/**
 * BusTicketing SaaS - Main Stylesheet
 * Mobile-first, optimized for African network conditions
 * Single file for fewer HTTP requests
 */

/* ===== CSS VARIABLES ===== */
:root {
    --primary: #1a73e8;
    --primary-dark: #1557b0;
    --primary-light: #e8f0fe;
    --secondary: #00c853;
    --secondary-dark: #009624;
    --danger: #ea4335;
    --warning: #fbbc04;
    --info: #4285f4;
    --dark: #1a1a2e;
    --gray-100: #f8f9fa;
    --gray-200: #e9ecef;
    --gray-300: #dee2e6;
    --gray-400: #adb5bd;
    --gray-500: #6c757d;
    --gray-600: #495057;
    --gray-700: #343a40;
    --white: #ffffff;
    --shadow: 0 2px 8px rgba(0,0,0,0.1);
    --shadow-lg: 0 4px 16px rgba(0,0,0,0.15);
    --radius: 12px;
    --radius-sm: 8px;
    --transition: all 0.2s ease;
}

/* ===== RESET & BASE ===== */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    font-size: 16px;
    -webkit-text-size-adjust: 100%;
    touch-action: manipulation;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--gray-100);
    color: var(--dark);
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    overflow-x: hidden;
}

/* ===== LAYOUT ===== */
#app {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.container {
    width: 100%;
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 16px;
}

/* ===== HEADER ===== */
.app-header {
    background: var(--primary);
    color: var(--white);
    padding: 12px 16px;
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: var(--shadow);
}

.app-header .container {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.app-logo {
    font-size: 1.25rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 8px;
}

.app-logo i {
    font-size: 1.5rem;
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 12px;
}

/* ===== BOTTOM NAV (Mobile) ===== */
.bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: var(--white);
    border-top: 1px solid var(--gray-200);
    display: flex;
    justify-content: space-around;
    padding: 8px 0;
    z-index: 100;
    box-shadow: 0 -2px 8px rgba(0,0,0,0.05);
}

.nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    padding: 4px 12px;
    color: var(--gray-500);
    text-decoration: none;
    font-size: 0.7rem;
    transition: var(--transition);
    border: none;
    background: none;
    cursor: pointer;
}

.nav-item i {
    font-size: 1.25rem;
}

.nav-item.active,
.nav-item:hover {
    color: var(--primary);
}

/* ===== SIDEBAR (Desktop) ===== */
.sidebar {
    display: none;
    position: fixed;
    left: 0;
    top: 0;
    bottom: 0;
    width: 260px;
    background: var(--white);
    border-right: 1px solid var(--gray-200);
    z-index: 200;
    overflow-y: auto;
}

.sidebar-header {
    padding: 20px;
    border-bottom: 1px solid var(--gray-200);
}

.sidebar-menu {
    list-style: none;
    padding: 12px;
}

.sidebar-menu li {
    margin-bottom: 4px;
}

.sidebar-menu a {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    color: var(--gray-600);
    text-decoration: none;
    border-radius: var(--radius-sm);
    font-size: 0.9rem;
    font-weight: 500;
    transition: var(--transition);
}

.sidebar-menu a:hover,
.sidebar-menu a.active {
    background: var(--primary-light);
    color: var(--primary);
}

.sidebar-menu i {
    font-size: 1.1rem;
    width: 24px;
    text-align: center;
}

/* ===== MAIN CONTENT ===== */
.main-content {
    flex: 1;
    padding-bottom: 80px; /* Space for bottom nav */
}

.page-header {
    background: var(--white);
    padding: 20px 16px;
    border-bottom: 1px solid var(--gray-200);
    margin-bottom: 16px;
}

.page-title {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--dark);
}

.page-subtitle {
    color: var(--gray-500);
    font-size: 0.9rem;
    margin-top: 4px;
}

/* ===== CARDS ===== */
.card {
    background: var(--white);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 16px;
    margin-bottom: 16px;
}

.card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
}

.card-title {
    font-size: 1.1rem;
    font-weight: 600;
}

/* ===== STATS GRID ===== */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
    margin-bottom: 20px;
}

.stat-card {
    background: var(--white);
    border-radius: var(--radius);
    padding: 16px;
    box-shadow: var(--shadow);
}

.stat-card.primary { border-left: 4px solid var(--primary); }
.stat-card.success { border-left: 4px solid var(--secondary); }
.stat-card.warning { border-left: 4px solid var(--warning); }
.stat-card.danger { border-left: 4px solid var(--danger); }

