/* css/style.css */
:root {
    --primary: #2563eb;
    --primary-dark: #1d4ed8;
    --primary-light: #dbeafe;
    --success: #16a34a;
    --success-light: #dcfce7;
    --warning: #d97706;
    --warning-light: #fef3c7;
    --danger: #dc2626;
    --danger-light: #fee2e2;
    --info: #0891b2;
    --info-light: #cffafe;
    --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;
    --sidebar-w: 260px;
    --header-h: 64px;
    --radius: 10px;
    --shadow: 0 1px 3px rgba(0,0,0,.1), 0 1px 2px rgba(0,0,0,.06);
    --shadow-md: 0 4px 6px -1px rgba(0,0,0,.1), 0 2px 4px -1px rgba(0,0,0,.06);
    --shadow-lg: 0 10px 15px -3px rgba(0,0,0,.1), 0 4px 6px -2px rgba(0,0,0,.05);
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 15px; }
body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background: var(--gray-100);
    color: var(--gray-800);
    min-height: 100vh;
}

/* ── Login page ── */
.auth-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #1e3a8a 0%, #2563eb 60%, #7c3aed 100%);
    padding: 1rem;
}
.auth-card {
    background: #fff;
    border-radius: 16px;
    box-shadow: var(--shadow-lg);
    width: 100%;
    max-width: 420px;
    padding: 2.5rem;
}
.auth-logo {
    text-align: center;
    margin-bottom: 2rem;
}
.auth-logo .logo-icon {
    width: 56px; height: 56px;
    background: var(--primary);
    border-radius: 14px;
    display: inline-flex; align-items: center; justify-content: center;
    margin-bottom: .75rem;
}
.auth-logo .logo-icon svg { color: #fff; }
.auth-logo h1 { font-size: 1.5rem; font-weight: 700; color: var(--gray-900); }
.auth-logo p { color: var(--gray-500); font-size: .875rem; }
.auth-card .demo-box {
    background: var(--primary-light);
    border: 1px solid #bfdbfe;
    border-radius: 8px;
    padding: .75rem 1rem;
    margin-bottom: 1.5rem;
    font-size: .8rem;
    color: var(--primary-dark);
}
.auth-card .demo-box strong { display: block; margin-bottom: .25rem; }

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

.sidebar {
    width: var(--sidebar-w);
    background: var(--gray-900);
    color: #fff;
    display: flex; flex-direction: column;
    position: fixed; top: 0; left: 0; bottom: 0;
    z-index: 100;
    overflow-y: auto;
    transition: transform .3s;
}
.sidebar-header {
    padding: 1.25rem 1.5rem;
    border-bottom: 1px solid rgba(255,255,255,.08);
    display: flex; align-items: center; gap: .75rem;
}
.sidebar-header .logo-sm {
    width: 36px; height: 36px;
    background: var(--primary);
    border-radius: 8px;
    display: flex; align-items: center; justify-content: center;
    flex-shrink: 0;
}
.sidebar-header h2 { font-size: 1rem; font-weight: 700; }
.sidebar-header p { font-size: .7rem; color: var(--gray-400); }

.sidebar-nav { flex: 1; padding: 1rem 0; }
.nav-section { margin-bottom: 1.5rem; }
.nav-label {
    font-size: .65rem; font-weight: 600; text-transform: uppercase;
    letter-spacing: .1em; color: var(--gray-500);
    padding: 0 1.5rem; margin-bottom: .5rem;
}
.nav-item {
    display: flex; align-items: center; gap: .75rem;
    padding: .65rem 1.5rem;
    color: var(--gray-400);
    text-decoration: none;
    font-size: .875rem;
    border-radius: 0;
    transition: all .15s;
    cursor: pointer;
    border: none; background: none; width: 100%; text-align: left;
}
.nav-item:hover { background: rgba(255,255,255,.06); color: #fff; }
.nav-item.active { background: var(--primary); color: #fff; }
.nav-item svg { width: 18px; height: 18px; flex-shrink: 0; }
.nav-item .badge {
    margin-left: auto;
    background: var(--danger);
    color: #fff;
    font-size: .65rem; font-weight: 700;
    padding: .15rem .45rem;
    border-radius: 999px;
}

.sidebar-footer {
    padding: 1rem 1.5rem;
    border-top: 1px solid rgba(255,255,255,.08);
}
.user-info { display: flex; align-items: center; gap: .75rem; }
.user-avatar {
    width: 36px; height: 36px;
    background: var(--primary);
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    font-weight: 700; font-size: .875rem;
    flex-shrink: 0;
}
.user-info-text h4 { font-size: .8rem; font-weight: 600; }
.user-info-text p { font-size: .7rem; color: var(--gray-400); }

/* ── Main Content ── */
.main-content {
    margin-left: var(--sidebar-w);
    flex: 1;
    display: flex; flex-direction: column;
    min-height: 100vh;
}
.topbar {
    height: var(--header-h);
    background: #fff;
    border-bottom: 1px solid var(--gray-200);
    display: flex; align-items: center; justify-content: space-between;
    padding: 0 2rem;
    position: sticky; top: 0; z-index: 50;
    box-shadow: var(--shadow);
}
.topbar-left h1 { font-size: 1.25rem; font-weight: 700; }
.topbar-left p { font-size: .8rem; color: var(--gray-500); }
.topbar-right { display: flex; align-items: center; gap: 1rem; }

.page-content { flex: 1; padding: 2rem; }

/* ── Cards ── */
.card {
    background: #fff;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    border: 1px solid var(--gray-200);
}
.card-header {
    padding: 1.25rem 1.5rem;
    border-bottom: 1px solid var(--gray-100);
    display: flex; align-items: center; justify-content: space-between;
    gap: 1rem;
}
.card-header h3 { font-size: 1rem; font-weight: 700; }
.card-body { padding: 1.5rem; }

/* ── Stats Grid ── */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
    margin-bottom: 2rem;
}
.stat-card {
    background: #fff;
    border-radius: var(--radius);
    padding: 1.25rem 1.5rem;
    box-shadow: var(--shadow);
    border: 1px solid var(--gray-200);
    display: flex; align-items: center; gap: 1rem;
}
.stat-icon {
    width: 48px; height: 48px;
    border-radius: 10px;
    display: flex; align-items: center; justify-content: center;
    flex-shrink: 0;
}
.stat-icon.blue { background: var(--primary-light); color: var(--primary); }
.stat-icon.green { background: var(--success-light); color: var(--success); }
.stat-icon.yellow { background: var(--warning-light); color: var(--warning); }
.stat-icon.red { background: var(--danger-light); color: var(--danger); }
.stat-value { font-size: 1.75rem; font-weight: 800; line-height: 1; }
.stat-label { font-size: .8rem; color: var(--gray-500); margin-top: .25rem; }

/* ── Forms ── */
.form-group { margin-bottom: 1.25rem; }
.form-label {
    display: block;
    font-size: .8rem; font-weight: 600;
    color: var(--gray-700);
    margin-bottom: .4rem;
}
.form-control {
    display: block; width: 100%;
    padding: .55rem .85rem;
    border: 1.5px solid var(--gray-300);
    border-radius: 7px;
    font-size: .875rem;
    color: var(--gray-800);
    background: #fff;
    transition: border-color .15s, box-shadow .15s;
    outline: none;
}
.form-control:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(37,99,235,.15);
}
.form-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
}

