:root {
    --primary: #000000;
    --primary-hover: #333333;
    --accent: #276ef1; /* Uber Blue for secondary actions */
    --bg-main: #ffffff;
    --bg-secondary: #f6f6f6;
    --text-main: #000000;
    --text-muted: #545454;
    --success: #05a357;
    --danger: #e11900;
    --warning: #ffc043;
    --radius: 0px; /* Uber uses very sharp or slightly rounded corners, but modern Base Web has some rounding. I'll use 8px for a modern feel. */
    --radius-lg: 12px;
    --shadow: 0 4px 16px rgba(0,0,0,0.08);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

body {
    background-color: var(--bg-main);
    color: var(--text-main);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    -webkit-user-select: none; /* Native app feel */
    user-select: none;
    -webkit-tap-highlight-color: transparent; /* Remove blue tap highlight on mobile */
    overscroll-behavior-y: contain; /* Evita conflito com o pull-to-refresh nativo do navegador */
}

/* Trava o scroll do fundo enquanto um modal estiver aberto */
body.modal-open {
    overflow: hidden;
}

html:has(body.modal-open) {
    overflow: hidden;
}

input, textarea, select {
    user-select: auto; /* Re-enable selection for inputs */
}

.container {
    max-width: 500px;
    margin: 0 auto;
    padding: 1.5rem;
}

@media (max-width: 400px) {
    .container {
        padding: 1rem;
    }
}

header {
    background: var(--primary);
    color: white;
    padding: calc(1.5rem + env(safe-area-inset-top, 0px)) 1.5rem 1.5rem;
    position: sticky;
    top: 0;
    z-index: 100;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

header h1 {
    font-size: 1.25rem;
    font-weight: 700;
    letter-spacing: -0.02em;
}

header .logout-btn {
    color: white;
    text-decoration: none;
    font-size: 0.8rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 0.4rem;
    background: rgba(255, 255, 255, 0.15);
    padding: 0.45rem 0.85rem;
    border-radius: 20px;
    transition: background 0.2s;
}

header .logout-btn:hover {
    background: rgba(255, 255, 255, 0.25);
}

header .logout-btn i {
    font-size: 0.9rem;
}

/* Uber-style Greeting */
.greeting {
    padding: 2rem 0 1rem 0;
}

.greeting h2 {
    font-size: 2rem;
    font-weight: 700;
    line-height: 1.1;
    margin-bottom: 0.5rem;
}

.greeting p {
    color: var(--text-muted);
    font-size: 1rem;
}

@media (max-width: 400px) {
    .greeting h2 {
        font-size: 1.75rem;
    }
    .greeting {
        padding: 1.5rem 0 1rem 0;
    }
}

/* ========================================
   1. STATUS FILTER TABS
   ======================================== */
.filter-tabs {
    display: flex;
    background: var(--bg-secondary);
    border-radius: 12px;
    padding: 4px;
    gap: 4px;
    margin-bottom: 1.5rem;
}

.filter-tab {
    flex: 1;
    border: none;
    padding: 0.65rem 0.5rem;
    border-radius: 8px;
    font-size: 0.8rem;
    font-weight: 700;
    cursor: pointer;
    background: transparent;
    color: var(--text-muted);
    transition: all 0.25s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.35rem;
    position: relative;
}

.filter-tab.active {
    background: white;
    color: var(--primary);
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

.filter-tab .tab-count {
    background: var(--bg-secondary);
    font-size: 0.65rem;
    font-weight: 800;
    padding: 0.1rem 0.4rem;
    border-radius: 10px;
    min-width: 18px;
    text-align: center;
    line-height: 1.4;
}

.filter-tab.active .tab-count {
    background: var(--primary);
    color: white;
}

@media (max-width: 380px) {
    .filter-tab {
        font-size: 0.7rem;
        padding: 0.6rem 0.25rem;
    }
    .filter-tab .tab-count {
        padding: 0.1rem 0.3rem;
        min-width: 15px;
    }
}

/* ========================================
   2. STATUS BADGES
   ======================================== */
.status-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    font-size: 0.65rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    padding: 0.25rem 0.6rem;
    border-radius: 6px;
    line-height: 1;
}

.status-badge.scheduled {
    background: #FFF8E1;
    color: #F59E0B;
}

.status-badge.in-progress {
    background: #E8F0FE;
    color: var(--accent);
    animation: badgePulse 2s ease-in-out infinite;
}

.status-badge.completed {
    background: #E8F5E9;
    color: var(--success);
}

.status-badge i {
    font-size: 0.55rem;
}

@keyframes badgePulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.6; }
}

/* ========================================
   3. DATE GROUP HEADERS
   ======================================== */
.date-group-header {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 1rem;
    margin-top: 0.5rem;
}

