/**
 * Offloaded Passenger Information System v3.0
 * Mobile-First Executive Design
 */

:root {
    --primary: #1a4d7a;
    --primary-dark: #0f3556;
    --primary-light: #2567a0;
    --secondary: #d97706;
    --secondary-dark: #b45309;
    --gray-50: #f9fafb; --gray-100: #f3f4f6; --gray-200: #e5e7eb;
    --gray-300: #d1d5db; --gray-400: #9ca3af; --gray-500: #6b7280;
    --gray-600: #4b5563; --gray-700: #374151; --gray-800: #1f2937; --gray-900: #111827;
    --success: #059669; --warning: #d97706; --danger: #dc2626; --info: #0891b2;
    --font-body: 'Segoe UI', 'Roboto', -apple-system, BlinkMacSystemFont, sans-serif;
    --font-mono: 'Consolas', 'Monaco', 'Courier New', monospace;
    --shadow-sm: 0 1px 2px 0 rgba(0,0,0,0.05);
    --shadow-md: 0 4px 6px -1px rgba(0,0,0,0.1);
    --shadow-lg: 0 10px 15px -3px rgba(0,0,0,0.1);
    --shadow-xl: 0 20px 25px -5px rgba(0,0,0,0.1);
    --radius-sm: 0.25rem; --radius-md: 0.375rem; --radius-lg: 0.5rem;
}

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

body {
    font-family: var(--font-body);
    font-size: 14px; line-height: 1.5;
    color: var(--gray-800);
    background: var(--gray-50);
    -webkit-font-smoothing: antialiased;
    overflow-x: hidden;
}

/* ===== LOGIN PAGE ===== */
.login-page {
    display: flex; align-items: center; justify-content: center;
    min-height: 100vh; padding: 1rem;
    background: linear-gradient(135deg, var(--primary-dark) 0%, var(--primary) 50%, var(--primary-light) 100%);
}
.login-page::before {
    content: ''; position: absolute; top: 0; left: 0; right: 0; bottom: 0;
    background-image: 
        radial-gradient(circle at 20% 50%, rgba(255,255,255,0.05) 0%, transparent 50%),
        radial-gradient(circle at 80% 80%, rgba(255,255,255,0.05) 0%, transparent 50%);
    pointer-events: none;
}
.login-container {
    background: white; border-radius: var(--radius-lg); box-shadow: var(--shadow-xl);
    padding: 2rem; width: 100%; max-width: 420px; position: relative; z-index: 1;
}
.login-header { text-align: center; margin-bottom: 2rem; }
.login-logo {
    width: 70px; height: 70px; border-radius: 50%;
    margin-bottom: 1rem; object-fit: cover;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
}
.login-header h1 { font-size: 18px; font-weight: 600; color: var(--gray-900); margin-bottom: 0.25rem; }
.subtitle { color: var(--gray-500); font-size: 13px; }
.login-form { margin-bottom: 1.5rem; }
.login-footer {
    text-align: center; color: var(--gray-400);
    padding-top: 1.5rem; border-top: 1px solid var(--gray-200);
}
.login-signature { margin-top: 0.75rem; font-size: 12px; color: var(--gray-400); letter-spacing: 0.3px; }
.login-signature strong { color: var(--primary); font-weight: 600; }

/* ===== MAIN LAYOUT ===== */
.app-container { display: flex; min-height: 100vh; }

