/* ============================================================
   EGL NEXUS — Design System
   Enterprise SaaS aesthetic (M365 / Jira / Linear / Monday)
============================================================ */

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

/* ============================================================
   4-THEME SYSTEM — Sidebar dark in EVERY theme (Special Touch)
   1. Dark + Indigo (default, Premium)
   2. Light + Indigo (Professional)  ← body.light / body.light-indigo
   3. Dark + Brown (Executive)        ← body.brown / body.dark-brown
   4. Light + Brown (Corporate)       ← body.blueblack / body.light-brown
============================================================ */

:root {
    /* ===== DEFAULT: DARK + INDIGO (Premium) ===== */
    --bg:        #0F172A;
    --bg-elevated:#1E293B;
    --bg-hover:  #273449;
    --card-bg:   #1E293B;
    --card:      #1E293B;
    --border:    rgba(255,255,255,0.06);
    --border-strong: rgba(255,255,255,0.12);
    --text:      #F1F5F9;
    --text-muted:#94A3B8;
    --muted:     #94A3B8;
    --text-dim:  #64748B;

    /* Sidebar — DARK in every theme */
    --sidebar-bg:        #020617;
    --sidebar-hover:     #1E293B;
    --sidebar-text:      #CBD5E1;
    --sidebar-text-dim:  #64748B;
    --sidebar-active-bg: #4F46E5;
    --sidebar-border:    rgba(255,255,255,0.06);

    /* Indigo primary */
    --primary: #4F46E5;
    --primary-hover: #6366F1;
    --primary-tint: rgba(79,70,229,0.16);
    --accent:  #4F46E5;

    /* Status (common) */
    --success: #16A34A; --success-tint: rgba(22,163,74,0.16);
    --warning: #F59E0B; --warning-tint: rgba(245,158,11,0.18);
    --danger:  #DC2626; --danger-tint: rgba(220,38,38,0.16);
    --info:    #06B6D4; --info-tint: rgba(6,182,212,0.16);

    --shadow-card: 0 1px 3px rgba(0,0,0,0.3), 0 1px 2px rgba(0,0,0,0.2);
    --shadow-md:   0 4px 12px rgba(0,0,0,0.35);
    --shadow-lg:   0 10px 30px rgba(0,0,0,0.45);
    --radius: 12px;
    --radius-sm: 8px;
    --radius-lg: 16px;
    --radius-full: 999px;
    --glow: 0 0 0 4px rgba(79,70,229,0.22);
}

/* ===== LIGHT + INDIGO (Professional) ===== */
body.light, body.light-indigo {
    --bg: #F8FAFC;
    --bg-elevated: #FFFFFF;
    --bg-hover: #F1F5F9;
    --card-bg: #FFFFFF;
    --card: #FFFFFF;
    --border: #E2E8F0;
    --border-strong: #CBD5E1;
    --text: #0F172A;
    --text-muted: #64748B;
    --muted: #64748B;
    --text-dim: #94A3B8;
    --primary: #4F46E5;
    --primary-hover: #6366F1;
    --primary-tint: #EEF2FF;
    --accent: #4F46E5;
    --success-tint: #DCFCE7;
    --warning-tint: #FEF3C7;
    --danger-tint: #FEE2E2;
    --info-tint: #E0F2FE;
    --shadow-card: 0 1px 3px rgba(15,23,42,0.06), 0 1px 2px rgba(15,23,42,0.04);
    --shadow-md:   0 4px 12px rgba(15,23,42,0.08);
    --shadow-lg:   0 10px 30px rgba(15,23,42,0.10);
    --glow: 0 0 0 4px rgba(79,70,229,0.18);
    /* Sidebar STAYS DARK — Special Touch */
}

/* ===== DARK + BROWN (Executive) ===== */
body.brown, body.dark-brown {
    --bg: #111827;
    --bg-elevated: #1E293B;
    --bg-hover: #2D3748;
    --card-bg: #1E293B;
    --card: #1E293B;
    --border: rgba(255,255,255,0.06);
    --border-strong: rgba(255,255,255,0.12);
    --text: #F1F5F9;
    --text-muted: #94A3B8;
    --muted: #94A3B8;
    --text-dim: #64748B;
    --primary: #92400E;
    --primary-hover: #D97706;
    --primary-tint: rgba(146,64,14,0.20);
    --accent: #D97706;
    --success: #22C55E; --success-tint: rgba(34,197,94,0.16);
    --warning: #F59E0B; --warning-tint: rgba(245,158,11,0.18);
    --danger: #EF4444; --danger-tint: rgba(239,68,68,0.16);
    --glow: 0 0 0 4px rgba(217,119,6,0.22);
    --sidebar-bg: #1F2937;
    --sidebar-active-bg: #D97706;
}

