/* ============================================================
   WhereFy IRCTC LOP Validator – Global Styles
   Full-screen sidebar + header layout, zero white space
   ============================================================ */

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

/* ---------- CSS VARIABLES ---------- */
:root {
    --primary-dark: #0a1e3c;
    --primary: #1a3c6e;
    --primary-light: #2c5a8c;
    --accent: #e8a838;
    --success: #28a745;
    --danger: #dc3545;
    --warning: #fd7e14;
    --bg-body: #f5f7fa;
    --border-light: #dce1e8;
    --text-dark: #1e293b;
    --text-muted: #64748b;
    --sidebar-bg: #ffffff;
    --sidebar-width: 260px;
    --header-height: 64px;
}

/* ---------- BODY ---------- */
body {
    font-family: 'Inter', 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background-color: var(--bg-body);
    color: var(--text-dark);
    height: 100vh;
    overflow: hidden;
    display: flex;
}

/* ============================================================
   SIDEBAR
   ============================================================ */
.sidebar {
    width: var(--sidebar-width);
    height: 100vh;
    background: var(--sidebar-bg);
    border-right: 1px solid var(--border-light);
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    overflow-y: auto;
    box-shadow: 0 0 20px rgba(0, 0, 0, 0.02);
    z-index: 10;
}

.sidebar-brand {
    padding: 1.2rem 1.5rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    border-bottom: 1px solid var(--border-light);
    min-height: var(--header-height);
}

.sidebar-brand .logo-icon {
    width: 32px;
    height: 32px;
    background: var(--primary);
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-weight: 700;
    font-size: 0.9rem;
}

.sidebar-brand .brand-text {
    font-weight: 700;
    font-size: 1.1rem;
    color: var(--primary-dark);
    letter-spacing: -0.01em;
}

.sidebar-brand .brand-text span {
    color: var(--accent);
    font-weight: 800;
}

.sidebar-brand .brand-sub {
    font-size: 0.7rem;
    color: var(--text-muted);
    font-weight: 400;
    margin-left: auto;
}

.sidebar-nav {
    padding: 1.5rem 1rem;
    flex: 1;
}

.sidebar-nav .nav-section {
    font-size: 0.65rem;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    color: #94a3b8;
    font-weight: 600;
    padding: 0 0.75rem;
    margin-bottom: 0.5rem;
    margin-top: 1.25rem;
}

.sidebar-nav .nav-section:first-of-type {
    margin-top: 0;
}

.sidebar-nav .nav-link {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.6rem 0.75rem;
    border-radius: 8px;
    color: #475569;
    font-weight: 500;
    font-size: 0.9rem;
    transition: all 0.15s ease;
    text-decoration: none;
    margin-bottom: 0.15rem;
}

.sidebar-nav .nav-link i {
    font-size: 1.1rem;
    color: #94a3b8;
    transition: color 0.15s ease;
    width: 20px;
    text-align: center;
}

.sidebar-nav .nav-link:hover {
    background: #f1f5f9;
    color: var(--primary);
}

.sidebar-nav .nav-link:hover i {
    color: var(--primary);
}

.sidebar-nav .nav-link.active {
    background: #e8edf5;
    color: var(--primary);
    font-weight: 600;
}

.sidebar-nav .nav-link.active i {
    color: var(--primary);
}

.sidebar-footer {
    padding: 1rem 1.5rem;
    border-top: 1px solid var(--border-light);
    font-size: 0.75rem;
    color: #94a3b8;
}

.sidebar-footer .status-dot {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #94a3b8;
    margin-right: 0.4rem;
}

/* ============================================================
   MAIN WRAPPER
   ============================================================ */
.main-wrap {
    flex: 1;
    display: flex;
    flex-direction: column;
    height: 100vh;
    overflow: hidden;
}

/* ============================================================
   TOP HEADER
   ============================================================ */
.top-header {
    height: var(--header-height);
    background: #ffffff;
    border-bottom: 1px solid var(--border-light);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 2rem;
    flex-shrink: 0;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.02);
}

