/* ============================================================
   FLAT UI DESIGN SYSTEM — tokens
   ============================================================ */
:root {
    /* Brand */
    --primary-color: #4f46e5;
    --primary-dark: #4338ca;
    --primary-light: #eef2ff;
    --secondary-color: #6366f1;
    --secondary-dark: #4f46e5;

    /* Semantic */
    --success-color: #10b981;
    --success-dark: #059669;
    --success-light: #d1fae5;
    --danger-color: #ef4444;
    --danger-dark: #dc2626;
    --danger-light: #fee2e2;
    --warning-color: #f59e0b;
    --warning-dark: #d97706;
    --warning-light: #fef3c7;
    --info-color: #3b82f6;
    --info-dark: #2563eb;
    --info-light: #dbeafe;

    /* Neutrals */
    --dark-color: #0f172a;
    --gray-color: #64748b;
    --light-gray: #f8fafc;
    --border-color: #e2e8f0;
    --white: #ffffff;
    --text-color: #334155;

    /* Layout */
    --sidebar-width: 280px;
    --header-height: 70px;

    /* Spacing grid (8px base / 16px & 24px rhythm) */
    --space-1: 8px;
    --space-2: 16px;
    --space-3: 24px;
    --space-4: 32px;

    /* Radius — flat UI, 6-8px */
    --radius-sm: 6px;
    --radius-md: 8px;
    --radius-lg: 8px;

    /* Subtle elevation only — flat design */
    --shadow-flat: 0 1px 2px 0 rgba(15, 23, 42, 0.05);
    --shadow-flat-hover: 0 2px 6px 0 rgba(15, 23, 42, 0.08);

    --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;

    color-scheme: light;
}

/* Dark mode token overrides */
[data-theme="dark"] {
    --dark-color: #f1f5f9;
    --gray-color: #94a3b8;
    --light-gray: #1e293b;
    --border-color: #2b3a52;
    --white: #16213a;
    --text-color: #cbd5e1;
    --primary-light: #1e2350;
    --success-light: #0f2e26;
    --danger-light: #3a1414;
    --warning-light: #3a2a0d;
    --info-light: #0d2545;
    color-scheme: dark;
}

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

html { scroll-behavior: smooth; }

body {
    font-family: var(--font-sans);
    background: var(--light-gray);
    overflow-x: hidden;
    color: var(--text-color);
    -webkit-font-smoothing: antialiased;
    font-size: 15px;
    line-height: 1.6;
    transition: background 0.2s ease, color 0.2s ease;
}