.stat-value {
    font-size: 1.75rem;
    font-weight: 700;
    color: var(--dark);
    line-height: 1.2;
}

.stat-label {
    font-size: 0.8rem;
    color: var(--gray-500);
    margin-top: 4px;
}

/* ===== SEAT MAP ===== */
.seat-map-container {
    background: var(--white);
    border-radius: var(--radius);
    padding: 20px;
    margin-bottom: 16px;
}

.bus-front {
    text-align: center;
    padding: 12px;
    background: var(--gray-200);
    border-radius: var(--radius-sm) var(--radius-sm) 0 0;
    margin-bottom: 16px;
    font-weight: 600;
    color: var(--gray-600);
}

.seat-grid {
    display: grid;
    gap: 8px;
    justify-content: center;
}

.seat-row {
    display: flex;
    align-items: center;
    gap: 8px;
}

.seat {
    width: 48px;
    height: 48px;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.8rem;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    border: 2px solid transparent;
    user-select: none;
}

.seat.available {
    background: var(--primary-light);
    color: var(--primary);
    border-color: var(--primary);
}

.seat.selected {
    background: var(--primary);
    color: var(--white);
    border-color: var(--primary-dark);
    transform: scale(1.05);
}

.seat.booked {
    background: var(--gray-200);
    color: var(--gray-400);
    cursor: not-allowed;
    border-color: var(--gray-300);
}

.seat.locked {
    background: #fff3cd;
    color: #856404;
    cursor: wait;
    border-color: var(--warning);
}

.seat.premium {
    border-width: 3px;
    border-color: #ffd700;
}

.seat.aisle {
    width: 24px;
    background: transparent;
    border: none;
    cursor: default;
}

.seat-legend {
    display: flex;
    flex-wrap: wrap;
    gap: 16px;
    margin-top: 16px;
    padding-top: 16px;
    border-top: 1px solid var(--gray-200);
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.8rem;
    color: var(--gray-600);
}

.legend-seat {
    width: 20px;
    height: 20px;
    border-radius: 4px;
    border: 2px solid;
}

/* ===== FORMS ===== */
.form-group {
    margin-bottom: 16px;
}

.form-label {
    display: block;
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--gray-700);
    margin-bottom: 6px;
}

.form-input {
    width: 100%;
    padding: 12px 16px;
    border: 2px solid var(--gray-200);
    border-radius: var(--radius-sm);
    font-size: 1rem;
    font-family: inherit;
    transition: var(--transition);
    background: var(--white);
    -webkit-appearance: none;
}

.form-input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-light);
}

.form-input::placeholder {
    color: var(--gray-400);
}

select.form-input {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%23666' d='M6 9L1 4h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    padding-right: 36px;
}

/* ===== BUTTONS ===== */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px 24px;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 1rem;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    transition: var(--transition);
    text-decoration: none;
    -webkit-appearance: none;
    min-height: 48px;
}

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

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

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

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

.btn-secondary:hover:not(:disabled) {
    background: var(--secondary-dark);
}

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

.btn-outline {
    background: transparent;
    color: var(--primary);
    border: 2px solid var(--primary);
}

.btn-outline:hover:not(:disabled) {
    background: var(--primary-light);
}

.btn-block {
    width: 100%;
}

.btn-lg {
    padding: 16px 32px;
    font-size: 1.1rem;
}

.btn-sm {
    padding: 8px 16px;
    font-size: 0.85rem;
    min-height: 36px;
}

/* ===== SEARCH & FILTERS ===== */
.search-bar {
    position: relative;
    margin-bottom: 16px;
}

.search-bar i {
    position: absolute;
    left: 16px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--gray-400);
}

.search-bar input {
    padding-left: 44px;
}

.filters-row {
    display: flex;
    gap: 12px;
    margin-bottom: 16px;
    overflow-x: auto;
    padding-bottom: 4px;
}

.filter-chip {
    padding: 8px 16px;
    background: var(--white);
    border: 1px solid var(--gray-200);
    border-radius: 20px;
    font-size: 0.85rem;
    white-space: nowrap;
    cursor: pointer;
    transition: var(--transition);
}

.filter-chip.active {
    background: var(--primary);
    color: var(--white);
    border-color: var(--primary);
}

/* ===== LISTS ===== */
.list-item {
    background: var(--white);
    border-radius: var(--radius);
    padding: 16px;
    margin-bottom: 12px;
    box-shadow: var(--shadow);
    display: flex;
    align-items: center;
    gap: 16px;
    cursor: pointer;
    transition: var(--transition);
}