/* ===== SIDEBAR ===== */
.sidebar {
    width: 240px; background: var(--gray-900); color: white;
    display: flex; flex-direction: column;
    position: fixed; height: 100vh; overflow-y: auto; z-index: 100;
    transition: transform 0.3s ease;
}
.sidebar-header { padding: 1.25rem 1rem; border-bottom: 1px solid rgba(255,255,255,0.1); text-align: center; }
.sidebar-logo-img {
    width: 45px; height: 45px; border-radius: 50%;
    margin-bottom: 0.5rem; object-fit: cover;
    border: 2px solid rgba(255,255,255,0.2);
}
.sidebar-logo { font-size: 15px; font-weight: 700; letter-spacing: 0.5px; color: white; }
.sidebar-subtitle { font-size: 11px; color: var(--gray-400); margin-top: 0.15rem; }
.sidebar-nav { flex: 1; padding: 0.75rem; }
.nav-item {
    display: flex; align-items: center;
    padding: 0.6rem 1rem; color: var(--gray-300); text-decoration: none;
    border-radius: var(--radius-md); margin-bottom: 0.15rem;
    transition: all 0.2s; font-size: 13px;
}
.nav-item:hover { background: rgba(255,255,255,0.1); color: white; }
.nav-item.active { background: var(--primary); color: white; font-weight: 500; }
.nav-icon { margin-right: 0.5rem; font-size: 16px; }
.sidebar-footer { padding: 1rem; border-top: 1px solid rgba(255,255,255,0.1); }
.user-info { display: flex; align-items: center; margin-bottom: 0.75rem; }
.user-avatar {
    width: 32px; height: 32px; border-radius: 50%; background: var(--primary);
    display: flex; align-items: center; justify-content: center;
    font-weight: 600; margin-right: 0.5rem; font-size: 13px; flex-shrink: 0;
}
.user-details { flex: 1; min-width: 0; }
.user-name { font-size: 12px; font-weight: 500; color: white; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-role { font-size: 10px; color: var(--gray-400); text-transform: capitalize; }
.sidebar-version { text-align: center; font-size: 10px; color: var(--gray-500); margin-top: 0.5rem; }

/* Sidebar overlay for mobile */
.sidebar-overlay {
    display: none; position: fixed; top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.5); z-index: 99;
}
.sidebar-overlay.active { display: block; }

/* ===== MAIN CONTENT ===== */
.main-content { flex: 1; margin-left: 240px; padding: 1.5rem; min-width: 0; }
.page-header { margin-bottom: 1.5rem; }
.page-title { font-size: 22px; font-weight: 600; color: var(--gray-900); margin-bottom: 0.15rem; }
.page-subtitle { color: var(--gray-500); font-size: 13px; }

/* ===== DASHBOARD HEADER ===== */
.dashboard-header {
    display: flex; justify-content: space-between; align-items: center;
    margin-bottom: 1.5rem; padding-bottom: 1.25rem;
    border-bottom: 2px solid var(--gray-200);
}
.dashboard-header-left { display: flex; align-items: center; gap: 1rem; }
.dashboard-logo {
    width: 48px; height: 48px; border-radius: 50%; object-fit: cover;
    box-shadow: var(--shadow-md); border: 2px solid var(--gray-200);
}
.dashboard-header-right { text-align: right; }
.header-badge {
    display: inline-block; background: var(--primary); color: white;
    padding: 0.3rem 0.75rem; border-radius: 20px;
    font-size: 11px; font-weight: 500; letter-spacing: 0.3px;
}

/* ===== FILTER BAR ===== */
.filter-bar {
    background: white; border-radius: var(--radius-lg);
    padding: 1.25rem; margin-bottom: 1.25rem;
    box-shadow: var(--shadow-sm);
    display: flex; gap: 0.75rem; flex-wrap: wrap; align-items: end;
}
.filter-group { flex: 1; min-width: 140px; }
.filter-buttons { min-width: 100px; flex: 0 0 auto; }

/* ===== KPI STRIP ===== */
.kpi-strip {
    display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 0.75rem; margin-bottom: 1.25rem;
}
.kpi-card {
    background: white; border-radius: var(--radius-lg);
    padding: 1.25rem; box-shadow: var(--shadow-sm);
    border-left: 4px solid var(--primary);
}
.kpi-card.warning { border-left-color: var(--warning); }
.kpi-card.success { border-left-color: var(--success); }
.kpi-card.danger { border-left-color: var(--danger); }
.kpi-label { font-size: 10px; text-transform: uppercase; letter-spacing: 0.5px; color: var(--gray-500); margin-bottom: 0.15rem; font-weight: 600; }
.kpi-value { font-size: 24px; font-weight: 700; color: var(--gray-900); line-height: 1; margin-bottom: 0.15rem; }
.kpi-trend { font-size: 12px; color: var(--gray-600); }
.kpi-trend.positive { color: var(--success); }
.kpi-trend.negative { color: var(--danger); }

