/* ═══════════════════════════════════════════════════════
   CrewAssist Portal — Professional Aviation Theme
   ═══════════════════════════════════════════════════════ */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap');

:root {
    --bg-primary: #0a0e1a;
    --bg-secondary: #111827;
    --bg-card: #1a1f35;
    --bg-card-hover: #222845;
    --bg-input: #151b2e;
    --border-color: #2a3154;
    --border-light: #1e2544;
    --text-primary: #e8eaf0;
    --text-secondary: #8b95b0;
    --text-tertiary: #5a6480;
    --accent-blue: #3b82f6;
    --accent-blue-hover: #2563eb;
    --accent-cyan: #06b6d4;
    --accent-green: #10b981;
    --accent-yellow: #f59e0b;
    --accent-red: #ef4444;
    --accent-purple: #8b5cf6;
    --sidebar-width: 260px;
    --header-height: 64px;
    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 14px;
    --shadow-card: 0 4px 24px rgba(0,0,0,0.3);
    --shadow-lg: 0 8px 40px rgba(0,0,0,0.4);
    --transition: all 0.2s ease;
}

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

body {
    font-family: 'Inter', -apple-system, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
}

a { color: var(--accent-blue); text-decoration: none; }
a:hover { color: var(--accent-blue-hover); }

/* ─── Layout ─────────────────────────────────────────── */
.app-layout {
    display: flex;
    min-height: 100vh;
}

.sidebar {
    width: var(--sidebar-width);
    background: var(--bg-secondary);
    border-right: 1px solid var(--border-color);
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    overflow: hidden;
    z-index: 100;
    display: flex;
    flex-direction: column;
}

.sidebar-brand {
    padding: 20px 24px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    gap: 12px;
}

.sidebar-brand-icon {
    width: 40px;
    height: 40px;
    background: linear-gradient(135deg, var(--accent-blue), var(--accent-cyan));
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
}

.sidebar-brand h1 {
    font-size: 18px;
    font-weight: 700;
    letter-spacing: -0.02em;
    background: linear-gradient(135deg, var(--text-primary), var(--accent-cyan));
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

.sidebar-brand small {
    font-size: 11px;
    color: var(--text-tertiary);
    display: block;
    margin-top: 2px;
    -webkit-text-fill-color: var(--text-tertiary);
}

.sidebar-nav {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    padding: 16px 12px;
    display: flex;
    flex-direction: column;
}

.sidebar-section {
    margin-bottom: 8px;
}

.sidebar-section-title {
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-tertiary);
    padding: 8px 12px 6px;
}

.sidebar-link {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    font-size: 13.5px;
    font-weight: 500;
    transition: var(--transition);
    margin-bottom: 2px;
}

.sidebar-link:hover {
    background: var(--bg-card);
    color: var(--text-primary);
}

.sidebar-link.active {
    background: linear-gradient(135deg, rgba(59,130,246,0.15), rgba(6,182,212,0.1));
    color: var(--accent-blue);
    border: 1px solid rgba(59,130,246,0.2);
}

.sidebar-link .icon { font-size: 16px; width: 20px; text-align: center; }

.sidebar-link .badge {
    margin-left: auto;
    background: var(--accent-red);
    color: #fff;
    font-size: 10px;
    font-weight: 700;
    padding: 2px 7px;
    border-radius: 10px;
    min-width: 18px;
    text-align: center;
}

.sidebar-footer {
    padding: 16px;
    border-top: 1px solid var(--border-color);
}

.sidebar-user {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px;
    border-radius: var(--radius-sm);
}

.sidebar-user-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--accent-blue), var(--accent-purple));
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    font-weight: 600;
    color: #fff;
    flex-shrink: 0;
}

.sidebar-user-info {
    flex: 1;
    min-width: 0;
}