/* ── Buttons ── */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: .5rem;
    padding: .55rem 1.25rem;
    border-radius: 7px;
    font-size: .875rem; font-weight: 600;
    border: 1.5px solid transparent;
    cursor: pointer;
    transition: all .15s;
    text-decoration: none;
    white-space: nowrap;
}
.btn-primary { background: var(--primary); color: #fff; border-color: var(--primary); }
.btn-primary:hover { background: var(--primary-dark); border-color: var(--primary-dark); }
.btn-success { background: var(--success); color: #fff; }
.btn-success:hover { background: #15803d; }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { background: #b91c1c; }
.btn-warning { background: var(--warning); color: #fff; }
.btn-outline { background: transparent; border-color: var(--gray-300); color: var(--gray-700); }
.btn-outline:hover { background: var(--gray-50); }
.btn-sm { padding: .35rem .8rem; font-size: .8rem; }
.btn-lg { padding: .75rem 1.75rem; font-size: 1rem; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

/* ── Badges/Pills ── */
.badge-pill {
    display: inline-flex; align-items: center;
    padding: .25rem .7rem;
    border-radius: 999px;
    font-size: .75rem; font-weight: 600;
}
.badge-draft { background: var(--gray-100); color: var(--gray-600); }
.badge-submitted { background: var(--info-light); color: var(--info); }
.badge-approved { background: var(--success-light); color: var(--success); }
.badge-rejected { background: var(--danger-light); color: var(--danger); }

/* ── Table ── */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: .875rem; }
thead th {
    background: var(--gray-50);
    padding: .65rem 1rem;
    font-size: .75rem; font-weight: 700;
    text-transform: uppercase; letter-spacing: .05em;
    color: var(--gray-500);
    border-bottom: 2px solid var(--gray-200);
    text-align: left; white-space: nowrap;
}
tbody td {
    padding: .75rem 1rem;
    border-bottom: 1px solid var(--gray-100);
    vertical-align: middle;
}
tbody tr:hover { background: var(--gray-50); }
tbody tr:last-child td { border-bottom: none; }
tfoot td {
    padding: .75rem 1rem;
    font-weight: 700;
    background: var(--gray-50);
    border-top: 2px solid var(--gray-200);
}

/* ── Timesheet Editor ── */
.timesheet-header {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 1rem;
    margin-bottom: 1.5rem;
}
.ts-meta { display: flex; flex-direction: column; gap: .25rem; }
.ts-meta label { font-size: .75rem; font-weight: 600; color: var(--gray-500); text-transform: uppercase; }
.ts-meta span { font-size: .95rem; font-weight: 600; }

.ts-table-wrap { overflow-x: auto; }
.ts-table { width: 100%; border-collapse: collapse; min-width: 900px; }
.ts-table thead th {
    background: var(--primary);
    color: #fff;
    padding: .65rem .75rem;
    font-size: .75rem; font-weight: 700;
    text-transform: uppercase; letter-spacing: .04em;
    white-space: nowrap;
}
.ts-table tbody td {
    padding: .4rem .5rem;
    border-bottom: 1px solid var(--gray-200);
    vertical-align: middle;
}
.ts-table tbody tr:hover { background: #f0f4ff; }
.ts-table tfoot td {
    background: var(--gray-800);
    color: #fff;
    font-weight: 700;
    padding: .65rem .75rem;
}
.ts-table .day-label {
    font-weight: 700; font-size: .8rem;
    color: var(--gray-700);
    white-space: nowrap;
}
.ts-table .weekend td { background: #fffbeb; }
.ts-table input, .ts-table select {
    width: 100%; padding: .3rem .5rem;
    border: 1px solid var(--gray-300); border-radius: 5px;
    font-size: .8rem; background: #fff;
}
.ts-table input:focus, .ts-table select:focus {
    border-color: var(--primary); outline: none;
    box-shadow: 0 0 0 2px rgba(37,99,235,.15);
}
.ts-table .hours-cell {
    text-align: right; font-weight: 700; font-size: .875rem;
    color: var(--gray-700); white-space: nowrap;
    min-width: 70px;
}
.ts-table .overtime-cell { color: var(--warning); }
.ts-table .total-cell { color: var(--primary); }

.summary-box {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 1rem;
    background: var(--gray-50);
    border: 1px solid var(--gray-200);
    border-radius: var(--radius);
    padding: 1.25rem;
    margin-top: 1.5rem;
}
.summary-item { text-align: center; }
.summary-item .val { font-size: 1.75rem; font-weight: 800; }
.summary-item .lbl { font-size: .75rem; color: var(--gray-500); font-weight: 600; text-transform: uppercase; }
.summary-item.warn .val { color: var(--warning); }
.summary-item.danger .val { color: var(--danger); }
.summary-item.success .val { color: var(--success); }

/* ── Week Tabs ── */
.week-tabs {
    display: flex; gap: .5rem;
    border-bottom: 2px solid var(--gray-200);
    margin-bottom: 1.5rem;
}
.week-tab {
    padding: .65rem 1.25rem;
    font-size: .875rem; font-weight: 600;
    color: var(--gray-500);
    cursor: pointer;
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
    transition: all .15s;
}
.week-tab:hover { color: var(--primary); }
.week-tab.active { color: var(--primary); border-bottom-color: var(--primary); }
.week-tab .status-dot {
    display: inline-block;
    width: 7px; height: 7px;
    border-radius: 50%;
    margin-left: .4rem;
    vertical-align: middle;
}

/* ── Progress bar ── */
.progress-bar {
    height: 8px;
    background: var(--gray-200);
    border-radius: 999px;
    overflow: hidden;
    margin-top: .5rem;
}
.progress-fill {
    height: 100%;
    border-radius: 999px;
    background: var(--primary);
    transition: width .4s;
}
.progress-fill.warn { background: var(--warning); }
.progress-fill.danger { background: var(--danger); }

/* ── Modals ── */
.modal-backdrop {
    position: fixed; inset: 0;
    background: rgba(0,0,0,.5);
    z-index: 200;
    display: none; align-items: center; justify-content: center;
}
.modal-backdrop.show { display: flex; }
.modal {
    background: #fff;
    border-radius: 14px;
    box-shadow: var(--shadow-lg);
    width: 100%; max-width: 520px;
    max-height: 90vh;
    overflow-y: auto;
    margin: 1rem;
}
.modal-header {
    padding: 1.25rem 1.5rem;
    border-bottom: 1px solid var(--gray-200);
    display: flex; align-items: center; justify-content: space-between;
}
.modal-header h3 { font-size: 1.1rem; font-weight: 700; }
.modal-close {
    width: 32px; height: 32px;
    border-radius: 8px;
    border: none; background: none;
    cursor: pointer; color: var(--gray-400);
    display: flex; align-items: center; justify-content: center;
}
.modal-close:hover { background: var(--gray-100); color: var(--gray-700); }
.modal-body { padding: 1.5rem; }
.modal-footer {
    padding: 1rem 1.5rem;
    border-top: 1px solid var(--gray-200);
    display: flex; justify-content: flex-end; gap: .75rem;
}

/* ── Toast notifications ── */
#toast-container {
    position: fixed;
    bottom: 1.5rem; right: 1.5rem;
    z-index: 9999;
    display: flex; flex-direction: column; gap: .5rem;
}
.toast {
    background: var(--gray-900);
    color: #fff;
    padding: .85rem 1.25rem;
    border-radius: 10px;
    box-shadow: var(--shadow-lg);
    font-size: .875rem;
    display: flex; align-items: center; gap: .75rem;
    animation: slideIn .3s ease;
    min-width: 260px;
}
.toast.success { border-left: 4px solid var(--success); }
.toast.error { border-left: 4px solid var(--danger); }
.toast.info { border-left: 4px solid var(--info); }
@keyframes slideIn { from { transform: translateX(100%); opacity: 0; } to { transform: translateX(0); opacity: 1; } }

/* ── Alerts ── */
.alert {
    padding: .85rem 1.1rem;
    border-radius: 8px;
    font-size: .875rem;
    display: flex; align-items: flex-start; gap: .75rem;
    margin-bottom: 1rem;
}
.alert-info { background: var(--info-light); color: #0e7490; border: 1px solid #a5f3fc; }
.alert-warning { background: var(--warning-light); color: #92400e; border: 1px solid #fde68a; }
.alert-error { background: var(--danger-light); color: #991b1b; border: 1px solid #fca5a5; }
.alert-success { background: var(--success-light); color: #166534; border: 1px solid #86efac; }

/* ── Empty state ── */
.empty-state {
    text-align: center;
    padding: 4rem 2rem;
    color: var(--gray-400);
}
.empty-state svg { width: 64px; height: 64px; margin-bottom: 1rem; opacity: .4; }
.empty-state h3 { font-size: 1.1rem; color: var(--gray-600); margin-bottom: .5rem; }
.empty-state p { font-size: .875rem; }

/* ── Utility ── */
.flex { display: flex; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-2 { gap: .5rem; }
.gap-3 { gap: .75rem; }
.mb-4 { margin-bottom: 1rem; }
.mb-6 { margin-bottom: 1.5rem; }
.text-sm { font-size: .875rem; }
.text-xs { font-size: .75rem; }
.text-muted { color: var(--gray-500); }
.text-right { text-align: right; }
.font-bold { font-weight: 700; }
.w-full { width: 100%; }
.hidden { display: none !important; }

/* ── Loader ── */
.spinner {
    width: 20px; height: 20px;
    border: 2px solid rgba(255,255,255,.3);
    border-top-color: #fff;
    border-radius: 50%;
    animation: spin .7s linear infinite;
    display: inline-block;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Responsive ── */
@media (max-width: 768px) {
    .sidebar { transform: translateX(-100%); }
    .sidebar.open { transform: translateX(0); }
    .main-content { margin-left: 0; }
    .stats-grid { grid-template-columns: repeat(2, 1fr); }
    .summary-box { grid-template-columns: repeat(2, 1fr); }
    .topbar { padding: 0 1rem; }
    .page-content { padding: 1rem; }
}

/* ── Print ── */
@media print {
    .sidebar, .topbar, .btn, .week-tabs, .no-print { display: none !important; }
    .main-content { margin-left: 0; }
    .card { box-shadow: none; border: 1px solid #000; }
    .ts-table thead th { background: #000 !important; color: #fff !important; -webkit-print-color-adjust: exact; }
}

/* ── Settings toggle ── */
.toggle-track { display: block; }
.toggle-track::before {
    content: '';
    position: absolute;
    top: 3px; left: 3px;
    width: 18px; height: 18px;
    background: #fff;
    border-radius: 50%;
    transition: .3s;
    box-shadow: 0 1px 3px rgba(0,0,0,.2);
}
input[type=checkbox]:checked + .toggle-track { background: var(--primary) !important; }
input[type=checkbox]:checked + .toggle-track::before { transform: translateX(20px); }

/* ── Report charts ── */
canvas { max-width: 100%; }

/* ── Export preview ── */
.export-preview table td { font-size: .78rem; white-space: nowrap; }

/* ── Notification dot ── */
.notif-dot {
    display: inline-block;
    width: 8px; height: 8px;
    background: var(--primary);
    border-radius: 50%;
    margin-left: .35rem;
    vertical-align: middle;
}

/* ── Responsive 2-col grid ── */
@media (max-width: 900px) {
    div[style*="grid-template-columns: 280px"] {
        grid-template-columns: 1fr !important;
    }
    div[style*="grid-template-columns: 1fr 1fr"] {
        grid-template-columns: 1fr !important;
    }
}

/* ── Topbar burger (mobile) ── */
@media (max-width: 768px) {
    #burger { display: flex !important; }
}

/* ── Sidebar sign-out link ── */
.sidebar-signout {
    display: flex;
    align-items: center;
    gap: .5rem;
    color: var(--gray-400);
    text-decoration: none;
    font-size: .8rem;
    margin-top: .75rem;
    padding: .4rem .5rem;
    border-radius: 6px;
    transition: background .15s;
}
.sidebar-signout:hover { background: rgba(255,255,255,.06); }

/* ── Topbar burger always visible on mobile ── */
#burger {
    display: none;
    background: none;
    border: none;
    cursor: pointer;
    padding: .4rem;
}
@media (max-width: 768px) { #burger { display: flex; } }

/* ── Audit log table ── */
.audit-badge {
    font-size: .7rem;
    font-weight: 700;
    padding: .15rem .5rem;
    border-radius: 4px;
    text-transform: uppercase;
}
.audit-login     { background: #dbeafe; color: #1d4ed8; }
.audit-logout    { background: #f3f4f6; color: #6b7280; }
.audit-create    { background: #dcfce7; color: #15803d; }
.audit-update    { background: #fef3c7; color: #92400e; }
.audit-delete    { background: #fee2e2; color: #991b1b; }
.audit-pwd_reset { background: #ede9fe; color: #6d28d9; }
.audit-submit    { background: #cffafe; color: #0e7490; }
.audit-approve   { background: #dcfce7; color: #15803d; }
.audit-reject    { background: #fee2e2; color: #991b1b; }
.audit-failure   { background: #fee2e2; color: #991b1b; }
