:root {
    --bg-color: #f7f9fc;
    --primary-color: #1a73e8;
    --primary-dark: #1557b0;
    --secondary-color: #34a853;
    --text-color: #202124;
    --border-color: #dadce0;
    --card-bg: #fff;
    --slip-bg: #fff;
    --slip-brand: #1a73e8;
    --slip-text: #3c4043;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: 'Noto Sans TC', system-ui, sans-serif;
    background-color: var(--bg-color);
    color: var(--text-color);
    line-height: 1.6;
}

#app {
    max-width: 800px;
    margin: 0 auto;
    padding: 20px;
}

/* Utilities */
.text-center { text-align: center; }
.align-end { align-items: flex-end; }
.full-width { grid-column: 1 / -1; }

/* Stepper */
.stepper {
    display: flex;
    justify-content: space-between;
    margin-bottom: 20px;
    background: transparent;
    padding: 10px 0;
}
.step {
    flex: 1;
    text-align: center;
    font-size: 0.85em;
    color: #9aa0a6;
    position: relative;
    font-weight: 500;
}
.step.active {
    color: var(--primary-color);
    font-weight: 700;
}

/* Views */
.view {
    display: none;
    animation: fadeIn 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}
.view.active {
    display: block;
}
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(15px); }
    to { opacity: 1; transform: translateY(0); }
}
.view-title {
    margin-bottom: 25px;
    font-size: 1.6rem;
    font-weight: 700;
    color: #202124;
}

/* Forms & UI */
.form-section {
    background: var(--card-bg);
    padding: 24px;
    border-radius: 16px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.03);
    margin-bottom: 20px;
    border: 1px solid var(--border-color);
}
.section-title {
    font-size: 1.1rem;
    color: var(--primary-color);
    margin-bottom: 15px;
    font-weight: 600;
    border-bottom: 2px solid #e8eaed;
    padding-bottom: 8px;
}
.form-row {
    display: flex;
    gap: 15px;
    margin-bottom: 15px;
    flex-wrap: wrap;
}
.form-group {
    display: flex;
    flex-direction: column;
}
.row-group {
    flex-direction: row;
    align-items: center;
    gap: 10px;
}
label {
    font-size: 0.85rem;
    font-weight: 600;
    margin-bottom: 6px;
    color: #5f6368;
}
input[type="text"], input[type="tel"], input[type="date"], input[type="time"], input[type="number"], .modern-select, input[type="password"] {
    padding: 12px 16px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    font-size: 1rem;
    font-family: inherit;
    background: #f8f9fa;
    transition: all 0.2s;
    width: 100%;
}
input:focus, .modern-select:focus {
    outline: none;
    border-color: var(--primary-color);
    background: #fff;
    box-shadow: 0 0 0 3px rgba(26,115,232,0.15);
}
.short-input { width: 70px !important; }

/* Radio Cards (Service Type) */
.radio-group-modern {
    display: flex;
    gap: 12px;
}
.radio-card {
    flex: 1;
    position: relative;
    cursor: pointer;
}
.radio-card input {
    position: absolute;
    opacity: 0;
}
.rc-content {
    background: #f8f9fa;
    border: 2px solid #e8eaed;
    border-radius: 10px;
    padding: 15px 10px;
    text-align: center;
    font-weight: 600;
    color: #5f6368;
    transition: all 0.2s;
}
.radio-card input:checked + .rc-content {
    border-color: var(--primary-color);
    background: rgba(26,115,232,0.05);
    color: var(--primary-color);
}