[data-theme="dark"] body { background: #0b1220; }

.sidebar-header h3 .brand-accent {
    color: #e11d48;
    font-weight: 800;
}

/* Scrollbar */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 10px; }
::-webkit-scrollbar-thumb:hover { background: #94a3b8; }

/* Theme toggle */
.theme-toggle {
    width: 40px;
    height: 40px;
    border-radius: var(--radius-md);
    border: 1px solid var(--border-color);
    background: var(--white);
    color: var(--gray-color);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 1rem;
    transition: all 0.15s ease;
}
.theme-toggle:hover { color: var(--primary-color); border-color: var(--primary-color); }

/* Pagination */
.pagination-custom {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: var(--space-2);
    margin-top: var(--space-2);
    padding-top: var(--space-2);
    border-top: 1px solid var(--border-color);
}

.pagination-info { font-size: 0.85rem; color: var(--gray-color); font-weight: 500; }

.pagination-buttons { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }

.pagination-buttons button,
.pagination-buttons a {
    padding: 6px 12px;
    border: 1px solid var(--border-color);
    background: var(--white);
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all 0.15s ease;
    text-decoration: none;
    color: var(--primary-color);
    font-size: 0.875rem;
    font-weight: 500;
}

.pagination-buttons button:hover:not(:disabled),
.pagination-buttons a:hover { background: var(--light-gray); border-color: #cbd5e1; }
.pagination-buttons button:disabled { opacity: 0.5; cursor: not-allowed; }
.pagination-buttons .active { background: var(--primary-color); color: white; border-color: var(--primary-color); }

.page-select {
    padding: 6px 12px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    background: var(--white);
    cursor: pointer;
    font-size: 0.875rem;
    color: var(--text-color);
    font-weight: 500;
}

/* Detail View */
.detail-view { max-height: 500px; overflow-y: auto; }
.detail-row {
    margin-bottom: var(--space-2);
    display: flex;
    flex-wrap: wrap;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: var(--space-2);
    font-size: 0.9rem;
}
.detail-label { font-weight: 600; width: 35%; color: var(--gray-color); }
.detail-value { flex: 1; min-width: 60%; font-weight: 500; word-break: break-word; color: var(--dark-color); }

/* Spinner */
.spinner-custom {
    display: inline-block;
    width: 30px;
    height: 30px;
    border: 3px solid rgba(79, 70, 229, 0.15);
    border-radius: 50%;
    border-top-color: var(--primary-color);
    animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Login Container */
.login-container {
    min-height: 100vh;
    background: var(--dark-color);
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    overflow: hidden;
    padding: var(--space-2);
}

.login-card {
    background: var(--white);
    border-radius: var(--radius-lg);
    border: 1px solid rgba(255,255,255,0.06);
    box-shadow: 0 8px 24px -8px rgba(0,0,0,0.35);
    padding: var(--space-4) var(--space-3);
    width: 100%;
    max-width: 420px;
    z-index: 1;
}

/* Sidebar */
.sidebar {
    position: fixed;
    left: 0;
    top: 0;
    width: var(--sidebar-width);
    height: 100vh;
    background: var(--dark-color);
    color: white;
    z-index: 1000;
    overflow-y: auto;
    border-right: 1px solid #1e293b;
    transition: transform 0.25s ease;
}
[data-theme="dark"] .sidebar { background: #060b17; border-right-color: #1a2740; }

.sidebar-header { padding: var(--space-3) var(--space-2); border-bottom: 1px solid rgba(255,255,255,0.06); text-align: center; }
.sidebar-header h3 { font-weight: 700; font-size: 1.25rem; margin-bottom: 8px; letter-spacing: 0.02em; }
.sidebar-header p { font-size: 0.8rem; color: #94a3b8; margin-bottom: 12px; }

.sidebar-menu { padding: var(--space-2) 0; }

.menu-item {
    padding: 12px 16px;
    margin: 4px 12px;
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    gap: 12px;
    color: #94a3b8;
    cursor: pointer;
    transition: background 0.15s ease, color 0.15s ease;
    font-size: 0.875rem;
    font-weight: 500;
}
.menu-item:hover { background: #1e293b; color: white; }
.menu-item.active { background: var(--primary-color); color: white; font-weight: 600; }
.menu-item i { width: 20px; text-align: center; font-size: 1rem; }

.menu-badge {
    background: var(--danger-color);
    color: white;
    border-radius: 20px;
    padding: 2px 8px;
    font-size: 11px;
    margin-left: auto;
    font-weight: 600;
}

.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.5);
    z-index: 999;
}
.sidebar-overlay.show { display: block; }

/* Main Content */
.main-content {
    margin-left: var(--sidebar-width);
    padding: var(--space-3) var(--space-4);
    min-height: 100vh;
    transition: margin 0.25s ease;
}

/* Top Navbar */
.top-navbar {
    background: var(--white);
    border-radius: var(--radius-lg);
    padding: var(--space-2) var(--space-3);
    margin-bottom: var(--space-4);
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: var(--space-2);
    flex-wrap: wrap;
    box-shadow: var(--shadow-flat);
    border: 1px solid var(--border-color);
    position: sticky;
    top: var(--space-2);
    z-index: 99;
}

.page-title { font-size: 1.25rem; font-weight: 700; color: var(--dark-color); }
.user-info { display: flex; align-items: center; gap: var(--space-2); flex-wrap: wrap; }

.user-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--primary-color);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: bold;
    font-size: 1rem;
    flex-shrink: 0;
}

.notification-icon { position: relative; cursor: pointer; font-size: 1.25rem; color: var(--gray-color); transition: color 0.15s; }
.notification-icon:hover { color: var(--primary-color); }
.notification-badge {
    position: absolute; top: -6px; right: -6px;
    background: var(--danger-color); color: white; border-radius: 50%;
    width: 16px; height: 16px; font-size: 9px;
    display: flex; align-items: center; justify-content: center;
    font-weight: bold; border: 2px solid var(--white);
}

/* Stat & Content Cards */
.stat-card {
    background: var(--white);
    border-radius: var(--radius-lg);
    padding: var(--space-3);
    margin-bottom: var(--space-3);
    transition: border-color 0.15s ease, transform 0.15s ease;
    cursor: pointer;
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow-flat);
    position: relative;
    overflow: hidden;
}
.stat-card:hover { transform: translateY(-2px); border-color: var(--primary-color); box-shadow: var(--shadow-flat-hover); }

.stat-icon {
    width: 48px; height: 48px; border-radius: var(--radius-md);
    display: flex; align-items: center; justify-content: center;
    font-size: 1.5rem; color: white; margin-bottom: var(--space-2);
}
.stat-value { font-size: 1.875rem; font-weight: 700; margin-bottom: 4px; color: var(--dark-color); }
.stat-label { color: var(--gray-color); font-size: 0.875rem; font-weight: 500; }

.content-card {
    background: var(--white);
    border-radius: var(--radius-lg);
    padding: var(--space-3);
    margin-bottom: var(--space-3);
    box-shadow: var(--shadow-flat);
    border: 1px solid var(--border-color);
}

.card-header-custom {
    display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: var(--space-1);
    margin-bottom: var(--space-3); padding-bottom: var(--space-2); border-bottom: 1px solid var(--border-color);
}
.card-header-custom h5 { font-weight: 600; margin: 0; color: var(--dark-color); font-size: 1.125rem; }

/* Buttons */
.btn-custom {
    padding: 10px 18px;
    border-radius: var(--radius-md);
    font-weight: 500;
    font-size: 0.875rem;
    transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
    border: 1px solid transparent;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}
.btn-primary-custom { background: var(--primary-color); color: white; }
.btn-primary-custom:hover { background: var(--primary-dark); color: white; }
.btn-outline-custom { background: var(--white); border-color: #cbd5e1; color: var(--text-color); }
.btn-outline-custom:hover { background: var(--light-gray); color: var(--dark-color); }
.hp-processing { opacity: 0.75; cursor: not-allowed !important; pointer-events: none; }

/* Tables */
.table-responsive-custom { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.table-custom { width: 100%; border-collapse: collapse; text-align: left; }
.table-custom thead th {
    background: var(--light-gray);
    padding: 12px 16px;
    font-weight: 600;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--gray-color);
    border-bottom: 1px solid var(--border-color);
    border-top: 1px solid var(--border-color);
    white-space: nowrap;
}
.table-custom tbody td {
    padding: 14px 16px;
    border-bottom: 1px solid var(--border-color);
    vertical-align: middle;
    font-size: 0.875rem;
    color: var(--text-color);
}
.table-custom tbody tr:hover { background: var(--light-gray); }

/* Badges */
.badge-status {
    padding: 4px 10px;
    border-radius: var(--radius-sm);
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.025em;
    display: inline-block;
}
.badge-pending { background: var(--warning-light); color: var(--warning-dark); border: 1px solid #fde68a; }
.badge-approved { background: var(--success-light); color: var(--success-dark); border: 1px solid #a7f3d0; }
.badge-rejected { background: var(--danger-light); color: var(--danger-dark); border: 1px solid #fecaca; }
.badge-cancelled { background: #e2e8f0; color: #475569; border: 1px solid #cbd5e1; }

/* Actions */
.action-btn {
    padding: 6px 10px;
    margin: 0 2px;
    border-radius: var(--radius-sm);
    font-size: 0.75rem;
    font-weight: 500;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    cursor: pointer;
    border: 1px solid transparent;
    transition: background 0.15s ease;
    text-decoration: none;
}
.action-view { background: var(--info-light); color: var(--info-dark); } .action-view:hover { background: #bae6fd; }
.action-edit { background: var(--warning-light); color: var(--warning-dark); } .action-edit:hover { background: #fde68a; }
.action-delete { background: var(--danger-light); color: var(--danger-dark); } .action-delete:hover { background: #fecaca; }
.action-pdf { background: #f3f4f6; color: #4b5563; border-color: #d1d5db; } .action-pdf:hover { background: #e5e7eb; }

/* Filter Bar */
.filter-bar {
    background: var(--light-gray);
    padding: var(--space-2);
    border-radius: var(--radius-lg);
    margin-bottom: var(--space-3);
    border: 1px solid var(--border-color);
}
.filter-bar label {
    font-size: 0.75rem; font-weight: 600; color: var(--gray-color);
    text-transform: uppercase; letter-spacing: 0.05em; margin-bottom: 6px; display: block;
}

/* Modals */
.modal-custom {
    display: none;
    position: fixed;
    top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(15, 23, 42, 0.55);
    z-index: 9999;
    align-items: center;
    justify-content: center;
    padding: var(--space-2);
}
.modal-content-custom {
    background: var(--white);
    border-radius: var(--radius-lg);
    width: 100%;
    max-width: 650px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 12px 32px -8px rgba(0,0,0,0.25);
    animation: modalSlideIn 0.2s ease;
}
@keyframes modalSlideIn {
    from { opacity: 0; transform: translateY(-12px); }
    to { opacity: 1; transform: translateY(0); }
}
.modal-header-custom {
    padding: var(--space-2) var(--space-3);
    border-bottom: 1px solid var(--border-color);
    display: flex; justify-content: space-between; align-items: center;
    background: var(--white);
    position: sticky; top: 0; z-index: 10;
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
}
.modal-header-custom h5 { margin: 0; font-weight: 600; color: var(--dark-color); font-size: 1.125rem; }
.modal-header-custom button { background: none; border: none; font-size: 22px; cursor: pointer; color: var(--gray-color); }
.modal-body-custom { padding: var(--space-3); }
.modal-footer-custom {
    padding: var(--space-2) var(--space-3);
    border-top: 1px solid var(--border-color);
    display: flex; justify-content: flex-end; gap: var(--space-1); flex-wrap: wrap;
    background: var(--light-gray);
    position: sticky; bottom: 0;
    border-radius: 0 0 var(--radius-lg) var(--radius-lg);
}

/* Form Controls */
.form-group { margin-bottom: var(--space-2); }
.form-group label { display: block; margin-bottom: 6px; font-weight: 500; color: var(--text-color); font-size: 0.875rem; }
.form-control-custom {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid #cbd5e1;
    border-radius: var(--radius-md);
    font-size: 0.875rem;
    font-family: var(--font-sans);
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
    background-color: var(--white);
    color: var(--text-color);
}
.form-control-custom:focus { outline: none; border-color: var(--primary-color); box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.15); }

/* Mentions */
.mention-suggestions {
    position: absolute;
    background: var(--white);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    max-height: 200px;
    overflow-y: auto;
    z-index: 100000;
    min-width: 250px;
    box-shadow: 0 8px 20px -6px rgba(0,0,0,0.15);
}
.mention-suggestion-item { padding: 10px 16px; cursor: pointer; border-bottom: 1px solid var(--border-color); font-size: 0.875rem; }
.mention-suggestion-item:hover { background: var(--light-gray); }

/* Responsive */
@media (max-width: 991px) {
    .sidebar { transform: translateX(-100%); }
    .sidebar.open { transform: translateX(0); }
    .main-content { margin-left: 0; padding: var(--space-2) var(--space-3); }
}

/* =========================================================================
   ADMINISTRATOR SETTINGS & CAMBODIAN PAYSLIP DETAILS STYLING
   ========================================================================= */
#viewModal .modal-content-custom {
    max-width: 860px !important;
    width: 96% !important;
}

.settings-tab-pane {
    animation: modalSlideIn 0.2s ease-in-out;
}

.payslip-modal-container {
    color: #0f172a;
    font-family: 'Inter', 'Kantumruy Pro', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

.payslip-modal-container table {
    vertical-align: middle;
}

.payslip-modal-container .badge {
    font-size: 11.5px;
    font-weight: 600;
}

/* =========================================================================
   SESSION EXPIRING WARNING MODAL (Enhanced - Pixel-perfect matching screenshot)
   ========================================================================= */
.session-modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(15, 23, 42, 0.65);
    backdrop-filter: blur(5px);
    -webkit-backdrop-filter: blur(5px);
    z-index: 9999999;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 20px;
    box-sizing: border-box;
    animation: sessionFadeIn 0.2s ease-out;
}

@keyframes sessionFadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.session-modal-card {
    background: #ffffff;
    border-radius: 28px;
    max-width: 370px;
    width: 100%;
    padding: 38px 28px 26px;
    text-align: center;
    box-shadow: 0 25px 60px -12px rgba(0, 0, 0, 0.35), 0 0 0 1px rgba(0, 0, 0, 0.04);
    animation: sessionSlideUp 0.25s cubic-bezier(0.16, 1, 0.3, 1);
    box-sizing: border-box;
    position: relative;
}

@keyframes sessionSlideUp {
    from { transform: translateY(18px) scale(0.96); opacity: 0; }
    to { transform: translateY(0) scale(1); opacity: 1; }
}

.session-icon-wrap {
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 16px;
}

.session-modal-title {
    font-size: 24px;
    font-weight: 700;
    color: #111827;
    margin: 0 0 10px 0;
    letter-spacing: -0.3px;
    font-family: inherit;
}

.session-modal-text {
    font-size: 15px;
    line-height: 1.45;
    color: #64748b;
    margin: 0 auto 18px;
    max-width: 290px;
    font-weight: 400;
    font-family: inherit;
}

.session-timer-text {
    font-size: 48px;
    font-weight: 800;
    color: #ef4444;
    line-height: 1;
    margin: 0 0 28px 0;
    letter-spacing: -0.5px;
    font-variant-numeric: tabular-nums;
    font-family: inherit;
}

.session-btn-stay {
    width: 100%;
    padding: 14px 24px;
    background: #1677ff;
    color: #ffffff;
    font-size: 16px;
    font-weight: 600;
    border: none;
    border-radius: 9999px;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    box-shadow: 0 4px 16px rgba(22, 119, 255, 0.4);
    transition: background 0.15s ease, box-shadow 0.15s ease, transform 0.1s ease;
    outline: none;
    font-family: inherit;
}

.session-btn-stay:hover {
    background: #0958d9;
    box-shadow: 0 6px 20px rgba(22, 119, 255, 0.5);
    transform: translateY(-1px);
}

.session-btn-stay:active {
    transform: translateY(0);
}

.session-logout-wrap {
    margin-top: 14px;
}

.session-btn-logout {
    background: transparent;
    border: none;
    color: #64748b;
    font-size: 15px;
    font-weight: 500;
    cursor: pointer;
    transition: color 0.15s ease;
    padding: 4px 10px;
    outline: none;
    font-family: inherit;
}

.session-btn-logout:hover {
    color: #111827;
}