/* ===== LIGHT + BROWN (Corporate) ===== */
body.blueblack, body.light-brown {
    --bg: #FAF7F2;
    --bg-elevated: #FFFFFF;
    --bg-hover: #F5EFE6;
    --card-bg: #FFFFFF;
    --card: #FFFFFF;
    --border: #E7E5E4;
    --border-strong: #D6D3D1;
    --text: #0F172A;
    --text-muted: #57534E;
    --muted: #57534E;
    --text-dim: #A8A29E;
    --primary: #A16207;
    --primary-hover: #CA8A04;
    --primary-tint: #FEF3C7;
    --accent: #CA8A04;
    --success-tint: #DCFCE7;
    --warning-tint: #FEF3C7;
    --danger-tint: #FEE2E2;
    --info-tint: #E0F2FE;
    --shadow-card: 0 1px 3px rgba(15,23,42,0.06);
    --shadow-md:   0 4px 12px rgba(15,23,42,0.08);
    --shadow-lg:   0 10px 30px rgba(15,23,42,0.10);
    --glow: 0 0 0 4px rgba(161,98,7,0.22);
    /* Sidebar STAYS DARK — uses default --sidebar-bg */
}

/* ===== RESET ===== */
*, *::before, *::after { box-sizing: border-box; }
html, body {
    margin: 0;
    padding: 0;
    height: 100%;
    overflow: hidden;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    color: var(--text);
    background: var(--bg);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    line-height: 1.5;
    font-size: 14px;
}

/* ===== TYPOGRAPHY ===== */
h1, h2, h3, h4, h5, h6 {
    font-family: 'Inter', sans-serif;
    color: var(--text);
    margin: 0 0 12px;
    font-weight: 700;
    letter-spacing: -0.015em;
    line-height: 1.25;
}
h1 { font-size: 1.75rem; font-weight: 700; letter-spacing: -0.025em; }
h2 { font-size: 1.25rem; font-weight: 600; }
h3 { font-size: 1.05rem; font-weight: 600; }
h4 { font-size: 0.92rem; font-weight: 600; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.04em; }
p { margin: 0 0 12px; color: var(--text); }
small, .text-sm { font-size: 0.8125rem; color: var(--text-muted); }
.text-muted { color: var(--text-muted); }
.subtitle { color: var(--text-muted); font-size: 0.92rem; margin: 4px 0 20px; }
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ===== CARDS ===== */
.card, .table-card {
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px;
    box-shadow: var(--shadow-card);
    margin-bottom: 16px;
}

/* ===== BUTTONS ===== */
.btn, .btn-primary, .btn-action, .login-btn, button[type=submit]:not(.toggle-password) {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 18px;
    border-radius: var(--radius-sm);
    border: none;
    background: var(--primary);
    color: #fff;
    font-family: inherit;
    font-size: 0.875rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.15s, transform 0.08s, box-shadow 0.15s;
    text-decoration: none;
    line-height: 1.2;
}
.btn:hover, .btn-primary:hover, .login-btn:hover { background: var(--primary-hover); }
.btn:active, .btn-primary:active { transform: scale(0.98); }

.btn-secondary, .btn.ghost, .btn-cancel {
    background: var(--card-bg);
    color: var(--text);
    border: 1px solid var(--border);
}
.btn-secondary:hover, .btn-cancel:hover { background: var(--bg); border-color: var(--border-strong); }

