/* ============================================================
   BNSF Railway ATS — Application Stylesheet
   ============================================================ */

/* ---- Reset & Base ---- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
    --bnsf-orange: #FF6600;
    --bnsf-green: #006633;
    --bnsf-dark: #1A1A2E;
    --bnsf-darker: #16162A;
    --primary: #3B82F6;
    --primary-dark: #2563EB;
    --success: #10B981;
    --warning: #F59E0B;
    --danger: #EF4444;
    --info: #06B6D4;
    --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;
    --font-sans: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', sans-serif;
    --font-mono: 'SF Mono', 'Fira Code', 'Consolas', monospace;
    --radius: 6px;
    --radius-lg: 10px;
    --shadow-sm: 0 1px 2px rgba(0,0,0,.05);
    --shadow: 0 1px 3px rgba(0,0,0,.1), 0 1px 2px rgba(0,0,0,.06);
    --shadow-md: 0 4px 6px rgba(0,0,0,.07), 0 2px 4px rgba(0,0,0,.06);
    --shadow-lg: 0 10px 15px rgba(0,0,0,.1), 0 4px 6px rgba(0,0,0,.05);
    --sidebar-w: 250px;
    --sidebar-collapsed: 60px;
    --header-h: 56px;
}

html { font-size: 14px; }
body { font-family: var(--font-sans); color: var(--gray-800); background: var(--gray-50); line-height: 1.6; }
a { color: var(--primary); text-decoration: none; }
a:hover { color: var(--primary-dark); text-decoration: underline; }
img { max-width: 100%; }
table { border-collapse: collapse; width: 100%; }

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

/* Sidebar */
.sidebar {
    width: var(--sidebar-w); background: var(--bnsf-dark); color: #fff;
    position: fixed; top: 0; left: 0; height: 100vh; z-index: 100;
    display: flex; flex-direction: column; transition: width .2s;
    overflow-y: auto; overflow-x: hidden;
}
.sidebar.collapsed { width: var(--sidebar-collapsed); overflow: hidden; }
.sidebar.collapsed .nav-text, .sidebar.collapsed .brand-text { display: none; }
.sidebar.collapsed .sidebar-header { justify-content: center; padding: 14px 8px; }
.sidebar.collapsed .brand { display: none; }
.sidebar.collapsed .sidebar-toggle { margin: 0 auto; }
.sidebar.collapsed .nav-item { justify-content: center; padding: 9px 8px; }
.sidebar.collapsed .nav-icon { margin: 0; }
.sidebar.collapsed .sidebar-footer { display: none; }

.sidebar-header {
    display: flex; align-items: center; justify-content: space-between;
    padding: 14px 16px; border-bottom: 1px solid rgba(255,255,255,.1);
}
.brand { display: flex; align-items: center; gap: 10px; }
.brand-icon {
    background: var(--bnsf-orange); color: #fff; font-weight: 800;
    padding: 4px 8px; border-radius: 4px; font-size: .85rem; letter-spacing: 1px;
}
.brand-text { font-weight: 600; font-size: .95rem; white-space: nowrap; }
.sidebar-toggle {
    background: none; border: none; color: #fff; font-size: 1.1rem;
    cursor: pointer; padding: 4px;
}