.sidebar-user-name {
    font-size: 13px;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.sidebar-user-role {
    font-size: 11px;
    color: var(--text-tertiary);
}

/* ─── Main Content ────────────────────────────────────── */
.main-content {
    margin-left: var(--sidebar-width);
    flex: 1;
    min-height: 100vh;
}

.content-header {
    padding: 24px 32px;
    border-bottom: 1px solid var(--border-color);
    background: var(--bg-secondary);
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: sticky;
    top: 0;
    z-index: 50;
}

.content-header h2 {
    font-size: 22px;
    font-weight: 700;
    letter-spacing: -0.02em;
}

.content-header p {
    font-size: 13px;
    color: var(--text-secondary);
    margin-top: 2px;
}

.content-body {
    padding: 32px;
}

/* ─── Cards ───────────────────────────────────────────── */
.card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 24px;
    box-shadow: var(--shadow-card);
    transition: var(--transition);
}

.card:hover {
    border-color: rgba(59,130,246,0.2);
}

.card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 20px;
    padding-bottom: 16px;
    border-bottom: 1px solid var(--border-light);
}

.card-title {
    font-size: 16px;
    font-weight: 600;
}

/* ─── Stat Cards ──────────────────────────────────────── */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 20px;
    margin-bottom: 28px;
}

.stat-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 24px;
    position: relative;
    overflow: hidden;
}

.stat-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: var(--stat-color, var(--accent-blue));
}

.stat-label {
    font-size: 12px;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-secondary);
    margin-bottom: 8px;
}

.stat-value {
    font-size: 32px;
    font-weight: 700;
    letter-spacing: -0.03em;
    color: var(--text-primary);
}

.stat-card.blue { --stat-color: var(--accent-blue); }
.stat-card.green { --stat-color: var(--accent-green); }
.stat-card.yellow { --stat-color: var(--accent-yellow); }
.stat-card.red { --stat-color: var(--accent-red); }
.stat-card.purple { --stat-color: var(--accent-purple); }
.stat-card.cyan { --stat-color: var(--accent-cyan); }

/* ─── Tables ──────────────────────────────────────────── */
.table-wrap {
    overflow-x: auto;
    border-radius: var(--radius-md);
    border: 1px solid var(--border-color);
}

table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13.5px;
}

thead {
    background: var(--bg-secondary);
}

th {
    padding: 12px 16px;
    text-align: left;
    font-weight: 600;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-secondary);
    border-bottom: 1px solid var(--border-color);
    white-space: nowrap;
}

td {
    padding: 14px 16px;
    border-bottom: 1px solid var(--border-light);
    color: var(--text-primary);
}

tr:hover td {
    background: var(--bg-card-hover);
}

tr:last-child td { border-bottom: none; }