.btn-action.approve { background: var(--success); }
.btn-action.approve:hover { background: #15803D; }
.btn-action.reject  { background: var(--danger); }
.btn-action.reject:hover  { background: #B91C1C; }
.btn-action[disabled] { opacity: 0.5; cursor: not-allowed; }

.btn-export-pdf {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 14px;
    background: var(--danger-tint);
    color: var(--danger);
    border: 1px solid transparent;
    border-radius: var(--radius-sm);
    font-size: 0.85rem;
    font-weight: 600;
    text-decoration: none;
    cursor: pointer;
}
.btn-export-pdf:hover { background: #FECACA; text-decoration: none; }

/* ===== FORMS / INPUTS ===== */
input, select, textarea, .input {
    width: 100%;
    padding: 9px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--card-bg);
    color: var(--text);
    font-family: inherit;
    font-size: 0.875rem;
    margin-bottom: 12px;
    transition: border-color 0.15s, box-shadow 0.15s;
}
input:focus, select:focus, textarea:focus, .input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: var(--glow);
}
input[type=checkbox], input[type=radio] { width: auto; margin-right: 6px; }
input[readonly], input[disabled] { background: var(--bg); cursor: not-allowed; opacity: 0.85; }
label {
    display: block;
    color: var(--text-muted);
    font-size: 0.8125rem;
    font-weight: 500;
    margin-bottom: 6px;
}

/* ===== TABLES ===== */
.table-wrapper {
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow-x: auto;
    margin-bottom: 16px;
    box-shadow: var(--shadow-card);
    display: block;
}
table, .users-table, .history-table {
    width: 100%;
    border-collapse: collapse;
    background: var(--card-bg);
    font-size: 0.875rem;
}
th, td { padding: 12px 14px; text-align: left; border-bottom: 1px solid var(--border); }
th {
    background: var(--bg);
    color: var(--text-muted);
    font-weight: 600;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}
tr:last-child td { border-bottom: none; }
tbody tr { transition: background 0.12s; }
tbody tr:hover { background: var(--bg); }

.table-search {
    width: 100%;
    max-width: 320px;
    padding: 9px 12px 9px 36px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--card-bg) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%2364748B' stroke-width='2.5'%3E%3Ccircle cx='11' cy='11' r='7'/%3E%3Cline x1='21' y1='21' x2='16.65' y2='16.65'/%3E%3C/svg%3E") 12px center no-repeat;
    margin-bottom: 12px;
    font-size: 0.875rem;
}

/* ===== BADGES ===== */
.badge, .status, .status-badge {
    display: inline-flex;
    align-items: center;
    padding: 3px 10px;
    border-radius: var(--radius-full);
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: capitalize;
    letter-spacing: 0.02em;
    line-height: 1.4;
    background: var(--primary-tint);
    color: var(--primary);
}
.badge.active, .status.active, .badge.approved, .status.approved, .status-badge.approved, .status-badge.sent, .status-badge.admin_approved, .status-badge.hr_approved
    { background: var(--success-tint); color: var(--success); }