/* ===== INSIGHT BOX ===== */
.insight-box {
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    color: white; border-radius: var(--radius-lg);
    padding: 1.25rem; margin-bottom: 1.25rem; box-shadow: var(--shadow-md);
}
.insight-icon { font-size: 22px; margin-bottom: 0.25rem; opacity: 0.9; }
.insight-title { font-size: 12px; text-transform: uppercase; letter-spacing: 0.5px; margin-bottom: 0.25rem; opacity: 0.9; }
.insight-content { font-size: 14px; line-height: 1.5; }

/* ===== CHARTS ===== */
.charts-grid {
    display: grid; grid-template-columns: repeat(auto-fit, minmax(350px, 1fr));
    gap: 1.25rem; margin-bottom: 1.25rem;
}
.chart-card {
    background: white; border-radius: var(--radius-lg);
    padding: 1.25rem; box-shadow: var(--shadow-sm); margin-bottom: 1.25rem;
}
.chart-header { margin-bottom: 1rem; }
.chart-title { font-size: 14px; font-weight: 600; color: var(--gray-900); margin-bottom: 0.15rem; }
.chart-subtitle { font-size: 11px; color: var(--gray-500); }
.chart-canvas { height: 280px; }

/* ===== TABLES ===== */
.table-card {
    background: white; border-radius: var(--radius-lg);
    padding: 1.25rem; box-shadow: var(--shadow-sm); margin-bottom: 1.25rem; overflow: hidden;
}
.table-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 1.25rem; flex-wrap: wrap; gap: 0.5rem; }
.table-title { font-size: 15px; font-weight: 600; color: var(--gray-900); }
.table-container { overflow-x: auto; -webkit-overflow-scrolling: touch; }

table { width: 100%; border-collapse: collapse; font-size: 13px; }
thead { background: var(--gray-50); }
th {
    text-align: left; padding: 0.5rem 0.75rem; font-weight: 600; color: var(--gray-700);
    border-bottom: 2px solid var(--gray-200); font-size: 11px;
    text-transform: uppercase; letter-spacing: 0.5px; white-space: nowrap;
}
td { padding: 0.5rem 0.75rem; border-bottom: 1px solid var(--gray-200); color: var(--gray-700); }
tr:hover td { background: var(--gray-50); }
.row-disabled td { opacity: 0.5; }

/* Results bar */
.results-bar { display: flex; justify-content: space-between; align-items: center; margin-bottom: 1rem; gap: 0.75rem; flex-wrap: wrap; }
.export-buttons { display: flex; gap: 0.5rem; flex-shrink: 0; }

/* Pagination */
.pagination { display: flex; justify-content: center; gap: 0.35rem; margin-top: 1.25rem; flex-wrap: wrap; }

/* Cell helpers */
.nowrap { white-space: nowrap; }
.mono-sm { font-family: var(--font-mono); font-size: 12px; }
.text-sm { font-size: 12px; }
.actions-cell { white-space: nowrap; display: flex; gap: 0.25rem; }

/* ===== FORMS ===== */
.form-group { margin-bottom: 1.25rem; }
label { display: block; font-size: 13px; font-weight: 500; color: var(--gray-700); margin-bottom: 0.25rem; }
input, select, textarea {
    width: 100%; padding: 0.5rem 0.75rem;
    border: 1px solid var(--gray-300); border-radius: var(--radius-md);
    font-size: 14px; font-family: var(--font-body); color: var(--gray-800); transition: all 0.2s;
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(26,77,122,0.1); }
input:disabled, select:disabled { background: var(--gray-100); cursor: not-allowed; }
textarea { resize: vertical; min-height: 80px; }

