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

:root {
    --primary: #1e3a8a; /* Corporate Navy */
    --primary-hover: #1e40af;
    --primary-light: #eff6ff;
    --accent: #3b82f6;
    --sidebar-bg: #ffffff;
    --sidebar-color: #334155;
    --sidebar-hover-bg: #eff6ff;
    --sidebar-hover-color: #1e3a8a;
    --bg-light: #f8fafc;
    --white: #ffffff;
    --text-primary: #0f172a;
    --text-secondary: #64748b;
    --danger: #ef4444;
    --success: #10b981;
    --border-color: #e2e8f0;
    --sidebar-width: 260px;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    font-family: 'Inter', sans-serif;
}

h1, h2, h3, h4, .sidebar-header, .sidebar-category {
    font-family: 'Outfit', sans-serif;
}

body {
    background-color: var(--bg-light);
    color: var(--text-primary);
    display: flex;
    min-height: 100vh;
}

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

/* =========================================
   SIDEBAR
   ========================================= */
.sidebar {
    width: var(--sidebar-width);
    background-color: var(--sidebar-bg);
    color: var(--sidebar-color);
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    position: fixed;
    height: 100vh;
    overflow-y: auto;
    border-right: 1px solid var(--border-color);
    z-index: 300;
    transition: transform 0.3s ease;
}

.sidebar-header {
    padding: 1.5rem;
    font-size: 1.2rem;
    font-weight: 700;
    color: var(--primary);
    display: flex;
    align-items: center;
    gap: 0.5rem;
    border-bottom: 1px solid var(--border-color);
}

.sidebar-category {
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: #64748b;
    padding: 1.5rem 1.5rem 0.5rem;
}

.sidebar-nav {
    display: flex;
    flex-direction: column;
}

.sidebar-nav a {
    color: var(--sidebar-color);
    text-decoration: none;
    padding: 0.75rem 1.5rem;
    font-size: 0.95rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    transition: all 0.2s ease;
    font-weight: 600;
    min-height: 48px;
}

.sidebar-nav a:hover, .sidebar-nav a.active {
    background-color: var(--sidebar-hover-bg);
    color: var(--sidebar-hover-color);
    border-left: 3px solid var(--primary);
}

/* Mobile overlay behind sidebar */
.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.5);
    z-index: 250;
    backdrop-filter: blur(2px);
}

.sidebar-overlay.open {
    display: block;
}

/* Sidebar footer override */
.sidebar > div[style*="border-top"] {
    border-top: 1px solid var(--border-color) !important;
}

/* =========================================
   MAIN CONTENT
   ========================================= */
.main-content {
    flex-grow: 1;
    margin-left: var(--sidebar-width);
    display: flex;
    flex-direction: column;
    min-width: 0;
}

/* =========================================
   TOP HEADER
   ========================================= */
.top-header {
    background-color: var(--white);
    padding: 1rem 2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--border-color);
    box-shadow: 0 1px 3px rgba(0,0,0,0.05);
    position: sticky;
    top: 0;
    z-index: 100;
    gap: 1rem;
}

.top-header h1 {
    font-size: 1.25rem;
    font-weight: 600;
    margin: 0;
}

/* Hamburger — hidden on desktop, shown on mobile */
.sidebar-toggle {
    display: none;
    background: none;
    border: none;
    cursor: pointer;
    padding: 0.5rem;
    color: var(--text-primary);
    font-size: 1.25rem;
    border-radius: 4px;
    flex-shrink: 0;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
    min-width: 40px;
    min-height: 40px;
}
.sidebar-toggle:hover {
    background: var(--primary-light);
    color: var(--primary);
}

/* =========================================
   CONTENT AREA
   ========================================= */
.content-area {
    padding: 2rem;
    flex-grow: 1;
    overflow-y: auto;
}

/* =========================================
   KPI GRID
   ========================================= */