.badge.pending, .status.pending, .status-badge.pending, .status-badge.pending_admin, .status-badge.pending_manager
    { background: var(--warning-tint); color: #92400E; }
.badge.rejected, .status.rejected, .status-badge.rejected, .status-badge.failed
    { background: var(--danger-tint); color: var(--danger); }
.badge.inactive, .status.inactive, .status-badge.skipped
    { background: #F1F5F9; color: var(--text-muted); }
.status-badge.delivered { background: var(--info-tint); color: var(--info); }
.status-badge.read { background: #EDE9FE; color: #6D28D9; }

/* role status colors */
.status.admin   { background: var(--primary-tint); color: var(--primary); }
.status.manager { background: #FEF3C7; color: #92400E; }
.status.user    { background: #F1F5F9; color: var(--text-muted); }

/* Inline dash-card status flavors */
.dash-card.pending   { border-left: 4px solid var(--warning); }
.dash-card.approved  { border-left: 4px solid var(--success); }
.dash-card.rejected  { border-left: 4px solid var(--danger); }
.dash-card.warning   { border-left: 4px solid var(--warning); }
.dash-card.inventory { border-left: 4px solid var(--primary); }

/* ===== ALERTS / MESSAGES ===== */
.success-message, .alert-success {
    background: var(--success-tint);
    color: #14532D;
    border: 1px solid #BBF7D0;
    border-radius: var(--radius-sm);
    padding: 12px 16px;
    margin-bottom: 14px;
    font-size: 0.875rem;
}
.error-message, .alert-error {
    background: var(--danger-tint);
    color: #7F1D1D;
    border: 1px solid #FCA5A5;
    border-radius: var(--radius-sm);
    padding: 12px 16px;
    margin-bottom: 14px;
    font-size: 0.875rem;
}
.info-message {
    background: var(--info-tint);
    color: #075985;
    border: 1px solid #7DD3FC;
    border-radius: var(--radius-sm);
    padding: 12px 16px;
    margin-bottom: 14px;
    font-size: 0.875rem;
}

/* ===== MODALS ===== */
.modal-overlay, #deleteModal, #editModal, #decisionModal {
    position: fixed;
    inset: 0;
    background: rgba(15,23,42,0.55);
    backdrop-filter: blur(4px);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 9000;
    padding: 20px;
}
.modal-overlay.active { display: flex; }
.modal-box {
    background: var(--card-bg);
    border-radius: var(--radius-lg);
    padding: 24px;
    max-width: 320px;
    width: 100%;
    box-shadow: var(--shadow-lg);
    animation: modalPop 0.22s cubic-bezier(0.34, 1.56, 0.64, 1);
    border: 1px solid var(--border-color);
}
@keyframes modalPop { from { transform: scale(0.96); opacity: 0; } to { transform: scale(1); opacity: 1; } }
.modal-box h3 { margin-top: 0; margin-bottom: 12px; font-size: 1.15rem; }
.modal-actions {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
    margin-top: 18px;
}

/* ===== UTILITIES ===== */
.hidden { display: none !important; }
.flex { display: flex; }
.gap-2 { gap: 8px; }
.gap-3 { gap: 12px; }
.gap-4 { gap: 16px; }

/* ===== LOGIN PAGE (classic look — IGNORES theme system) ===== */
.login-wrapper {
    /* Pin variables to the original light/blue palette
       so no theme on <body> can leak in */
    --bg:        #F8FAFC;
    --bg-elevated:#FFFFFF;
    --card-bg:   #FFFFFF;
    --card:      #FFFFFF;
    --border:    #E2E8F0;
    --border-strong: #CBD5E1;
    --text:      #0F172A;
    --text-muted:#64748B;
    --muted:     #64748B;
    --primary:   #2563EB;
    --primary-hover: #1D4ED8;
    --primary-tint: #EFF6FF;
    --shadow-md: 0 4px 12px rgba(15,23,42,0.08);
    --radius-lg: 16px;

    display: grid;
    grid-template-columns: 1fr 1fr;
    min-height: 100vh;
    background: #F8FAFC;
    color: #0F172A;
}

.login-illustration {
    background: linear-gradient(135deg, #1E40AF, #2563EB);
    display: flex; align-items: center; justify-content: center;
    padding: 40px;
}
.login-illustration img { max-width: 100%; height: auto; }

.login-form { display: flex; align-items: center; justify-content: center; padding: 40px; background: #F8FAFC; }
.form-panel { width: 100%; max-width: 420px; }
.form-box {
    background: #FFFFFF;
    border: 1px solid #E2E8F0;
    border-radius: 16px;
    padding: 32px;
    box-shadow: 0 4px 12px rgba(15,23,42,0.08);
    color: #0F172A;
}
.form-logo { text-align: center; margin-bottom: 20px; }
.form-box h2 { font-size: 1.5rem; margin-bottom: 6px; color: #0F172A; }
.form-box .subtitle { margin-bottom: 24px; color: #64748B; }

.login-wrapper .input-group { position: relative; margin-bottom: 14px; }
.login-wrapper .input-group input {
    width: 100%; margin-bottom: 0; padding: 12px;
    background: #FFFFFF; color: #0F172A;
    border: 1px solid #E2E8F0; border-radius: 8px;
}
.login-wrapper .input-group label {
    position: absolute; left: 12px; top: 12px; pointer-events: none;
    transition: all 0.15s; background: #FFFFFF; padding: 0 4px;
    color: #64748B; font-size: 0.875rem;
}
.login-wrapper .input-group input:focus + label,
.login-wrapper .input-group input:not(:placeholder-shown) + label {
    top: -8px; font-size: 0.7rem; color: #2563EB;
}

.login-wrapper .remember-row { display: flex; align-items: center; gap: 6px; font-size: 0.8125rem; color: #64748B; margin-bottom: 14px; }
.login-wrapper .password-wrapper { position: relative; }
.login-wrapper .toggle-password { position: absolute; right: 12px; top: 12px; cursor: pointer; color: #64748B; }
.login-wrapper .login-btn {
    width: 100%; padding: 12px; font-size: 0.95rem; margin-top: 8px;
    background: #2563EB; color: #FFFFFF; border: none; border-radius: 8px;
    cursor: pointer; font-weight: 600;
}
.login-wrapper .login-btn:hover { background: #1D4ED8; }
.login-wrapper .error-message,
.login-wrapper .success-message { padding: 10px 12px; border-radius: 8px; margin-bottom: 12px; font-size: 0.875rem; }
.login-wrapper .error-message { background: #FEE2E2; color: #991B1B; border: 1px solid #FECACA; }
.login-wrapper .success-message { background: #DCFCE7; color: #166534; border: 1px solid #BBF7D0; }

@media (max-width: 768px) {
    .login-wrapper { grid-template-columns: 1fr; }
    .login-illustration { display: none; }
}

/* body.dark = no-op (default :root is already dark indigo) */
body.dark { /* default dark indigo from :root */ }