.sidebar-nav { flex: 1; padding: 12px 8px; }
.nav-item {
    display: flex; align-items: center; gap: 10px;
    padding: 9px 12px; border-radius: var(--radius);
    color: rgba(255,255,255,.7); font-size: .875rem; transition: all .15s;
    margin-bottom: 2px; text-decoration: none;
}
.nav-item:hover { background: rgba(255,255,255,.08); color: #fff; text-decoration: none; }
.nav-item.active { background: rgba(59,130,246,.25); color: #fff; font-weight: 500; }
.nav-icon { font-size: 1.05rem; width: 22px; text-align: center; flex-shrink: 0; }

.sidebar-footer {
    padding: 12px 16px; border-top: 1px solid rgba(255,255,255,.1);
    font-size: .8rem; color: rgba(255,255,255,.5);
}
.sidebar-user { display: flex; align-items: center; gap: 8px; }
.sidebar-user .avatar {
    width: 32px; height: 32px; border-radius: 50%;
    background: var(--bnsf-orange); display: flex; align-items: center;
    justify-content: center; font-weight: 700; font-size: .75rem; color: #fff;
}
.sidebar-user-info { overflow: hidden; }
.sidebar-user-name { font-weight: 500; color: #fff; white-space: nowrap; text-overflow: ellipsis; overflow: hidden; }
.sidebar-user-role { font-size: .7rem; }

/* Main content */
.main-content {
    margin-left: var(--sidebar-w); flex: 1; display: flex; flex-direction: column;
    transition: margin-left .2s;
}
.sidebar.collapsed ~ .main-content { margin-left: var(--sidebar-collapsed); }

.content-header {
    background: #fff; border-bottom: 1px solid var(--gray-200);
    padding: 16px 28px; display: flex; align-items: center;
    justify-content: space-between; min-height: var(--header-h);
}
.content-header h1 { font-size: 1.25rem; font-weight: 600; color: var(--gray-900); }
.content-body { padding: 24px 28px; flex: 1; }

/* ---- Cards ---- */
.card {
    background: #fff; border-radius: var(--radius-lg); box-shadow: var(--shadow);
    border: 1px solid var(--gray-200); overflow: hidden;
}
.card-header {
    padding: 16px 20px; border-bottom: 1px solid var(--gray-100);
    display: flex; align-items: center; justify-content: space-between;
}
.card-header h2, .card-header h3 { font-size: 1rem; font-weight: 600; margin: 0; }
.card-body { padding: 20px; }
.card-footer { padding: 14px 20px; border-top: 1px solid var(--gray-100); background: var(--gray-50); }

/* ---- Stat Cards ---- */
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 16px; margin-bottom: 24px; }
.stat-card {
    background: #fff; border-radius: var(--radius-lg); padding: 20px;
    box-shadow: var(--shadow-sm); border: 1px solid var(--gray-200);
}
.stat-card .stat-label { font-size: .75rem; text-transform: uppercase; letter-spacing: .5px; color: var(--gray-500); margin-bottom: 4px; }
.stat-card .stat-value { font-size: 1.75rem; font-weight: 700; color: var(--gray-900); }
.stat-card .stat-change { font-size: .8rem; margin-top: 4px; }
.stat-card .stat-change.up { color: var(--success); }
.stat-card .stat-change.down { color: var(--danger); }

/* ---- Tables ---- */
.data-table { width: 100%; font-size: .875rem; }
.data-table thead th {
    text-align: left; padding: 10px 14px; font-weight: 600;
    color: var(--gray-600); background: var(--gray-50);
    border-bottom: 2px solid var(--gray-200); font-size: .8rem;
    text-transform: uppercase; letter-spacing: .3px; white-space: nowrap;
}
.data-table tbody td { padding: 12px 14px; border-bottom: 1px solid var(--gray-100); vertical-align: middle; }
.data-table tbody tr:hover { background: var(--gray-50); }
.data-table tbody tr:last-child td { border-bottom: none; }

/* ---- Badges & Status ---- */
.badge {
    display: inline-flex; align-items: center; padding: 2px 10px;
    border-radius: 100px; font-size: .75rem; font-weight: 600;
    line-height: 1.6; white-space: nowrap;
}
.badge-primary { background: #DBEAFE; color: #1D4ED8; }
.badge-success { background: #D1FAE5; color: #065F46; }
.badge-warning { background: #FEF3C7; color: #92400E; }
.badge-danger  { background: #FEE2E2; color: #991B1B; }
.badge-info    { background: #CFFAFE; color: #155E75; }
.badge-gray    { background: var(--gray-100); color: var(--gray-600); }

.status-draft            { background: var(--gray-100); color: var(--gray-600); }
.status-pending_approval { background: #FEF3C7; color: #92400E; }
.status-approved         { background: #DBEAFE; color: #1D4ED8; }
.status-open             { background: #D1FAE5; color: #065F46; }
.status-on_hold          { background: #FEF3C7; color: #92400E; }
.status-filled           { background: #D1FAE5; color: #065F46; }
.status-cancelled        { background: #FEE2E2; color: #991B1B; }

.priority-low    { border-left: 3px solid var(--gray-400); }
.priority-medium { border-left: 3px solid var(--primary); }
.priority-high   { border-left: 3px solid var(--warning); }
.priority-urgent { border-left: 3px solid var(--danger); }

.level-badge { font-weight: 700; font-size: .7rem; padding: 2px 8px; border-radius: 4px; }
.level-L3, .level-L4 { background: #DBEAFE; color: #1D4ED8; }
.level-L5, .level-L6 { background: #D1FAE5; color: #065F46; }
.level-L7, .level-L8 { background: #FEF3C7; color: #92400E; }
.level-L9, .level-L10 { background: #FEE2E2; color: #991B1B; }

/* ---- Buttons ---- */
.btn {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 8px 16px; border-radius: var(--radius); font-size: .875rem;
    font-weight: 500; cursor: pointer; border: 1px solid transparent;
    transition: all .15s; text-decoration: none; line-height: 1.4;
}
.btn:hover { text-decoration: none; }
.btn-primary { background: var(--primary); color: #fff; border-color: var(--primary); }
.btn-primary:hover { background: var(--primary-dark); color: #fff; }
.btn-success { background: var(--success); color: #fff; }
.btn-success:hover { background: #059669; color: #fff; }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { background: #DC2626; color: #fff; }
.btn-warning { background: var(--warning); color: #fff; }
.btn-warning:hover { background: #D97706; color: #fff; }
.btn-secondary { background: #fff; color: var(--gray-700); border-color: var(--gray-300); }
.btn-secondary:hover { background: var(--gray-50); }
.btn-sm { padding: 4px 10px; font-size: .8rem; }
.btn-lg { padding: 10px 24px; font-size: 1rem; }
.btn-icon { padding: 6px 8px; }
.btn-group { display: flex; gap: 8px; flex-wrap: wrap; }

/* ---- Forms ---- */
.form-group { margin-bottom: 16px; }
.form-label {
    display: block; margin-bottom: 4px; font-weight: 500;
    font-size: .85rem; color: var(--gray-700);
}
.form-label .required { color: var(--danger); }
.form-control {
    width: 100%; padding: 8px 12px; border: 1px solid var(--gray-300);
    border-radius: var(--radius); font-size: .875rem; font-family: var(--font-sans);
    color: var(--gray-800); background: #fff; transition: border-color .15s, box-shadow .15s;
}
.form-control:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(59,130,246,.15); }
.form-control.error { border-color: var(--danger); }
.form-hint { font-size: .78rem; color: var(--gray-500); margin-top: 2px; }
.form-error { font-size: .78rem; color: var(--danger); margin-top: 2px; }

select.form-control { appearance: auto; }
textarea.form-control { resize: vertical; min-height: 80px; }

.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.form-row-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 16px; }

.form-check { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.form-check input[type="checkbox"] { width: 16px; height: 16px; accent-color: var(--primary); }

/* ---- Alerts ---- */
.alert {
    display: flex; align-items: flex-start; gap: 10px; padding: 12px 16px;
    border-radius: var(--radius); margin-bottom: 16px; font-size: .875rem;
}
.alert-success { background: #D1FAE5; color: #065F46; border: 1px solid #A7F3D0; }
.alert-error   { background: #FEE2E2; color: #991B1B; border: 1px solid #FECACA; }
.alert-warning { background: #FEF3C7; color: #92400E; border: 1px solid #FDE68A; }
.alert-info    { background: #CFFAFE; color: #155E75; border: 1px solid #A5F3FC; }
.alert-icon { font-size: 1.1rem; flex-shrink: 0; margin-top: 1px; }
.alert-close {
    margin-left: auto; background: none; border: none; cursor: pointer;
    font-size: 1.2rem; color: inherit; opacity: .6; padding: 0;
}
.alert-close:hover { opacity: 1; }

/* ---- Pagination ---- */
.pagination { display: flex; align-items: center; gap: 4px; margin-top: 20px; justify-content: center; }
.pagination a, .pagination span {
    display: inline-flex; align-items: center; justify-content: center;
    min-width: 36px; height: 36px; padding: 0 8px;
    border: 1px solid var(--gray-200); border-radius: var(--radius);
    font-size: .85rem; color: var(--gray-700);
}
.pagination a:hover { background: var(--gray-50); text-decoration: none; }
.pagination .active { background: var(--primary); color: #fff; border-color: var(--primary); }
.pagination .disabled { color: var(--gray-400); pointer-events: none; }

/* ---- Filter Bar ---- */
.filter-bar {
    display: flex; flex-wrap: wrap; gap: 12px; align-items: flex-end;
    padding: 16px 20px; background: var(--gray-50); border-bottom: 1px solid var(--gray-100);
}
.filter-bar .form-group { margin-bottom: 0; }
.filter-bar .form-control { padding: 6px 10px; font-size: .8rem; min-width: 140px; }
.filter-bar .form-label { font-size: .75rem; margin-bottom: 2px; }

/* ---- Detail sections ---- */
.detail-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.detail-item { margin-bottom: 12px; }
.detail-label { font-size: .75rem; text-transform: uppercase; letter-spacing: .5px; color: var(--gray-500); margin-bottom: 2px; }
.detail-value { font-size: .9rem; color: var(--gray-900); }

/* Pipeline stages (horizontal) */
.pipeline { display: flex; gap: 4px; flex-wrap: wrap; margin: 16px 0; }
.pipeline-stage {
    display: flex; align-items: center; gap: 6px; padding: 6px 12px;
    border-radius: 100px; font-size: .78rem; font-weight: 500;
    background: var(--gray-100); color: var(--gray-600);
}
.pipeline-stage.active { background: var(--primary); color: #fff; }
.pipeline-stage .stage-dot { width: 8px; height: 8px; border-radius: 50%; }

/* Timeline / Approval history */
.timeline { position: relative; padding-left: 24px; }
.timeline::before { content: ''; position: absolute; left: 7px; top: 0; bottom: 0; width: 2px; background: var(--gray-200); }
.timeline-item { position: relative; margin-bottom: 20px; }
.timeline-item::before {
    content: ''; position: absolute; left: -21px; top: 4px;
    width: 12px; height: 12px; border-radius: 50%;
    background: #fff; border: 2px solid var(--gray-300);
}
.timeline-item.approved::before { border-color: var(--success); background: #D1FAE5; }
.timeline-item.rejected::before { border-color: var(--danger); background: #FEE2E2; }
.timeline-item.pending::before { border-color: var(--warning); background: #FEF3C7; }
.timeline-date { font-size: .75rem; color: var(--gray-500); }
.timeline-content { font-size: .875rem; }

/* ---- Responsive ---- */
@media (max-width: 768px) {
    .sidebar { width: var(--sidebar-collapsed); }
    .sidebar .nav-text, .sidebar .brand-text { display: none; }
    .main-content { margin-left: var(--sidebar-collapsed); }
    .form-row, .form-row-3, .detail-grid { grid-template-columns: 1fr; }
    .stat-grid { grid-template-columns: 1fr 1fr; }
    .content-body { padding: 16px; }
    .filter-bar { flex-direction: column; }
}

/* ---- Auth layout ---- */
.auth-layout {
    min-height: 100vh; display: flex; align-items: center; justify-content: center;
    background: linear-gradient(135deg, var(--bnsf-dark) 0%, #2D2D5E 100%);
}
.auth-card { width: 100%; max-width: 420px; padding: 24px; }
.auth-card .card { box-shadow: var(--shadow-lg); }
.auth-brand { text-align: center; margin-bottom: 24px; color: #fff; }
.auth-brand .brand-icon { display: inline-block; font-size: 1.2rem; margin-bottom: 8px; }
.auth-brand h1 { font-size: 1.3rem; font-weight: 600; }

/* ---- Misc ---- */
.text-muted { color: var(--gray-500); }
.text-sm { font-size: .8rem; }
.text-right { text-align: right; }
.text-center { text-align: center; }
.mt-1 { margin-top: 4px; }  .mt-2 { margin-top: 8px; }  .mt-3 { margin-top: 16px; }  .mt-4 { margin-top: 24px; }
.mb-1 { margin-bottom: 4px; } .mb-2 { margin-bottom: 8px; } .mb-3 { margin-bottom: 16px; } .mb-4 { margin-bottom: 24px; }
.mr-2 { margin-right: 8px; }
.d-flex { display: flex; } .align-center { align-items: center; } .gap-2 { gap: 8px; } .gap-3 { gap: 12px; }
.justify-between { justify-content: space-between; }
.flex-1 { flex: 1; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0,0,0,0); }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.no-wrap { white-space: nowrap; }
.w-full { width: 100%; }

/* Confirmation modal */
.modal-backdrop {
    position: fixed; inset: 0; background: rgba(0,0,0,.5); z-index: 999;
    display: none; align-items: center; justify-content: center;
}
.modal-backdrop.show { display: flex; }
.modal { background: #fff; border-radius: var(--radius-lg); padding: 24px; max-width: 480px; width: 90%; box-shadow: var(--shadow-lg); }
.modal h3 { margin-bottom: 12px; }
.modal-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 20px; }

/* Empty states */
.empty-state { text-align: center; padding: 48px 24px; color: var(--gray-500); }
.empty-state .empty-icon { font-size: 3rem; margin-bottom: 12px; }
.empty-state p { margin-bottom: 16px; }