.header-left {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.header-left .menu-toggle {
    font-size: 1.4rem;
    color: var(--text-muted);
    cursor: default;
}

.header-left .page-title {
    font-weight: 600;
    font-size: 1.1rem;
    color: var(--primary-dark);
    letter-spacing: -0.01em;
}

.header-left .page-title small {
    font-weight: 400;
    color: var(--text-muted);
    font-size: 0.8rem;
    margin-left: 0.5rem;
}

.header-right {
    display: flex;
    align-items: center;
    gap: 1.5rem;
}

.header-right .facility-selector {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.4rem 1rem;
    background: #f1f5f9;
    border-radius: 20px;
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text-dark);
    cursor: default;
}

.header-right .facility-selector i {
    font-size: 0.9rem;
    color: var(--text-muted);
}

.header-right .user-badge {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.header-right .user-badge .avatar {
    width: 36px;
    height: 36px;
    background: var(--primary);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-weight: 600;
    font-size: 0.9rem;
    text-transform: uppercase;
}

.header-right .user-badge .user-name {
    font-weight: 500;
    font-size: 0.9rem;
    color: var(--text-dark);
}

.header-right .signout-btn {
    font-size: 0.8rem;
    color: var(--text-muted);
    text-decoration: none;
    padding: 0.3rem 0.8rem;
    border: 1px solid var(--border-light);
    border-radius: 20px;
    transition: all 0.15s ease;
    cursor: default;
}

.header-right .signout-btn:hover {
    background: #f8fafc;
}

/* ============================================================
   CONTENT AREA
   ============================================================ */
.content-area {
    flex: 1;
    overflow-y: auto;
    padding: 2rem 2rem 1.5rem 2rem;
    background: var(--bg-body);
}

/* ============================================================
   STAT CARDS
   ============================================================ */
.stat-card {
    background: #ffffff;
    border-radius: 12px;
    padding: 1.5rem 1.5rem 1.2rem 1.5rem;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.04);
    border-left: 4px solid var(--primary);
    transition: all 0.2s ease;
    height: 100%;
}

.stat-card:hover {
    transform: translateY(-3px);
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.06);
}

.stat-card .stat-number {
    font-size: 2.4rem;
    font-weight: 700;
    color: var(--primary);
    line-height: 1.1;
}

.stat-card .stat-label {
    font-size: 0.8rem;
    color: var(--text-muted);
    font-weight: 500;
    margin-top: 0.25rem;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.stat-card.success { border-left-color: var(--success); }
.stat-card.success .stat-number { color: var(--success); }
.stat-card.danger { border-left-color: var(--danger); }
.stat-card.danger .stat-number { color: var(--danger); }
.stat-card.warning { border-left-color: var(--accent); }
.stat-card.warning .stat-number { color: var(--accent); }

/* ============================================================
   CARD
   ============================================================ */
.card-custom {
    border: none;
    border-radius: 12px;
    box-shadow: 0 1px 6px rgba(0, 0, 0, 0.04);
    background: #ffffff;
    transition: box-shadow 0.2s ease;
    overflow: hidden;
}

.card-custom .card-header {
    background: #ffffff;
    border-bottom: 1px solid var(--border-light);
    padding: 1rem 1.5rem;
    font-weight: 600;
    font-size: 0.95rem;
    color: var(--primary-dark);
    border-radius: 12px 12px 0 0 !important;
}

.card-custom .card-body {
    padding: 1.5rem;
}

/* ============================================================
   BADGES
   ============================================================ */
.badge-pass {
    background: var(--success);
    color: #fff;
    padding: 0.35rem 0.9rem;
    border-radius: 20px;
    font-weight: 500;
    font-size: 0.75rem;
    letter-spacing: 0.2px;
}

.badge-fail {
    background: var(--danger);
    color: #fff;
    padding: 0.35rem 0.9rem;
    border-radius: 20px;
    font-weight: 500;
    font-size: 0.75rem;
}

.badge-pending {
    background: var(--accent);
    color: #fff;
    padding: 0.35rem 0.9rem;
    border-radius: 20px;
    font-weight: 500;
    font-size: 0.75rem;
}

.badge-number {
    background: var(--primary);
    color: #fff;
    min-width: 28px;
    padding: 0.35rem 0.5rem;
    border-radius: 6px;
    font-weight: 600;
    font-size: 0.75rem;
    text-align: center;
}

.badge-accent {
    background: var(--accent);
    color: #fff;
    min-width: 28px;
    padding: 0.35rem 0.5rem;
    border-radius: 6px;
    font-weight: 600;
    font-size: 0.75rem;
    text-align: center;
}

/* ============================================================
   TABLES
   ============================================================ */
.table-custom {
    background: #fff;
    overflow: hidden;
    margin-bottom: 0;
}

.table-custom thead {
    background: #f8fafc;
    color: var(--text-muted);
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    font-weight: 600;
}

.table-custom thead th {
    padding: 0.9rem 1.2rem;
    border-bottom: 1px solid var(--border-light);
    white-space: nowrap;
}

.table-custom tbody td {
    padding: 0.9rem 1.2rem;
    vertical-align: middle;
    border-bottom: 1px solid var(--border-light);
    font-size: 0.88rem;
    color: var(--text-dark);
}

.table-custom tbody tr:hover {
    background: #fafbfc;
}

.table-custom tbody tr:last-child td {
    border-bottom: none;
}

/* ============================================================
   LINE TOGGLE CARDS
   ============================================================ */
.line-toggle-card {
    transition: background 0.15s ease, box-shadow 0.15s ease;
    border-radius: 10px;
    background: #ffffff;
    border: 1px solid var(--border-light);
    padding: 1rem 1.25rem;
    cursor: pointer;
}

.line-toggle-card.active {
    border-color: transparent;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.06);
}