.kpi-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.kpi-card {
    background: var(--white);
    padding: 1.5rem;
    border-radius: 0;
    border: 1px solid var(--border-color);
    box-shadow: 0 1px 3px rgba(0,0,0,0.02);
    display: flex;
    flex-direction: column;
}

.kpi-value {
    font-size: 1.75rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 0.25rem;
}

.kpi-label {
    font-size: 0.75rem;
    text-transform: uppercase;
    font-weight: 600;
    color: var(--text-secondary);
}

/* =========================================
   PANEL GRID
   ========================================= */
.panel-grid {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 1.5rem;
}

@media (max-width: 1024px) {
    .panel-grid {
        grid-template-columns: 1fr;
    }
}

/* =========================================
   CARD
   ========================================= */
.card {
    background: var(--white);
    border-radius: 0;
    border: 1px solid var(--border-color);
    box-shadow: 0 1px 3px rgba(0,0,0,0.02);
    padding: 1.5rem;
    margin-bottom: 1.5rem;
}

.card-header {
    font-size: 0.85rem;
    font-weight: 700;
    text-transform: uppercase;
    color: var(--text-secondary);
    margin-bottom: 1rem;
    padding-bottom: 0.75rem;
    border-bottom: 1px solid var(--border-color);
}

/* =========================================
   FORMS & BUTTONS
   ========================================= */
h2, h3 {
    margin-bottom: 1rem;
    font-weight: 600;
}

.btn {
    background: var(--primary);
    color: white;
    border: none;
    padding: 0.65rem 1.25rem;
    border-radius: 0;
    font-size: 0.85rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    cursor: pointer;
    transition: all 0.25s ease;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    min-height: 40px;
}

.btn:hover {
    background: var(--primary-hover);
    transform: translateY(-1px);
}