.list-item:hover {
    box-shadow: var(--shadow-lg);
    transform: translateY(-1px);
}

.list-icon {
    width: 48px;
    height: 48px;
    border-radius: var(--radius-sm);
    background: var(--primary-light);
    color: var(--primary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.25rem;
    flex-shrink: 0;
}

.list-content {
    flex: 1;
    min-width: 0;
}

.list-title {
    font-weight: 600;
    color: var(--dark);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.list-subtitle {
    font-size: 0.85rem;
    color: var(--gray-500);
    margin-top: 2px;
}

.list-meta {
    text-align: right;
    flex-shrink: 0;
}

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

/* ===== BADGES ===== */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 600;
}

.badge-success {
    background: #d4edda;
    color: #155724;
}

.badge-warning {
    background: #fff3cd;
    color: #856404;
}

.badge-danger {
    background: #f8d7da;
    color: #721c24;
}

.badge-info {
    background: var(--primary-light);
    color: var(--primary);
}

/* ===== QR SCANNER ===== */
.qr-scanner-container {
    position: relative;
    width: 100%;
    max-width: 400px;
    margin: 0 auto;
    border-radius: var(--radius);
    overflow: hidden;
}

.qr-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    pointer-events: none;
}

.qr-frame {
    width: 200px;
    height: 200px;
    border: 3px solid var(--secondary);
    border-radius: 16px;
    position: relative;
}

.qr-frame::before,
.qr-frame::after {
    content: '';
    position: absolute;
    width: 20px;
    height: 20px;
    border: 3px solid var(--secondary);
}

.qr-frame::before {
    top: -3px;
    left: -3px;
    border-right: none;
    border-bottom: none;
}

.qr-frame::after {
    bottom: -3px;
    right: -3px;
    border-left: none;
    border-top: none;
}

/* ===== TICKET DISPLAY ===== */
.ticket-card {
    background: var(--white);
    border-radius: var(--radius);
    overflow: hidden;
    box-shadow: var(--shadow-lg);
    margin-bottom: 20px;
}

.ticket-header {
    background: var(--primary);
    color: var(--white);
    padding: 20px;
    text-align: center;
}

.ticket-header h3 {
    font-size: 1.1rem;
    margin-bottom: 4px;
}

.ticket-number {
    font-family: 'Courier New', monospace;
    font-size: 0.9rem;
    opacity: 0.9;
}

.ticket-body {
    padding: 20px;
}

.ticket-row {
    display: flex;
    justify-content: space-between;
    padding: 10px 0;
    border-bottom: 1px dashed var(--gray-200);
}

.ticket-row:last-child {
    border-bottom: none;
}

.ticket-label {
    color: var(--gray-500);
    font-size: 0.85rem;
}

.ticket-value {
    font-weight: 600;
    color: var(--dark);
}

.ticket-qr {
    text-align: center;
    padding: 20px;
    background: var(--gray-100);
}

.ticket-qr img {
    max-width: 200px;
    border-radius: var(--radius-sm);
}

.ticket-validation-code {
    margin-top: 12px;
    font-family: 'Courier New', monospace;
    font-size: 1.25rem;
    font-weight: 700;
    letter-spacing: 4px;
    color: var(--primary);
}

/* ===== QR COUNTER DISPLAY ===== */
.qr-counter-display {
    text-align: center;
    padding: 40px 20px;
    background: var(--white);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

.qr-counter-code {
    margin: 20px auto;
    padding: 20px;
    background: var(--white);
    border-radius: var(--radius);
    max-width: 300px;
}

.qr-counter-code img {
    width: 100%;
    max-width: 250px;
}

/* ===== SCANNER PAGE ===== */
.scanner-page {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 20px;
}

.manual-entry {
    width: 100%;
    max-width: 400px;
    margin-top: 20px;
}

/* ===== PRINT STYLES ===== */
@media print {
    .no-print,
    .app-header,
    .bottom-nav,
    .sidebar {
        display: none !important;
    }
    
    body {
        background: white;
    }
    
    .ticket-card {
        box-shadow: none;
        border: 1px solid #ddd;
    }
    
    .main-content {
        padding-bottom: 0;
    }
}

/* ===== ANIMATIONS ===== */
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes pulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.05); }
}

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

.animate-fadeIn {
    animation: fadeIn 0.3s ease;
}

