/* Cobrun Rider App Design System */
:root {
    /* Colors */
    --primary-500: #6D28D9;
    --primary-700: #4C1D95;
    --accent-300: #FDE047;
    --text-900: #0F172A;
    --text-500: #64748B;
    --bg-50: #F8FAFC;
    --surface-0: #FFFFFF;
    --border-200: #E2E8F0;
    --success-600: #16A34A;
    --warn-500: #F59E0B;
    --danger-600: #DC2626;
    
    /* Spacing (8pt grid) */
    --spacing-4: 4px;
    --spacing-8: 8px;
    --spacing-12: 12px;
    --spacing-16: 16px;
    --spacing-20: 20px;
    --spacing-24: 24px;
    --spacing-32: 32px;
    --spacing-48: 48px;
    
    /* Radius */
    --radius-12: 12px;
    --radius-16: 16px;
    --radius-999: 999px;
}

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

/* Accessibility: Screen reader only class */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* Accessibility: Visible focus indicators */
:focus {
    outline: 2px solid var(--primary-500);
    outline-offset: 2px;
}

:focus:not(:focus-visible) {
    outline: none;
}

:focus-visible {
    outline: 2px solid var(--primary-500);
    outline-offset: 2px;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--bg-50);
    color: var(--text-900);
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

/* Typography */
h1 { font-size: 28px; line-height: 34px; font-weight: 600; }
h2 { font-size: 20px; line-height: 28px; font-weight: 600; }
h3 { font-size: 18px; line-height: 24px; font-weight: 600; }
.body { font-size: 16px; line-height: 24px; font-weight: 400; }
.caption { font-size: 13px; line-height: 18px; font-weight: 400; }
.button-text { font-size: 16px; line-height: 20px; font-weight: 600; }

/* Desktop-first container */
.rider-app {
    max-width: 100%;
    width: 100%;
    margin: 0;
    min-height: 100vh;
    background: var(--bg-50);
    position: relative;
    overflow-x: hidden;
}

/* Header */
.header {
    background: var(--surface-0);
    padding: var(--spacing-16) var(--spacing-32);
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid var(--border-200);
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
    height: 72px;
}

.header .logo {
    font-size: 24px;
    font-weight: 700;
    color: var(--primary-500);
    text-decoration: none;
}

.header .nav {
    display: flex;
    gap: var(--spacing-32);
    align-items: center;
}

.header .nav-link {
    text-decoration: none;
    color: var(--text-500);
    font-weight: 500;
    font-size: 15px;
    transition: color 0.2s ease;
}

.header .nav-link:hover,
.header .nav-link.active {
    color: var(--primary-500);
}

.header .profile {
    display: flex;
    align-items: center;
    gap: var(--spacing-12);
}

.header .notifications {
    position: relative;
    cursor: pointer;
    font-size: 20px;
}

.header .avatar {
    width: 40px;
    height: 40px;
    background: var(--primary-500);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: 600;
    cursor: pointer;
}

/* Mobile Menu Toggle */
.mobile-menu-toggle {
    display: none;
    background: none;
    border: none;
    font-size: 24px;
    cursor: pointer;
    color: var(--text-900);
    padding: var(--spacing-8);
}

.mobile-nav {
    display: none;
    position: fixed;
    top: 60px;
    left: 0;
    right: 0;
    bottom: 0;
    background: var(--surface-0);
    z-index: 99;
    overflow-y: auto;
    padding: var(--spacing-24);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.mobile-nav.active {
    display: block;
}

.mobile-nav .nav-link {
    display: block;
    padding: var(--spacing-16);
    text-decoration: none;
    color: var(--text-500);
    font-weight: 500;
    font-size: 16px;
    border-bottom: 1px solid var(--border-200);
    transition: all 0.2s ease;
}

.mobile-nav .nav-link:hover,
.mobile-nav .nav-link.active {
    color: var(--primary-500);
    background: var(--bg-50);
}

.mobile-nav .nav-link:last-child {
    border-bottom: none;
}

/* Leave Training Button */
.leave-training-btn {
    position: fixed;
    top: 16px;
    right: 16px;
    z-index: 200;
    padding: var(--spacing-8) var(--spacing-16);
    background: var(--surface-0);
    color: var(--text-900);
    border-radius: var(--radius-999);
    text-decoration: none;
    font-size: 14px;
    font-weight: 600;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    transition: all 0.2s ease;
}

.leave-training-btn:hover {
    background: var(--border-200);
    transform: translateY(-2px);
}

/* Main Content */
.main-content {
    width: 100%;
    max-width: 1360px;
    margin: 0 auto;
    padding: var(--spacing-24) var(--spacing-32);
}

/* Booking Workspace (Map + Panel) */
.booking-workspace {
    display: grid;
    grid-template-columns: 1fr 460px;
    gap: var(--spacing-24);
    height: calc(100vh - 72px);
    padding: var(--spacing-24);
}

.map-area {
    position: relative;
    border-radius: var(--radius-12);
    overflow: hidden;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    background: var(--bg-50);
}

.map-area #map {
    width: 100%;
    height: 100%;
    min-height: 500px;
}