/* ─── Status Badges ───────────────────────────────────── */
.status-badge {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
    background: color-mix(in srgb, var(--badge-color, #6b7280) 15%, transparent);
    color: var(--badge-color, #6b7280);
    border: 1px solid color-mix(in srgb, var(--badge-color, #6b7280) 25%, transparent);
}

.status-badge::before {
    content: '';
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--badge-color, #6b7280);
}

/* ─── Buttons ─────────────────────────────────────────── */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 20px;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 13.5px;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    font-family: inherit;
    text-decoration: none;
}

.btn-primary {
    background: linear-gradient(135deg, var(--accent-blue), var(--accent-blue-hover));
    color: #fff;
    box-shadow: 0 2px 8px rgba(59,130,246,0.3);
}
.btn-primary:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 16px rgba(59,130,246,0.4);
    color: #fff;
}

.btn-success {
    background: linear-gradient(135deg, var(--accent-green), #059669);
    color: #fff;
}
.btn-success:hover { transform: translateY(-1px); color: #fff; }

.btn-danger {
    background: linear-gradient(135deg, var(--accent-red), #dc2626);
    color: #fff;
}
.btn-danger:hover { transform: translateY(-1px); color: #fff; }

.btn-warning {
    background: linear-gradient(135deg, var(--accent-yellow), #d97706);
    color: #000;
}

.btn-outline {
    background: transparent;
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
}
.btn-outline:hover {
    background: var(--bg-card);
    color: var(--text-primary);
    border-color: var(--accent-blue);
}

.btn-sm {
    padding: 6px 14px;
    font-size: 12px;
}

.btn-xs {
    padding: 4px 10px;
    font-size: 11px;
}

.btn-group {
    display: inline-flex;
    gap: 6px;
}

/* ─── Forms ───────────────────────────────────────────── */
.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 6px;
}

.form-control {
    width: 100%;
    padding: 10px 14px;
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-size: 14px;
    font-family: inherit;
    transition: var(--transition);
}

.form-control:focus {
    outline: none;
    border-color: var(--accent-blue);
    box-shadow: 0 0 0 3px rgba(59,130,246,0.15);
}

select.form-control {
    appearance: none;
    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='%238b95b0' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    padding-right: 36px;
}

textarea.form-control {
    min-height: 100px;
    resize: vertical;
}

.form-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 20px;
}

.form-check {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
}

.form-check input[type="checkbox"] {
    width: 18px;
    height: 18px;
    accent-color: var(--accent-blue);
}

.checkbox-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 8px;
}

/* ─── Alerts ──────────────────────────────────────────── */
.alert {
    padding: 14px 18px;
    border-radius: var(--radius-sm);
    font-size: 14px;
    margin-bottom: 20px;
    display: flex;
    align-items: center;
    gap: 10px;
    animation: slideIn 0.3s ease;
}

.alert-success {
    background: rgba(16,185,129,0.1);
    border: 1px solid rgba(16,185,129,0.25);
    color: var(--accent-green);
}

.alert-error {
    background: rgba(239,68,68,0.1);
    border: 1px solid rgba(239,68,68,0.25);
    color: var(--accent-red);
}

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

/* ─── Login Page ──────────────────────────────────────── */
.login-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-primary);
    position: relative;
    overflow: hidden;
}

.login-page::before {
    content: '';
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: radial-gradient(ellipse at 30% 20%, rgba(59,130,246,0.08) 0%, transparent 50%),
                radial-gradient(ellipse at 70% 80%, rgba(6,182,212,0.06) 0%, transparent 50%);
    animation: bgPulse 15s ease-in-out infinite;
}

@keyframes bgPulse {
    0%, 100% { transform: translate(0, 0); }
    50% { transform: translate(-20px, -10px); }
}

.login-card {
    width: 100%;
    max-width: 420px;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 40px;
    box-shadow: var(--shadow-lg);
    position: relative;
    z-index: 1;
}

.login-logo {
    text-align: center;
    margin-bottom: 32px;
}

.login-logo-icon {
    width: 64px;
    height: 64px;
    margin: 0 auto 16px;
    background: linear-gradient(135deg, var(--accent-blue), var(--accent-cyan));
    border-radius: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 28px;
}

.login-logo h1 {
    font-size: 26px;
    font-weight: 700;
    letter-spacing: -0.02em;
}

.login-logo p {
    font-size: 13px;
    color: var(--text-secondary);
    margin-top: 4px;
}

.login-btn {
    width: 100%;
    padding: 14px;
    font-size: 15px;
}

/* ─── Empty States ────────────────────────────────────── */
.empty-state {
    text-align: center;
    padding: 48px 24px;
    color: var(--text-secondary);
}

.empty-state .icon {
    font-size: 48px;
    margin-bottom: 16px;
    opacity: 0.3;
}

.empty-state h3 {
    font-size: 18px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 8px;
}

.empty-state p {
    font-size: 14px;
    max-width: 400px;
    margin: 0 auto;
}

/* ─── Activity Feed ───────────────────────────────────── */
.activity-list { list-style: none; }

.activity-item {
    display: flex;
    gap: 12px;
    padding: 12px 0;
    border-bottom: 1px solid var(--border-light);
    font-size: 13px;
}

.activity-item:last-child { border-bottom: none; }

.activity-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--accent-blue);
    margin-top: 6px;
    flex-shrink: 0;
}

.activity-time {
    color: var(--text-tertiary);
    font-size: 11px;
    margin-top: 2px;
}

/* ─── Filter Tabs ─────────────────────────────────────── */
.filter-tabs {
    display: flex;
    gap: 4px;
    margin-bottom: 20px;
    flex-wrap: wrap;
}

.filter-tab {
    padding: 8px 16px;
    border-radius: var(--radius-sm);
    font-size: 13px;
    font-weight: 500;
    color: var(--text-secondary);
    background: transparent;
    border: 1px solid var(--border-color);
    cursor: pointer;
    transition: var(--transition);
    text-decoration: none;
}

.filter-tab:hover, .filter-tab.active {
    background: rgba(59,130,246,0.1);
    color: var(--accent-blue);
    border-color: rgba(59,130,246,0.3);
}

/* ─── Utility ─────────────────────────────────────────── */
.text-muted { color: var(--text-secondary); }
.text-sm { font-size: 13px; }
.text-xs { font-size: 11px; }
.mt-1 { margin-top: 8px; }
.mt-2 { margin-top: 16px; }
.mt-3 { margin-top: 24px; }
.mb-1 { margin-bottom: 8px; }
.mb-2 { margin-bottom: 16px; }
.mb-3 { margin-bottom: 24px; }
.flex { display: flex; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-2 { gap: 16px; }
.gap-1 { gap: 8px; }
.grid { display: grid; gap: 1.5rem; }
.grid-2 { grid-template-columns: 1fr 1fr; }
.grid-3 { grid-template-columns: 1fr 1fr 1fr; }

/* ─── Page Transition ─────────────────────────────────── */
.content-body {
    animation: fadeUp 0.35s ease-out;
}

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

/* ─── Scrollbar ───────────────────────────────────────── */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

::-webkit-scrollbar-track {
    background: var(--bg-primary);
}

::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--text-tertiary);
}