.date-group-header .date-label {
    font-size: 0.8rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-muted);
    white-space: nowrap;
}

.date-group-header .date-label.today {
    color: var(--accent);
}

.date-group-header .date-line {
    flex: 1;
    height: 1px;
    background: #E5E7EB;
}

/* ========================================
   5. PULL-TO-REFRESH
   ======================================== */
.ptr-container {
    position: relative;
    overflow: visible;
}

.ptr-indicator {
    position: absolute;
    top: -50px;
    left: 50%;
    transform: translateX(-50%);
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: white;
    box-shadow: 0 2px 12px rgba(0,0,0,0.15);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: top 0.2s, opacity 0.2s;
    opacity: 0;
    z-index: 50;
}

.ptr-indicator i {
    font-size: 1rem;
    color: var(--primary);
    transition: transform 0.3s;
}

.ptr-indicator.pulling {
    opacity: 1;
}

.ptr-indicator.refreshing i {
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

/* ========================================
   6. KM DISPLAY IN CARDS
   ======================================== */
.km-display {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-top: 0.75rem;
    padding: 0.5rem 0.75rem;
    background: var(--bg-secondary);
    border-radius: 8px;
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-muted);
}

.km-display i {
    color: var(--accent);
    font-size: 0.9rem;
}

.km-display .km-value {
    color: var(--text-main);
    font-weight: 800;
}

.card-active .km-display {
    background: rgba(39, 110, 241, 0.08);
}

/* ========================================
   7. COUNTDOWN TIMER
   ======================================== */
.countdown-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    font-size: 0.75rem;
    font-weight: 700;
    color: var(--accent);
    margin-top: 0.5rem;
    padding: 0.35rem 0.65rem;
    background: #E8F0FE;
    border-radius: 6px;
    animation: countdownPulse 3s ease-in-out infinite;
}

.countdown-badge i {
    font-size: 0.7rem;
}

@keyframes countdownPulse {
    0%, 100% { background: #E8F0FE; }
    50% { background: #D2E3FC; }
}

/* ========================================
   4. GESTOR OBSERVATION (in modal)
   ======================================== */
.gestor-observation {
    margin-bottom: 1.5rem;
    text-align: left;
}

.gestor-observation h4 {
    margin-bottom: 0.5rem;
    font-size: 1rem;
    color: var(--accent);
    display: flex;
    align-items: center;
    gap: 0.4rem;
}

.gestor-observation .obs-content {
    font-size: 0.9rem;
    color: var(--text-main);
    background: #E8F0FE;
    padding: 0.8rem;
    border-left: 3px solid var(--accent);
    border-radius: 0 8px 8px 0;
    font-weight: 500;
}

/* ========================================
   EXISTING STYLES (preserved)
   ======================================== */

/* Uber-style Cards */
.card {
    background: var(--bg-main);
    border-radius: var(--radius-lg);
    padding: 1.25rem;
    margin-bottom: 1.5rem;
    border: 1px solid #eeeeee;
    transition: background 0.2s, opacity 0.3s, transform 0.3s;
    cursor: pointer;
    position: relative;
    overflow: hidden;
    animation: cardFadeIn 0.35s ease-out both;
}

@keyframes cardFadeIn {
    from { 
        opacity: 0;
        transform: translateY(12px);
    }
    to { 
        opacity: 1;
        transform: translateY(0);
    }
}

.card:nth-child(1) { animation-delay: 0.02s; }
.card:nth-child(2) { animation-delay: 0.06s; }
.card:nth-child(3) { animation-delay: 0.10s; }
.card:nth-child(4) { animation-delay: 0.14s; }
.card:nth-child(5) { animation-delay: 0.18s; }

.card:hover {
    background: var(--bg-secondary);
}

.card-active {
    background: #E8F0FE; 
    border-color: #A0C3FF;
    border-left: 6px solid var(--accent);
    box-shadow: 0 4px 16px rgba(39, 110, 241, 0.12);
}

.card-active:hover {
    background: #D2E3FC; 
    border-color: #8AB4F8;
}

.card-finished {
    background: #F3F4F6;
    border: 1px dashed #D1D5DB;
    opacity: 0.5;
    filter: grayscale(1);
}

.card-finished:hover {
    opacity: 0.7;
}

.card .req-badge {
    position: absolute;
    top: 1.25rem;
    right: 1.25rem;
    font-size: 0.75rem;
    font-weight: 700;
    color: var(--text-muted);
    background: var(--bg-secondary);
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
}

.travel-info {
    display: flex;
    align-items: flex-start;
    gap: 1rem;
}

.icon-box {
    width: 40px;
    height: 40px;
    background: var(--bg-secondary);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.icon-box i {
    font-size: 1.25rem;
    color: var(--primary);
}

.travel-details {
    flex-grow: 1;
}

.origin-label {
    font-size: 0.875rem;
    color: var(--text-muted);
    margin-bottom: 0.75rem;
    overflow-wrap: anywhere;
}

.destination {
    font-size: 1.125rem;
    font-weight: 700;
    margin-bottom: 0.25rem;
    overflow-wrap: anywhere;
}

.meta-info {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem 1.5rem;
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text-main);
}

.meta-info i {
    margin-right: 0.4rem;
    color: var(--text-muted);
}

.status-indicator {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    margin-right: 0.5rem;
}

.status-indicator.active { background: var(--success); }
.status-indicator.pending { background: var(--warning); }

/* Buttons */
.btn {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 600;
    border: none;
    cursor: pointer;
    transition: all 0.2s;
    width: 100%;
    margin-top: 1rem;
}

.btn:active {
    transform: scale(0.97); /* Instant feedback on tap */
}

.btn-primary {
    background: var(--primary);
    color: white;
}

.btn-primary:hover {
    background: var(--primary-hover);
}

.btn-outline {
    background: var(--bg-secondary);
    color: var(--text-main);
}

.btn-danger {
    background: #FFEFEE;
    color: var(--danger);
}

/* Modal Uber Style */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.6);
    backdrop-filter: blur(2px); /* Native modal effect */
    z-index: 1000;
    align-items: flex-end; /* Align bottom for slide-up */
    animation: fadeIn 0.2s ease-out;
}