/* Form grid layouts */
.form-grid-2 { display: grid; grid-template-columns: repeat(2, 1fr); gap: 1rem; margin-bottom: 1rem; }
.form-grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1rem; margin-bottom: 1rem; }
.form-grid-responsive { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 1rem; margin-bottom: 1rem; }
.form-actions { display: flex; gap: 0.75rem; justify-content: flex-end; padding-top: 1.25rem; border-top: 2px solid var(--gray-200); margin-top: 1.5rem; }

/* ===== BUTTONS ===== */
.btn {
    display: inline-flex; align-items: center; justify-content: center;
    padding: 0.5rem 1.25rem; border: none;
    border-radius: var(--radius-md); font-size: 14px; font-weight: 500;
    cursor: pointer; transition: all 0.2s; text-decoration: none; text-align: center;
    white-space: nowrap;
}
.btn-primary { background: var(--primary); color: white; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-secondary { background: var(--gray-200); color: var(--gray-700); }
.btn-secondary:hover { background: var(--gray-300); }
.btn-danger { background: var(--danger); color: white; }
.btn-danger:hover { background: #b91c1c; }
.btn-warning { background: var(--warning); color: white; }
.btn-warning:hover { background: var(--secondary-dark); }
.btn-sm { padding: 0.25rem 0.5rem; font-size: 12px; }
.btn-block { width: 100%; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* ===== ALERTS ===== */
.alert { padding: 0.75rem 1rem; border-radius: var(--radius-md); margin-bottom: 1rem; font-size: 13px; }
.alert-success { background: #d1fae5; color: #065f46; border-left: 4px solid var(--success); }
.alert-error { background: #fee2e2; color: #991b1b; border-left: 4px solid var(--danger); }
.alert-info { background: #dbeafe; color: #1e40af; border-left: 4px solid var(--info); }

/* ===== BADGES ===== */
.badge {
    display: inline-block; padding: 0.2rem 0.5rem; border-radius: var(--radius-sm);
    font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.5px;
}
.badge-primary { background: #dbeafe; color: var(--primary); }
.badge-success { background: #d1fae5; color: var(--success); }
.badge-warning { background: #fed7aa; color: var(--secondary-dark); }
.badge-danger { background: #fee2e2; color: var(--danger); }
.badge-role-admin { background: #fef3c7; color: #92400e; }
.badge-role-supervisor { background: #dbeafe; color: #1e40af; }
.badge-role-manager { background: #e0e7ff; color: #3730a3; }
.badge-role-gate_agent { background: #d1fae5; color: #065f46; }

/* ===== PASSPORT INPUT ===== */
.passport-input { text-transform: uppercase; font-family: var(--font-mono); letter-spacing: 1px; }

/* ===== PASSENGER CARD ===== */
.passenger-card {
    background: var(--gray-50); border: 2px solid var(--gray-200);
    border-radius: 8px; padding: 1.25rem; margin-bottom: 0.75rem;
}
.passenger-card-header {
    display: flex; justify-content: space-between; align-items: center;
    margin-bottom: 1rem; padding-bottom: 0.5rem; border-bottom: 1px solid var(--gray-300);
}
.passenger-number { font-weight: 600; color: var(--primary); font-size: 14px; }
.remove-passenger-btn {
    background: var(--danger); color: white; border: none;
    padding: 0.25rem 0.75rem; border-radius: 4px; cursor: pointer; font-size: 12px;
}
.remove-passenger-btn:hover { background: #b91c1c; }
.add-passenger-section {
    text-align: center; padding: 1.5rem; background: var(--gray-100);
    border: 2px dashed var(--gray-300); border-radius: 8px; margin-top: 1rem;
}

/* ===== MODALS ===== */
.modal-overlay {
    position: fixed; top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.5); z-index: 1000;
    display: flex; align-items: center; justify-content: center;
    padding: 1rem;
}
.modal-content {
    background: white; border-radius: var(--radius-lg); box-shadow: var(--shadow-xl);
    padding: 1.5rem; max-width: 600px; width: 100%;
    max-height: 90vh; overflow-y: auto;
}
.modal-header {
    display: flex; justify-content: space-between; align-items: center;
    margin-bottom: 1.5rem; padding-bottom: 0.75rem; border-bottom: 2px solid var(--gray-200);
}
.modal-header h3 { font-size: 18px; font-weight: 600; color: var(--gray-900); }
.modal-close {
    background: none; border: none; font-size: 24px; cursor: pointer;
    color: var(--gray-400); padding: 0.25rem; line-height: 1;
}
.modal-close:hover { color: var(--gray-700); }

/* ===== ARABIC ===== */
.arabic {
    font-family: 'Traditional Arabic', 'Arabic Typesetting', 'Geeza Pro', Arial, sans-serif;
    direction: rtl; text-align: right; font-size: 14px; line-height: 1.8;
}

/* ===== MOBILE MENU TOGGLE ===== */
.mobile-menu-btn {
    display: none; position: fixed; top: 0.75rem; left: 0.75rem; z-index: 200;
    background: var(--primary); color: white; border: none;
    width: 40px; height: 40px; border-radius: 50%;
    font-size: 20px; cursor: pointer; box-shadow: var(--shadow-md);
    align-items: center; justify-content: center; line-height: 1;
}

/* ===== RESPONSIVE - TABLET ===== */
@media (max-width: 1024px) {
    .sidebar { transform: translateX(-100%); }
    .sidebar.open { transform: translateX(0); }
    .main-content { margin-left: 0; padding-top: 3.5rem; }
    .mobile-menu-btn { display: flex; }
    .charts-grid { grid-template-columns: 1fr; }
    .dashboard-header { flex-direction: column; gap: 0.75rem; text-align: center; }
    .dashboard-header-left { flex-direction: column; align-items: center; }
    .form-grid-3 { grid-template-columns: repeat(2, 1fr); }
}

/* ===== RESPONSIVE - MOBILE ===== */
@media (max-width: 768px) {
    .main-content { padding: 0.75rem; padding-top: 3.5rem; }
    .page-title { font-size: 18px; }
    
    .kpi-strip { grid-template-columns: repeat(2, 1fr); }
    .filter-bar { flex-direction: column; padding: 1rem; }
    .filter-group { width: 100%; min-width: unset; }
    .filter-buttons { width: 100%; }
    
    .form-grid-2 { grid-template-columns: 1fr; }
    .form-grid-3 { grid-template-columns: 1fr; }
    .form-grid-responsive { grid-template-columns: 1fr; }
    
    .results-bar { flex-direction: column; align-items: stretch; }
    .export-buttons { justify-content: center; }
    
    .table-card { padding: 0.75rem; }
    th, td { padding: 0.4rem 0.5rem; font-size: 12px; }
    
    .passenger-card { padding: 1rem; }
    .form-actions { flex-direction: column; }
    .form-actions .btn { width: 100%; }
    
    .modal-content { padding: 1.25rem; margin: 0.5rem; }
    
    .chart-canvas { height: 220px; }
    
    .actions-cell { flex-direction: column; gap: 0.2rem; }
    
    .login-container { padding: 1.5rem; }
    .login-header h1 { font-size: 16px; }
}

/* ===== RESPONSIVE - SMALL MOBILE ===== */
@media (max-width: 480px) {
    .kpi-strip { grid-template-columns: 1fr; }
    .kpi-card { padding: 1rem; }
    .kpi-value { font-size: 20px; }
    .pagination { gap: 0.2rem; }
    .btn-sm { padding: 0.2rem 0.4rem; font-size: 11px; }
}

/* ===== PRINT ===== */
@media print {
    .sidebar, .mobile-menu-btn, .sidebar-overlay, .filter-bar, .btn, .form-actions { display: none !important; }
    .main-content { margin-left: 0; padding: 0; }
}