/* ─── Row Actions ─────────────────────────────────────── */
td .btn-group {
    opacity: 0.7;
    transition: var(--transition);
}

tr:hover td .btn-group {
    opacity: 1;
}

/* ─── Card Backdrop Glow ──────────────────────────────── */
.stat-card {
    transition: var(--transition);
}

.stat-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
    border-color: color-mix(in srgb, var(--stat-color, var(--accent-blue)) 30%, transparent);
}

/* ─── Sidebar Animation ──────────────────────────────── */
.sidebar-link {
    position: relative;
    overflow: hidden;
}

.sidebar-link::after {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 2px;
    background: var(--accent-blue);
    transform: scaleY(0);
    transition: transform 0.2s ease;
}

.sidebar-link.active::after {
    transform: scaleY(1);
}

/* ─── Mobile Hamburger ────────────────────────────────── */
.mobile-toggle {
    display: none;
    position: fixed;
    top: 16px;
    left: 16px;
    z-index: 200;
    width: 40px;
    height: 40px;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    cursor: pointer;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 5px;
}

.mobile-toggle span {
    display: block;
    width: 20px;
    height: 2px;
    background: var(--text-primary);
    border-radius: 1px;
    transition: var(--transition);
}

.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.6);
    z-index: 90;
    backdrop-filter: blur(2px);
}

/* ─── Tooltip ─────────────────────────────────────────── */
[data-tooltip] {
    position: relative;
}

[data-tooltip]:hover::after {
    content: attr(data-tooltip);
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    background: var(--bg-card);
    color: var(--text-primary);
    padding: 4px 10px;
    border-radius: 4px;
    font-size: 11px;
    white-space: nowrap;
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow-card);
    pointer-events: none;
    z-index: 100;
    animation: fadeUp 0.15s ease;
}

/* ─── Print Styles ────────────────────────────────────── */
@media print {
    .sidebar, .content-header, .btn, .mobile-toggle { display: none !important; }
    .main-content { margin-left: 0 !important; }
    body { background: #fff; color: #000; }
    .card { box-shadow: none; border: 1px solid #ccc; }
}

/* ─── Responsive ──────────────────────────────────────── */
@media (max-width: 1024px) {
    .sidebar { width: 220px; }
    :root { --sidebar-width: 220px; }
    .content-body { padding: 20px; }
    .stats-grid { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 768px) {
    .mobile-toggle { display: flex; }
    
    .sidebar {
        transform: translateX(-100%);
        transition: transform 0.3s ease;
        z-index: 150;
        width: 280px;
    }
    
    .sidebar.open {
        transform: translateX(0);
    }
    
    .sidebar-overlay.active {
        display: block;
    }
    
    .main-content { margin-left: 0; }
    
    .content-header {
        padding-left: 64px;
    }
    
    .stats-grid { grid-template-columns: 1fr; }
    .form-row { grid-template-columns: 1fr; }
    .grid-2 { grid-template-columns: 1fr; }
    .grid-3 { grid-template-columns: 1fr; }
    
    .table-wrap {
        font-size: 12px;
    }
    
    .btn-group {
        flex-direction: column;
    }
}