.modal.closing {
    animation: fadeOut 0.18s ease-in forwards;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes fadeOut {
    from { opacity: 1; }
    to { opacity: 0; }
}

.modal-content {
    background: white;
    width: 100%;
    max-height: 90vh;
    max-height: 90dvh; /* Altura dinâmica: respeita barra do navegador no iOS */
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    padding: 2rem 1.5rem calc(2rem + env(safe-area-inset-bottom, 0px));
    border-radius: 20px 20px 0 0;
    animation: slideUp 0.3s cubic-bezier(0.16, 1, 0.3, 1) forwards;
    position: relative;
}

/* Alça de arraste — padrão de bottom sheet nativo */
.modal-content::before {
    content: "";
    position: absolute;
    top: 8px;
    left: 50%;
    transform: translateX(-50%);
    width: 42px;
    height: 5px;
    border-radius: 3px;
    background: #E0E0E0;
}

@media (max-width: 400px) {
    .modal-content {
        padding: 1.5rem 1rem;
    }
}

@keyframes slideUp {
    from { transform: translateY(100%); }
    to { transform: translateY(0); }
}

.modal-content h2 {
    font-size: 1.5rem;
    font-weight: 700;
    margin-bottom: 1.5rem;
}

.form-group {
    margin-bottom: 1.5rem;
}

.form-group label {
    display: block;
    font-size: 0.875rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
    color: var(--text-muted);
}

.form-control {
    width: 100%;
    padding: 0.875rem;
    background: var(--bg-secondary);
    border: none;
    border-radius: 8px;
    font-size: 1rem; /* 16px mínimo: evita zoom automático do iOS ao focar */
    -webkit-appearance: none;
    appearance: none;
}

/* Segmented Control for Checklist */
.segmented-control {
    display: flex;
    background: var(--bg-secondary);
    border-radius: 12px;
    padding: 4px;
    gap: 4px;
    margin-top: 0.5rem;
}

.segmented-control button {
    flex: 1;
    border: none;
    padding: 0.75rem 0.5rem;
    border-radius: 8px;
    font-size: 0.75rem;
    font-weight: 700;
    cursor: pointer;
    background: transparent;
    color: var(--text-muted);
    transition: all 0.2s;
}

.segmented-control button.active {
    background: white;
    color: var(--primary);
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

.segmented-control button.active[data-value="NAO CONFORME"] {
    color: var(--danger);
}

.segmented-control button.active[data-value="CONFORME"] {
    color: var(--success);
}

.checklist-item {
    flex-direction: column;
    align-items: flex-start;
    padding: 1.25rem 0;
}

/* Big Action Bar */
.action-footer {
    position: fixed;
    bottom: 0;
    left: 0;
    width: 100%;
    background: white;
    padding: 1.5rem;
    box-shadow: 0 -10px 20px rgba(0,0,0,0.05);
    z-index: 900;
}

.travel-card.active {
    border-left: 6px solid var(--accent);
}

/* Login Card Override */
.login-container {
    height: 100vh;
    background: var(--primary);
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
}

.login-card {
    background: white;
    padding: 3rem 2rem;
    border-radius: 24px 24px 0 0;
    width: 100%;
    max-width: 500px;
    margin: 0 auto;
}

@media (max-width: 400px) {
    .login-card {
        padding: 2rem 1.5rem;
    }
}

.login-card h2 {
    font-size: 1.75rem;
    margin-bottom: 1.5rem;
}

/* Toast Enhancements */
.toast {
    padding: 1rem 1.5rem;
    border-radius: 12px;
    color: white;
    font-weight: 600;
    box-shadow: 0 8px 24px rgba(0,0,0,0.2);
    animation: slideUpIn 0.3s forwards; /* container fica no rodapé */
    max-width: 90vw;
    text-align: center;
}

@keyframes slideUpIn {
    from { transform: translateY(20px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

.toast.success { background: var(--success); }
.toast.error { background: var(--danger); }
.toast.warning { background: var(--warning); color: var(--primary); }
.toast.info { background: var(--accent); }

/* ========================================
   EMPTY STATE
   ======================================== */
.empty-state {
    text-align: center;
    padding: 3rem 1.5rem;
    color: var(--text-muted);
}

.empty-state i {
    font-size: 2.5rem;
    margin-bottom: 1rem;
    opacity: 0.3;
}

.empty-state p {
    font-size: 0.95rem;
    font-weight: 500;
}

.empty-state .empty-hint {
    margin-top: 0.4rem;
    font-size: 0.8rem;
    color: #9CA3AF;
}

/* ========================================
   VALIDAÇÃO INLINE + PRÉVIA DE DISTÂNCIA
   ======================================== */
.form-error {
    display: flex;
    align-items: flex-start;
    gap: 0.45rem;
    background: #fff5f5;
    border: 1px solid #feb2b2;
    color: var(--danger);
    font-size: 0.85rem;
    font-weight: 600;
    padding: 0.8rem 1rem;
    border-radius: 10px;
    margin-bottom: 1rem;
}

.form-error::before {
    content: "\f06a"; /* fa-exclamation-circle */
    font-family: "Font Awesome 6 Free";
    font-weight: 900;
}

.form-error[hidden] { display: none; }

.distance-preview {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    background: #eef4ff;
    color: var(--accent);
    font-size: 0.9rem;
    padding: 0.8rem 1rem;
    border-radius: 10px;
    margin-bottom: 1rem;
}

.distance-preview[hidden] { display: none; }

/* ========================================
   CONTATOS DO PASSAGEIRO
   ======================================== */
.contact-row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.5rem;
    margin-top: 0.7rem;
    user-select: text; /* Permite copiar o telefone/e-mail */
    -webkit-user-select: text;
}

.contact-number {
    width: 100%;
    display: flex;
    align-items: center;
    gap: 0.4rem;
    color: var(--text-muted);
    font-size: 0.78rem;
    font-weight: 600;
}

.contact-chip {
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
    padding: 0.55rem 1rem;
    border-radius: 20px;
    background: var(--primary);
    color: white;
    font-size: 0.8rem;
    font-weight: 600;
    text-decoration: none;
    transition: opacity 0.2s;
}

.contact-chip:active { opacity: 0.75; }

.contact-chip.whatsapp { background: #25d366; }
.contact-chip.maps { background: #4285f4; color: white; }
.contact-chip.waze { background: #33ccff; color: #0b0f19; }

/* ========================================
   BOTÕES DE AÇÃO: GPS, PASSAGEIROS E SUPORTE
   ======================================== */
header .support-btn {
    color: white;
    text-decoration: none;
    font-size: 0.8rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 0.4rem;
    background: #05a357;
    padding: 0.45rem 0.85rem;
    border-radius: 20px;
    transition: background 0.2s, transform 0.1s;
}

header .support-btn:hover, header .support-btn:active {
    background: #048245;
    transform: scale(0.98);
}

.card-actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.5rem;
    margin-top: 0.85rem;
}

.btn-gps {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    background: #eef4ff;
    color: #1a56db;
    border: 1px solid #bfdbfe;
    font-size: 0.82rem;
    font-weight: 600;
    padding: 0.5rem 0.85rem;
    border-radius: 8px;
    text-decoration: none;
    transition: background 0.2s, transform 0.1s;
}

.btn-gps:active {
    background: #dbeafe;
    transform: scale(0.98);
}

.btn-passengers {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    background: #f8fafc;
    color: #334155;
    border: 1px solid #cbd5e1;
    font-size: 0.82rem;
    font-weight: 600;
    padding: 0.5rem 0.85rem;
    border-radius: 8px;
    cursor: pointer;
    transition: background 0.2s, transform 0.1s;
}

.btn-passengers:active {
    background: #e2e8f0;
    transform: scale(0.98);
}

.distance-preview.warning {
    background: #fffbeb;
    color: #b45309;
    border: 1px solid #fde68a;
    font-weight: 600;
}