/* AI Box */
.ai-box {
    background: linear-gradient(135deg, #e8f0fe 0%, #fce8e6 100%);
    border-radius: 16px;
    padding: 20px;
    margin-bottom: 25px;
    border: 1px solid #d2e3fc;
}
.ai-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.ai-box h3 {
    margin: 0;
    color: #1967d2;
    font-size: 1.1rem;
}
.ai-box p {
    font-size: 0.9rem;
    color: #3c4043;
    margin: 8px 0 15px;
}
.settings-icon {
    font-size: 0.85rem;
    text-decoration: none;
    color: #5f6368;
}
.settings-panel {
    background: rgba(255,255,255,0.8);
    padding: 15px;
    border-radius: 8px;
    margin: 10px 0;
}
.settings-desc { font-size: 0.8rem; color: #555; }
.file-modern {
    background: #fff;
    padding: 10px;
    border-radius: 8px;
    border: 1px dashed #aecbfa;
    width: 100%;
}
.ai-status { margin-top: 10px; font-size: 0.9rem; font-weight: 600; color: #188038; }

/* Buttons */
.form-actions { display: flex; gap: 15px; justify-content: center; margin-top: 20px; }
.dashboard-actions { display: flex; flex-direction: column; gap: 12px; margin-top: 25px; }
button {
    padding: 12px 24px;
    border: none;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    font-family: inherit;
}
.btn-primary { background: var(--primary-color); color: #fff; }
.btn-primary:active { opacity: 0.8; }
.btn-secondary { background: var(--secondary-color); color: #fff; }
.btn-outline { background: transparent; border: 2px solid var(--border-color); color: #3c4043; }
.btn-dark { background: #202124; color: #fff; }
.btn-large { padding: 16px 32px; font-size: 1.1rem; border-radius: 12px; width: 100%; box-shadow: 0 4px 12px rgba(26,115,232,0.3); }
.btn-block { width: 100%; padding: 15px; text-align: left; }
.icon-btn { display: flex; align-items: center; gap: 10px; font-size: 1.05rem; }
.text-link { color: var(--primary-color); text-decoration: none; font-size: 0.9rem; font-weight: 500; }

/* Dashboard & Status */
.status-card {
    background: #fff;
    border-radius: 16px;
    padding: 30px;
    border: 1px solid var(--border-color);
    box-shadow: 0 4px 15px rgba(0,0,0,0.05);
}
.status-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
}
.badge {
    background: #feefc3;
    color: #e37400;
    padding: 6px 12px;
    border-radius: 20px;
    font-size: 0.85rem;
    font-weight: 700;
}
.badge.signed { background: #e6f4ea; color: #137333; }
.instruction-text { color: #5f6368; font-size: 0.95rem; }
.action-divider {
    text-align: center;
    position: relative;
    margin: 10px 0;
}
.action-divider::before {
    content: '';
    position: absolute;
    top: 50%; left: 0; right: 0;
    border-top: 1px dashed #dadce0;
    z-index: 1;
}
.action-divider span {
    background: #fff;
    padding: 0 10px;
    color: #9aa0a6;
    font-size: 0.8rem;
    position: relative;
    z-index: 2;
}

/* Canvas */
.canvas-container {
    border: 2px dashed var(--border-color);
    border-radius: 12px;
    background-color: #f8f9fa;
    height: 350px;
    width: 100%;
    margin-bottom: 20px;
    position: relative;
}
#signature-canvas { position: absolute; top:0; left:0; width:100%; height:100%; cursor: crosshair; touch-action: none; }

/* =========================================
   BEAUTIFIED SLIP DESIGN
========================================= */
.slip-wrapper {
    background: #e8eaed;
    padding: 20px;
    border-radius: 16px;
    overflow-x: auto;
}
.slip-container {
    background: var(--slip-bg);
    width: 100%;
    max-width: 800px;
    margin: 0 auto;
    padding: 40px;
    border-radius: 8px; /* Look like paper */
    box-shadow: 0 10px 25px rgba(0,0,0,0.1);
    color: var(--slip-text);
}
.slip-actions { display: flex; justify-content: space-between; margin-bottom: 20px; }

/* Slip Header */
.slip-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    border-bottom: 3px solid var(--slip-brand);
    padding-bottom: 20px;
    margin-bottom: 25px;
}
.slip-brand { display: flex; align-items: center; gap: 18px; }
.logo-placeholder {
    width: 60px;
    height: 60px;
    background: var(--slip-brand);
    color: #fff;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 1.2rem;
}
.slip-logo {
    height: 75px; 
    width: auto;
    max-width: 180px;
    object-fit: contain; /* Using contain to ensure 'MAMBA RENTAL' isn't cut off */
    border-radius: 8px;
}
.slip-title-text h1 {
    font-size: 2.2rem;
    margin: 0;
    letter-spacing: 2px;
    color: #202124;
}
.slip-title-text p {
    font-size: 0.85rem;
    color: #80868b;
    margin: 2px 0 0;
    letter-spacing: 3px;
    font-family: 'Montserrat', sans-serif;
}
.slip-meta { text-align: right; }
.meta-tag {
    display: inline-block;
    background: #e8f0fe;
    color: var(--slip-brand);
    padding: 6px 12px;
    border-radius: 6px;
    font-weight: 700;
    font-size: 1.1rem;
    margin-bottom: 5px;
}
.meta-date { font-size: 0.9rem; color: #5f6368; }

/* Slip Body & Cards */
.slip-card {
    border: 1px solid #e8eaed;
    border-radius: 8px;
    margin-bottom: 20px;
    overflow: hidden;
}
.card-title {
    background: #f8f9fa;
    padding: 12px 20px;
    margin: 0;
    font-size: 1.05rem;
    color: #202124;
    border-bottom: 1px solid #e8eaed;
}
.card-title span { color: #9aa0a6; font-size: 0.85rem; margin-left: 8px; font-weight: 400; }
.grid-content {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0;
}
.grid-item {
    padding: 15px 20px;
    border-bottom: 1px solid #e8eaed;
    border-right: 1px solid #e8eaed;
    display: flex;
    flex-direction: column;
}
.grid-item:nth-child(even) { border-right: none; }
.grid-content.two-col .grid-item { border-right: 1px solid #e8eaed; }
.grid-content.two-col .grid-item:nth-child(even) { border-right: none; }

.highlight-row { background: #fef7e0; border-bottom: 1px solid #e8eaed !important; border-right: none !important;}
.label { font-size: 0.8rem; color: #80868b; margin-bottom: 4px; }
.value { font-size: 1.1rem; font-weight: 600; color: #202124; word-break: break-all; }
.thin-tag { font-weight: 400; color: #5f6368; font-size: 0.9rem; }
.car-plate { letter-spacing: 1px; font-family: 'Montserrat', sans-serif; }

/* Route Display inside Grid */
.route-display {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
}
.route-display .point { display: flex; flex-direction: column; flex: 1; }
.route-display .time { color: var(--slip-brand); font-weight: 600; margin-left: 8px; }
.route-arrow {
    font-size: 1.5rem;
    color: #dadce0;
    padding: 0 20px;
}

.price-row {
    padding: 20px;
    background: #f8f9fa;
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.price-row .label { font-size: 1rem; color: #202124; font-weight: 600; margin: 0; }
.price-value { font-size: 1.5rem; color: #1e8e3e; font-family: 'Montserrat', sans-serif; }

/* Signature Area */
.signature-section {
    display: flex;
    gap: 20px;
    margin-top: 30px;
}
.sign-box {
    flex: 1;
    border: 1px solid #dadce0;
    border-radius: 8px;
    height: 180px;
    position: relative;
    background: #fff;
}
.sign-label {
    position: absolute;
    top: -12px;
    left: 15px;
    background: #fff;
    padding: 0 8px;
    font-size: 0.85rem;
    color: #5f6368;
    font-weight: 600;
}
.unsigned-text { color: #d93025; font-weight: 400; font-size: 0.8rem; }
.stamp-container {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 15px 5px 5px 5px; /* Reduced padding to maximize space, leaving room for the label at the top */
}
.company-stamp-box img {
    width: 100%;
    height: 100%;
    max-height: 150px; /* Scale up as much as possible up to height */
    object-fit: contain;
    opacity: 0.95;
    mix-blend-mode: multiply;
}
.passenger-sign-box img {
    width: 100%;
    height: 100%;
    max-height: 150px;
    object-fit: contain;
}

.slip-footer {
    margin-top: 30px;
    text-align: center;
    font-size: 0.85rem;
    color: #9aa0a6;
    border-top: 1px solid #e8eaed;
    padding-top: 15px;
}

/* Constraint Utilities */
input, select, textarea { max-width: 100%; box-sizing: border-box; }
.modern-select { text-overflow: ellipsis; }
.slip-wrapper { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.slip-container { min-width: 750px; }

@media (max-width: 600px) {
    #app { padding: 10px; width: 100%; }
    .form-section { padding: 15px; margin-bottom: 15px; }
    .stepper { font-size: 0.9em; padding: 5px 0; }
    
    .form-row { flex-direction: column; gap: 15px; align-items: stretch !important; }
    .form-group, .form-group.full-width { width: 100%; }
    .radio-group-modern { flex-direction: column; }
}

@media (orientation: landscape) and (max-height: 600px) {
    .canvas-container { height: 65vh; margin-bottom: 10px; }
    .view-title { margin-bottom: 10px; font-size: 1.3rem; }
}

/* Navigation Top Bar */
.top-nav { display: flex; gap: 10px; margin-bottom: 15px; padding-bottom: 10px; border-bottom: 1px solid var(--border-color); }
.btn-topnav { flex: 1; padding: 12px; border-radius: 8px; font-size: 1rem; font-weight: 600; cursor: pointer; background: #fff; border: 1px solid var(--border-color); color: #444; }
.btn-topnav.primary-nav { background: var(--primary-color); color: #fff; border-color: var(--primary-color); }

/* History View */
.history-list-container { display: flex; flex-direction: column; gap: 15px; padding-bottom: 30px; }
.history-card { background: #fff; border: 1px solid var(--border-color); border-radius: 8px; padding: 15px; box-shadow: 0 2px 4px rgba(0,0,0,0.02); }
.h-card-top { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; }
.h-card-top strong { color: var(--primary-color); font-size: 1.1rem; }
.h-card-mid { font-size: 1.2rem; font-weight: 600; margin-bottom: 8px; }
.h-card-bot { color: #666; font-size: 0.95rem; margin-bottom: 12px; }
/* Disclaimer Overlay */
.disclaimer-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.85);
    backdrop-filter: blur(8px);
    z-index: 9999;
    display: none; /* Hidden by default, shown by JS */
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.disclaimer-content {
    background: #fff;
    width: 100%;
    max-width: 600px;
    max-height: 90vh;
    border-radius: 24px;
    padding: 30px;
    overflow-y: auto;
    position: relative;
    box-shadow: 0 20px 40px rgba(0,0,0,0.4);
    display: flex;
    flex-direction: column;
}

.disclaimer-title {
    text-align: center;
    color: var(--primary-color);
    font-size: 1.5rem;
    margin-bottom: 20px;
    padding-bottom: 15px;
    border-bottom: 2px solid #f0f0f0;
}

.disclaimer-body {
    font-size: 0.95rem;
    line-height: 1.7;
    color: #444;
}

.disclaimer-body ol {
    padding-left: 20px;
    margin-bottom: 20px;
}

.disclaimer-body li {
    margin-bottom: 10px;
}

.disclaimer-warning {
    background: linear-gradient(135deg, #fff5f5 0%, #fff1f0 100%);
    border: 2px solid #ffccc7;
    border-left: 8px solid #ff4d4f;
    padding: 20px;
    border-radius: 12px;
    margin: 25px 0;
    color: #cf1322;
    font-weight: 500;
    box-shadow: 0 4px 12px rgba(255, 77, 79, 0.1);
}

.disclaimer-warning strong {
    color: #a8071a;
    font-size: 1.25rem;
    display: block;
    margin-bottom: 8px;
    text-shadow: 0 1px 1px rgba(0,0,0,0.05);
}

.main-version-footer {
    text-align: center;
    padding: 20px 0;
    font-size: 0.85rem;
    color: #9aa0a6;
    font-family: 'Montserrat', sans-serif;
}

.authorized-list {
    margin-top: 20px;
    padding: 15px;
    background: #f8f9fa;
    border-radius: 12px;
}

.authorized-list h3 {
    font-size: 1rem;
    color: #333;
    margin-bottom: 8px;
}

.authorized-list p {
    font-weight: 700;
    color: var(--primary-color);
    font-size: 1.1rem;
}

.disclaimer-actions {
    margin-top: 30px;
}

.version-footer {
    text-align: center;
    margin-top: 20px;
    font-size: 0.8rem;
    color: #999;
    font-family: 'Montserrat', sans-serif;
}

@media (max-width: 600px) {
    .disclaimer-content {
        padding: 20px;
        border-radius: 16px;
    }
}

.feedback-container {
    display: flex;
    justify-content: center;
    margin-top: 10px;
}

.btn-feedback {
    font-size: 0.9rem;
    padding: 8px 16px;
    border-color: #d1d9e6;
    color: #5f6368;
    background: #fff;
    border-radius: 20px;
}

.btn-feedback:hover {
    background: #f8f9fa;
    border-color: #aecbfa;
    color: var(--primary-color);
}

.feedback-modal-content {
    max-width: 500px;
}