.btn-danger { background: var(--danger); }
.btn-danger:hover { background: #dc2626; }

.form-group {
    margin-bottom: 1.25rem;
}

.form-group label {
    display: block;
    margin-bottom: 0.5rem;
    color: var(--text-secondary);
    font-size: 0.85rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.form-control {
    width: 100%;
    padding: 0.75rem 1rem;
    background: var(--bg-light);
    border: 2px solid var(--border-color);
    border-radius: 0;
    color: var(--text-primary);
    transition: all 0.2s ease;
    /* Prevent iOS auto-zoom (font-size >= 16px) */
    font-size: 1rem;
}

.form-control:focus {
    outline: none;
    border-color: var(--primary);
    background: var(--white);
    box-shadow: 0 0 0 4px var(--primary-light);
}

/* =========================================
   TABLES
   ========================================= */
.table-responsive {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

table {
    width: 100%;
    border-collapse: collapse;
}

th, td {
    padding: 0.75rem 1rem;
    text-align: left;
    border-bottom: 1px solid var(--border-color);
    font-size: 0.9rem;
}

th {
    color: var(--text-secondary);
    font-weight: 600;
    text-transform: uppercase;
    font-size: 0.75rem;
    background: #f8fafc;
}

tr:hover td {
    background: #f1f5f9;
}

/* =========================================
   ALERTS
   ========================================= */
.alert {
    padding: 1rem;
    border-radius: 0;
    margin-bottom: 1rem;
    font-size: 0.9rem;
}

.alert-success {
    background: #ecfdf5;
    border: 1px solid #10b981;
    color: #047857;
}

.alert-danger {
    background: #fef2f2;
    border: 1px solid var(--danger);
    color: #b91c1c;
}

/* =========================================
   MODAL (overlay-style)
   ========================================= */
.modal-overlay {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(17, 24, 39, 0.6);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
    padding: 1rem;
}
.modal-overlay.active {
    opacity: 1;
    visibility: visible;
}
.modal-overlay .modal-content {
    background: var(--white);
    width: 100%;
    max-width: 500px;
    padding: 2rem;
    box-shadow: 0 10px 25px rgba(0,0,0,0.1);
    transform: translateY(20px);
    transition: all 0.3s ease;
    max-height: 90vh;
    overflow-y: auto;
}
.modal-overlay.active .modal-content {
    transform: translateY(0);
}
.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
}
.modal-header h3 { margin: 0; font-size: 1.25rem; }
.modal-close {
    background: none; border: none; font-size: 1.5rem; cursor: pointer; color: var(--text-secondary);
}
.modal-body { margin-bottom: 1.5rem; }
.wizard-progress { margin-bottom: 1.5rem; }
.wizard-progress-bar {
    height: 6px;
    background: var(--border-color);
    width: 100%;
    overflow: hidden;
}
.wizard-progress-fill {
    height: 100%;
    background: var(--primary);
    width: 0%;
    transition: width 0.3s ease;
}
.modal-footer {
    display: flex;
    justify-content: flex-end;
    align-items: center;
    gap: 1rem;
    flex-wrap: wrap;
}

/* =========================================
   MODAL (page-level, display:flex toggle)
   ========================================= */
.modal {
    position: fixed;
    top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(15, 23, 42, 0.4);
    backdrop-filter: blur(8px);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: 1rem;
}
.modal.show { display: flex; }
.modal .modal-content {
    background-color: #fff;
    padding: 2.5rem;
    border-radius: 0;
    max-width: 500px;
    width: 100%;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
    position: relative;
    max-height: 90vh;
    overflow-y: auto;
}
.close-modal {
    font-size: 1.5rem;
    cursor: pointer;
    color: var(--text-secondary);
    background: none;
    border: none;
}

/* =========================================
   ICON-ONLY BUTTONS
   ========================================= */
.btn-icon {
    width: 36px !important;
    height: 36px !important;
    padding: 0 !important;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    border-radius: 0 !important;
}

/* =========================================
   RESPONSIVE — MOBILE (≤768px)
   ========================================= */
@media (max-width: 768px) {

    /* Show hamburger button */
    .sidebar-toggle {
        display: inline-flex;
    }

    /* Sidebar slides off-screen by default */
    .sidebar {
        transform: translateX(-100%);
        width: 280px;
        box-shadow: 4px 0 24px rgba(0,0,0,0.18);
    }

    .sidebar.open {
        transform: translateX(0);
    }

    /* Main content spans full width */
    .main-content {
        margin-left: 0;
        width: 100%;
    }

    /* Tighter header */
    .top-header {
        padding: 0.75rem 1rem;
    }

    .top-header h1 {
        font-size: 1rem;
    }

    /* Reduce content padding */
    .content-area {
        padding: 1rem;
    }

    /* 2-column KPI grid */
    .kpi-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 0.75rem;
        margin-bottom: 1.25rem;
    }

    .kpi-card {
        padding: 1rem;
    }

    .kpi-value {
        font-size: 1.35rem;
    }

    .card {
        padding: 1rem;
    }

    /* Tables: ensure horizontal scroll */
    th, td {
        padding: 0.6rem 0.75rem;
        font-size: 0.8rem;
    }

    /* Stack search + action rows */
    div[style*="justify-content: space-between"][style*="display: flex"] {
        flex-direction: column !important;
        align-items: stretch !important;
    }

    /* Wider modals on mobile */
    .modal .modal-content,
    .modal-overlay .modal-content {
        padding: 1.5rem;
        max-height: 85vh;
    }
}

/* =========================================
   RESPONSIVE — SMALL MOBILE (≤480px)
   ========================================= */
@media (max-width: 480px) {

    /* Single column KPIs */
    .kpi-grid {
        grid-template-columns: 1fr;
    }

    .top-header h1 {
        font-size: 0.9rem;
    }

    /* Hide columns tagged hide-xs */
    .hide-xs {
        display: none !important;
    }

    .btn {
        font-size: 0.8rem;
        padding: 0.6rem 1rem;
    }

    /* Make action button groups wrap */
    div[style*="inline-flex"] {
        flex-wrap: wrap;
    }
}