.animate-pulse {
    animation: pulse 2s infinite;
}

/* ===== LOADING STATES ===== */
.skeleton {
    background: linear-gradient(90deg, var(--gray-200) 25%, var(--gray-100) 50%, var(--gray-200) 75%);
    background-size: 200% 100%;
    animation: skeleton-loading 1.5s infinite;
    border-radius: var(--radius-sm);
}

@keyframes skeleton-loading {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

.spinner {
    width: 24px;
    height: 24px;
    border: 3px solid var(--gray-200);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

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

/* ===== OFFLINE INDICATOR ===== */
.offline-bar {
    background: var(--warning);
    color: var(--dark);
    text-align: center;
    padding: 8px;
    font-size: 0.85rem;
    font-weight: 500;
    position: sticky;
    top: 56px;
    z-index: 99;
}

/* ===== TOAST NOTIFICATIONS ===== */
.toast-container {
    position: fixed;
    bottom: 80px;
    left: 16px;
    right: 16px;
    z-index: 1000;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.toast {
    padding: 12px 16px;
    border-radius: var(--radius-sm);
    color: var(--white);
    font-size: 0.9rem;
    font-weight: 500;
    animation: slideUp 0.3s ease;
    box-shadow: var(--shadow-lg);
}

.toast-success { background: var(--secondary); }
.toast-error { background: var(--danger); }
.toast-warning { background: var(--warning); color: var(--dark); }

/* ===== MODAL ===== */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.5);
    display: flex;
    align-items: flex-end;
    justify-content: center;
    z-index: 500;
    opacity: 0;
    visibility: hidden;
    transition: var(--transition);
}

.modal-overlay.active {
    opacity: 1;
    visibility: visible;
}

.modal-content {
    background: var(--white);
    border-radius: var(--radius) var(--radius) 0 0;
    width: 100%;
    max-width: 600px;
    max-height: 90vh;
    overflow-y: auto;
    padding: 20px;
    transform: translateY(100%);
    transition: transform 0.3s ease;
}

.modal-overlay.active .modal-content {
    transform: translateY(0);
}

/* ===== EMPTY STATE ===== */
.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: var(--gray-500);
}

.empty-state i {
    font-size: 4rem;
    margin-bottom: 16px;
    color: var(--gray-300);
}

.empty-state h3 {
    font-size: 1.1rem;
    margin-bottom: 8px;
    color: var(--dark);
}

/* ===== PASSENGER FORM ===== */
.passenger-form {
    background: var(--white);
    border-radius: var(--radius);
    padding: 20px;
    margin-bottom: 16px;
}

/* ===== PAYMENT METHODS ===== */
.payment-methods {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
    margin-bottom: 20px;
}

.payment-method {
    border: 2px solid var(--gray-200);
    border-radius: var(--radius-sm);
    padding: 16px;
    text-align: center;
    cursor: pointer;
    transition: var(--transition);
}

.payment-method:hover,
.payment-method.active {
    border-color: var(--primary);
    background: var(--primary-light);
}

.payment-method i {
    font-size: 2rem;
    margin-bottom: 8px;
    display: block;
    color: var(--primary);
}

.payment-method-title {
    font-size: 0.85rem;
    font-weight: 600;
}

/* ===== DESKTOP LAYOUT ===== */
@media (min-width: 768px) {
    .bottom-nav {
        display: none;
    }
    
    .sidebar {
        display: block;
    }
    
    .main-content {
        margin-left: 260px;
        padding-bottom: 20px;
    }
    
    .app-header {
        left: 260px;
    }
    
    .stats-grid {
        grid-template-columns: repeat(4, 1fr);
    }
    
    .payment-methods {
        grid-template-columns: repeat(4, 1fr);
    }
    
    .seat {
        width: 56px;
        height: 56px;
        font-size: 0.9rem;
    }
    
    .modal-overlay {
        align-items: center;
    }
    
    .modal-content {
        border-radius: var(--radius);
        transform: translateY(20px);
    }
    
    .filters-row {
        flex-wrap: wrap;
    }
}

/* ===== DARK MODE SUPPORT ===== */
@media (prefers-color-scheme: dark) {
    :root {
        --gray-100: #1a1a2e;
        --gray-200: #2d2d44;
        --gray-300: #3d3d5c;
        --white: #16213e;
        --dark: #e0e0e0;
    }
}

/* ===== REDUCED MOTION ===== */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        transition-duration: 0.01ms !important;
    }
}