.booking-panel {
    background: var(--surface-0);
    border-radius: var(--radius-12);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.panel-content {
    flex: 1;
    overflow-y: auto;
    padding: var(--spacing-24);
}

.panel-section {
    margin-bottom: var(--spacing-24);
}

.panel-section:last-child {
    margin-bottom: 0;
}

.panel-section-title {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-500);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: var(--spacing-12);
}

/* Location Field */
.location-field {
    display: flex;
    align-items: center;
    gap: var(--spacing-12);
    padding: var(--spacing-16);
    background: var(--bg-50);
    border-radius: var(--radius-12);
    margin-bottom: var(--spacing-12);
    cursor: pointer;
    transition: all 0.2s ease;
}

.location-field:hover {
    background: var(--border-200);
}

.location-field .icon {
    font-size: 20px;
    color: var(--text-500);
}

.location-field .content {
    flex: 1;
}

.location-field .label {
    font-size: 12px;
    color: var(--text-500);
    margin-bottom: 4px;
}

.location-field .value {
    font-size: 16px;
    font-weight: 500;
    color: var(--text-900);
}

.location-field .subvalue {
    font-size: 13px;
    color: var(--text-500);
    margin-top: 2px;
}

.location-field .actions {
    display: flex;
    gap: var(--spacing-8);
}

/* Where To Input */
.where-to-input {
    width: 100%;
    padding: var(--spacing-16) var(--spacing-20);
    font-size: 18px;
    border: 2px solid var(--border-200);
    border-radius: var(--radius-999);
    background: var(--surface-0);
    transition: all 0.2s ease;
}

.where-to-input:focus {
    outline: none;
    border-color: var(--primary-500);
    box-shadow: 0 0 0 3px rgba(109, 40, 217, 0.1);
}

/* Ride Tier Card */
.ride-tier-card {
    padding: var(--spacing-20);
    border: 2px solid var(--border-200);
    border-radius: var(--radius-12);
    margin-bottom: var(--spacing-12);
    cursor: pointer;
    transition: all 0.2s ease;
}

.ride-tier-card:hover {
    border-color: var(--primary-500);
    box-shadow: 0 4px 12px rgba(109, 40, 217, 0.1);
}

.ride-tier-card.selected {
    border-color: var(--primary-500);
    background: rgba(109, 40, 217, 0.05);
}

.ride-tier-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: var(--spacing-8);
}

.ride-tier-name {
    font-size: 18px;
    font-weight: 600;
}

.ride-tier-price {
    font-size: 20px;
    font-weight: 700;
    color: var(--primary-500);
}

.ride-tier-meta {
    display: flex;
    gap: var(--spacing-16);
    font-size: 13px;
    color: var(--text-500);
}

.ride-tier-badge {
    display: inline-block;
    padding: 4px 8px;
    background: var(--accent-300);
    color: var(--text-900);
    border-radius: var(--radius-999);
    font-size: 11px;
    font-weight: 600;
    margin-top: var(--spacing-8);
}