.line-toggle-card:not(.active) {
    background-color: #eef1f5;
}

.line-toggle-card:not(.active) .line-title,
.line-toggle-card:not(.active) small {
    color: #9aa5b3 !important;
}

.line-toggle-card:not(.active) .line-badge {
    background-color: #c3cad4 !important;
    color: #ffffff;
}

.line-status-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 20px;
    height: 20px;
    font-size: 0.8rem;
    font-weight: 700;
    opacity: 0;
    transform: scale(0.4);
    transition: all 0.2s ease;
}

.line-toggle-card.active .line-status-icon {
    opacity: 1;
    transform: scale(1);
}

/* ============================================================
   LINE FILTER BUTTONS
   ============================================================ */
.line-filter-btn {
    border-radius: 20px;
    padding: 0.3rem 1rem;
    font-weight: 500;
    font-size: 0.78rem;
    border: 1px solid var(--border-light);
    background: #fff;
    color: var(--text-muted);
    transition: all 0.15s ease;
    margin: 0 2px;
}

.line-filter-btn.active-all { background: var(--primary); color: #fff; border-color: var(--primary); }
.line-filter-btn.active-up { background: #0d6efd; color: #fff; border-color: #0d6efd; }
.line-filter-btn.active-down { background: #fd7e14; color: #fff; border-color: #fd7e14; }

.line-row-hidden { display: none; }

/* ============================================================
   UPLOAD ZONE
   ============================================================ */
.upload-zone {
    border: 2px dashed var(--border-light);
    border-radius: 12px;
    padding: 2.5rem 1.5rem;
    text-align: center;
    cursor: pointer;
    transition: all 0.2s ease;
    background: #fafbfc;
}

.upload-zone:hover {
    border-color: var(--primary);
    background: #f0f4f8;
}

.upload-zone.dragover {
    border-color: var(--primary);
    background: #e8edf5;
}

.upload-zone .upload-icon {
    font-size: 3rem;
    color: var(--primary);
    opacity: 0.5;
    margin-bottom: 0.5rem;
}

.upload-progress {
    display: flex;
    align-items: center;
    padding: 0.75rem 1rem;
    background: #f0f4f8;
    border-radius: 8px;
}

/* ============================================================
   BUTTONS
   ============================================================ */
.btn-primary-custom {
    background: var(--primary);
    border: none;
    color: #fff;
    padding: 0.55rem 1.6rem;
    font-weight: 500;
    border-radius: 8px;
    font-size: 0.9rem;
    transition: all 0.2s ease;
}

.btn-primary-custom:hover {
    background: var(--primary-light);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(26, 60, 110, 0.25);
    color: #fff;
}

.btn-success-custom {
    background: var(--success);
    border: none;
    color: #fff;
    padding: 0.55rem 1.6rem;
    font-weight: 500;
    border-radius: 8px;
    font-size: 0.9rem;
    transition: all 0.2s ease;
}

.btn-success-custom:hover {
    background: #20c997;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(40, 167, 69, 0.25);
    color: #fff;
}

.btn-secondary-custom {
    background: #e9ecef;
    border: none;
    color: #495057;
    padding: 0.55rem 1.6rem;
    font-weight: 500;
    border-radius: 8px;
    font-size: 0.9rem;
    transition: all 0.2s ease;
}

.btn-secondary-custom:hover {
    background: #dee2e6;
    color: #343a40;
}

.btn-view-action {
    background: var(--primary);
    color: #fff;
    border-radius: 6px;
    padding: 0.3rem 1rem;
    font-size: 0.8rem;
    border: none;
    transition: all 0.15s ease;
}

.btn-view-action:hover {
    background: var(--primary-light);
    color: #fff;
}

/* ============================================================
   TABS
   ============================================================ */
.nav-tabs {
    border-bottom: 2px solid var(--border-light);
    gap: 0.25rem;
}

.nav-tabs .nav-link {
    border: none;
    color: var(--text-muted);
    font-weight: 500;
    font-size: 0.9rem;
    padding: 0.7rem 1.5rem;
    border-radius: 8px 8px 0 0;
    transition: all 0.15s ease;
    background: transparent;
    margin-bottom: -2px;
}

.nav-tabs .nav-link:hover {
    color: var(--primary);
    background: #f8fafc;
}

.nav-tabs .nav-link.active {
    color: var(--primary);
    background: #ffffff;
    border-bottom: 3px solid var(--primary);
    font-weight: 600;
}

/* ============================================================
   ALERTS
   ============================================================ */
.alert-info-custom {
    background: #f0f4f8;
    border-left: 4px solid var(--primary);
    border-radius: 8px;
    padding: 1rem 1.25rem;
}

.alert-error-custom {
    background: #fdf2f2;
    border-left: 4px solid var(--danger);
    border-radius: 8px;
    padding: 1rem 1.25rem;
}

.error-icon {
    font-size: 4rem;
    color: #dc3545;
    opacity: 0.3;
    line-height: 1;
}

/* ============================================================
   CURVE TABLE
   ============================================================ */
.curve-results-table th,
.curve-results-table td {
    white-space: nowrap;
}

.curve-results-table th:last-child,
.curve-results-table td:last-child {
    min-width: 350px;
    white-space: normal;
}

#curvePanel .table-responsive {
    max-height: 70vh;
    overflow: auto;
}

/* ============================================================
   UTILITIES
   ============================================================ */
.text-muted { color: var(--text-muted) !important; }
.fw-medium { font-weight: 500; }
code { font-size: 0.85rem; }

[role="tabpanel"][hidden] { display: none !important; }

/* ============================================================
   SCROLLBAR
   ============================================================ */
.content-area::-webkit-scrollbar { width: 6px; }
.content-area::-webkit-scrollbar-track { background: transparent; }
.content-area::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 10px; }
.content-area::-webkit-scrollbar-thumb:hover { background: #94a3b8; }

.table-responsive::-webkit-scrollbar { height: 6px; width: 6px; }
.table-responsive::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 10px; }

/* ============================================================
   RESPONSIVE
   ============================================================ */
@media (max-width: 992px) {
    .sidebar { width: 72px; }
    .sidebar .brand-text,
    .sidebar .brand-sub,
    .sidebar-nav .nav-link span,
    .sidebar-footer span:not(.status-dot) { display: none; }
    .sidebar-nav .nav-link { justify-content: center; padding: 0.75rem; }
    .sidebar-nav .nav-link i { font-size: 1.3rem; margin: 0; }
    .sidebar-nav .nav-section { text-align: center; font-size: 0.55rem; padding: 0; }
    .sidebar-brand { justify-content: center; padding: 0.75rem; }
    .sidebar-brand .logo-icon { width: 28px; height: 28px; font-size: 0.8rem; }
    .top-header { padding: 0 1rem; }
    .content-area { padding: 1.25rem; }
    .header-right .facility-selector span { display: none; }
    .header-right .user-badge .user-name { display: none; }
}

@media (max-width: 576px) {
    .header-left .page-title { font-size: 0.95rem; }
    .header-left .page-title small { display: none; }
    .stat-card .stat-number { font-size: 1.8rem; }
}