/* Sticky Confirm Bar */
.sticky-confirm-bar {
    padding: var(--spacing-20) var(--spacing-24);
    background: var(--surface-0);
    border-top: 1px solid var(--border-200);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.confirm-summary {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.confirm-eta {
    font-size: 13px;
    color: var(--text-500);
}

.confirm-price {
    font-size: 24px;
    font-weight: 700;
    color: var(--primary-500);
}

/* Buttons */
.btn {
    padding: var(--spacing-12) var(--spacing-24);
    border-radius: var(--radius-12);
    font-size: 16px;
    font-weight: 600;
    border: none;
    cursor: pointer;
    transition: all 0.2s ease;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--spacing-8);
}

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

.btn-primary:hover {
    background: var(--primary-700);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(109, 40, 217, 0.3);
}

.btn-secondary {
    background: var(--surface-0);
    color: var(--text-900);
    border: 1px solid var(--border-200);
}

.btn-secondary:hover {
    background: var(--bg-50);
    border-color: var(--primary-500);
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Card */
.card {
    background: var(--surface-0);
    border-radius: var(--radius-12);
    padding: var(--spacing-24);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
    margin-bottom: var(--spacing-16);
}

/* Table */
.table-container {
    background: var(--surface-0);
    border-radius: var(--radius-12);
    overflow: hidden;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
}

.table {
    width: 100%;
    border-collapse: collapse;
}

.table thead {
    background: var(--bg-50);
}

.table th {
    padding: var(--spacing-12) var(--spacing-16);
    text-align: left;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-500);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.table td {
    padding: var(--spacing-16);
    border-top: 1px solid var(--border-200);
    font-size: 14px;
}

.table tbody tr:hover {
    background: var(--bg-50);
}

/* Filter Bar */
.filter-bar {
    display: flex;
    gap: var(--spacing-12);
    margin-bottom: var(--spacing-24);
    flex-wrap: wrap;
}

.filter-input {
    padding: var(--spacing-8) var(--spacing-12);
    border: 1px solid var(--border-200);
    border-radius: var(--radius-12);
    font-size: 14px;
    background: var(--surface-0);
}

/* Status Badge */
.status-badge {
    display: inline-block;
    padding: 4px 12px;
    border-radius: var(--radius-999);
    font-size: 12px;
    font-weight: 600;
}

.status-badge.completed {
    background: rgba(22, 163, 74, 0.1);
    color: var(--success-600);
}

.status-badge.cancelled {
    background: rgba(220, 38, 38, 0.1);
    color: var(--danger-600);
}

.status-badge.in-progress {
    background: rgba(109, 40, 217, 0.1);
    color: var(--primary-500);
}

/* Mobile-first responsive utilities */
.mobile-grid {
    display: grid;
}

.mobile-grid-2col {
    grid-template-columns: 2fr 1fr;
}

.mobile-grid-3col {
    grid-template-columns: repeat(3, 1fr);
}

/* Trip Timeline */
.trip-timeline {
    background: var(--surface-0);
    border-radius: var(--radius-12);
    padding: var(--spacing-24);
    margin-bottom: var(--spacing-16);
}

.timeline-step {
    display: flex;
    gap: var(--spacing-16);
    margin-bottom: var(--spacing-24);
    position: relative;
    opacity: 0.4;
    transition: all 0.3s ease;
}

.timeline-step:last-child {
    margin-bottom: 0;
}

.timeline-step.active {
    opacity: 1;
}

.timeline-step.completed {
    opacity: 1;
}

.timeline-step.completed .timeline-dot {
    background: var(--success-600);
    border-color: var(--success-600);
}

.timeline-step.active .timeline-dot {
    background: var(--primary-500);
    border-color: var(--primary-500);
    animation: pulse-dot 2s infinite;
}

.timeline-icon {
    position: relative;
    flex-shrink: 0;
}

.timeline-dot {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--border-200);
    border: 3px solid var(--border-200);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    position: relative;
}

.timeline-dot::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 14px;
    font-weight: 700;
    color: white;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.timeline-step.completed .timeline-dot::after {
    content: '✓';
    opacity: 1;
}

.timeline-step:not(:last-child)::after {
    content: '';
    position: absolute;
    left: 15px;
    top: 32px;
    width: 2px;
    height: calc(100% + var(--spacing-8));
    background: var(--border-200);
    z-index: 0;
}

.timeline-step.completed:not(:last-child)::after {
    background: var(--success-600);
}

.timeline-content {
    flex: 1;
    padding-top: 4px;
}

.timeline-title {
    font-weight: 600;
    font-size: 16px;
    color: var(--text-900);
    margin-bottom: 4px;
}

.timeline-subtitle {
    font-size: 14px;
    color: var(--text-500);
}

.timeline-step.active .timeline-title {
    color: var(--primary-500);
}

.driver-info-card {
    background: var(--surface-0);
    border-radius: var(--radius-12);
    padding: var(--spacing-24);
    margin-bottom: var(--spacing-16);
    animation: slideIn 0.3s ease;
}

@keyframes pulse-dot {
    0%, 100% {
        transform: scale(1);
        box-shadow: 0 0 0 0 rgba(109, 40, 217, 0.7);
    }
    50% {
        transform: scale(1.05);
        box-shadow: 0 0 0 8px rgba(109, 40, 217, 0);
    }
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Responsive - Mobile */
@media (max-width: 768px) {
    .header {
        padding: var(--spacing-12) var(--spacing-16);
        height: auto;
        min-height: 60px;
        flex-wrap: wrap;
    }
    
    .header .logo {
        font-size: 20px;
    }
    
    .header .nav {
        display: none;
    }
    
    .mobile-menu-toggle {
        display: block;
    }
    
    .header .profile {
        gap: var(--spacing-8);
    }
    
    .header .avatar {
        width: 32px;
        height: 32px;
        font-size: 14px;
    }
    
    .main-content {
        padding: var(--spacing-16);
        max-width: 100%;
    }
    
    .booking-workspace {
        grid-template-columns: 1fr !important;
        height: auto;
        padding: var(--spacing-16);
        gap: var(--spacing-16);
    }
    
    .map-area {
        height: 400px !important;
        min-height: 400px !important;
        max-height: 400px !important;
        order: 1;
    }
    
    .map-area #map {
        min-height: 400px !important;
    }
    
    .booking-panel {
        position: relative !important;
        width: 100% !important;
        transform: none !important;
        order: 2;
        max-height: none;
        border-radius: var(--radius-12) var(--radius-12) 0 0;
    }
    
    .panel-content {
        max-height: none;
        overflow-y: visible;
        padding: var(--spacing-16);
    }
    
    .where-to-input {
        font-size: 16px;
        padding: var(--spacing-12) var(--spacing-16);
    }
    
    .location-field {
        padding: var(--spacing-12);
    }
    
    .ride-tier-card {
        padding: var(--spacing-16);
    }
    
    .sticky-confirm-bar {
        position: sticky;
        bottom: 0;
        padding: var(--spacing-16);
        flex-direction: column;
        gap: var(--spacing-12);
        background: var(--surface-0);
        box-shadow: 0 -2px 8px rgba(0, 0, 0, 0.1);
    }
    
    .sticky-confirm-bar .btn {
        width: 100%;
    }
    
    /* Grid layouts become single column */
    .mobile-grid-2col,
    .mobile-grid-3col,
    div[style*="grid-template-columns: 2fr 1fr"],
    div[style*="grid-template-columns: 1fr 1fr"],
    div[style*="grid-template-columns: repeat(2"],
    div[style*="grid-template-columns: repeat(3"],
    div[style*="grid-template-columns: repeat(4"] {
        grid-template-columns: 1fr !important;
    }
    
    .table-container {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
    
    .table {
        min-width: 600px;
        font-size: 13px;
    }
    
    .table th,
    .table td {
        padding: var(--spacing-8) var(--spacing-12);
    }
    
    .filter-bar {
        flex-direction: column;
    }
    
    .filter-input {
        width: 100%;
    }
    
    .card {
        padding: var(--spacing-16);
    }
    
    .modal {
        width: 95% !important;
        max-width: 95% !important;
        margin: var(--spacing-16);
        padding: var(--spacing-16);
    }
    
    .modal-overlay {
        padding: var(--spacing-16);
        align-items: flex-end;
    }
    
    .leave-training-btn {
        top: 8px;
        right: 8px;
        padding: var(--spacing-6) var(--spacing-12);
        font-size: 12px;
    }
    
    h1 {
        font-size: 24px;
    }
    
    h2 {
        font-size: 18px;
    }
    
    .btn {
        padding: var(--spacing-10) var(--spacing-16);
        font-size: 15px;
    }
    
    .kpi-grid {
        grid-template-columns: 1fr !important;
    }
    
    .panel-section {
        margin-bottom: var(--spacing-16);
    }
    
    .trip-timeline {
        padding: var(--spacing-16);
    }
    
    .timeline-step {
        margin-bottom: var(--spacing-16);
    }
    
    .timeline-dot {
        width: 28px;
        height: 28px;
    }
    
    .timeline-title {
        font-size: 14px;
    }
    
    .timeline-subtitle {
        font-size: 13px;
    }
    
    .driver-info-card {
        padding: var(--spacing-16);
    }
    
    /* Ensure modals work well on mobile */
    .modal-overlay {
        padding: 0;
        align-items: flex-end;
    }
    
    .modal {
        border-radius: var(--radius-16) var(--radius-16) 0 0;
        max-height: 90vh;
    }
    
    /* Ride tier cards mobile adjustments */
    .ride-tier-name {
        font-size: 16px;
    }
    
    .ride-tier-price {
        font-size: 18px;
    }
    
    .confirm-price {
        font-size: 20px;
    }
}

@media (max-width: 1280px) and (min-width: 769px) {
    .booking-workspace {
        grid-template-columns: 1fr;
        height: auto;
    }
    
    .booking-panel {
        position: fixed;
        right: 0;
        top: 72px;
        bottom: 0;
        width: 460px;
        z-index: 50;
        transform: translateX(100%);
        transition: transform 0.3s ease;
    }
    
    .booking-panel.open {
        transform: translateX(0);
    }
    
    .header .nav {
        gap: var(--spacing-20);
        font-size: 14px;
    }
}

