/* ══════════════════════════════════════
   WorkPulse — Design System
   ══════════════════════════════════════ */

:root {
    /* Primary Palette */
    --deep-blue: #1E3A5F;
    --deep-blue-dark: #152C4A;
    --deep-blue-light: #2A4F7A;
    --accent-orange: #FF6B35;
    --accent-orange-hover: #E85A28;
    --accent-orange-glow: rgba(255, 107, 53, 0.15);

    /* Semantic Colors */
    --green: #22C55E;
    --green-bg: rgba(34, 197, 94, 0.12);
    --red: #EF4444;
    --red-bg: rgba(239, 68, 68, 0.12);
    --orange: #F59E0B;
    --orange-bg: rgba(245, 158, 11, 0.12);
    --blue: #3B82F6;
    --blue-bg: rgba(59, 130, 246, 0.12);
    --gray: #94A3B8;
    --gray-bg: rgba(148, 163, 184, 0.12);

    /* Surface Colors */
    --bg-primary: #F1F5F9;
    --bg-card: #FFFFFF;
    --bg-card-hover: #F8FAFC;
    --border-color: #E2E8F0;
    --border-light: #F1F5F9;
    
    /* Text */
    --text-primary: #0F172A;
    --text-secondary: #475569;
    --text-muted: #94A3B8;
    --text-inverse: #FFFFFF;

    /* Sidebar */
    --sidebar-width: 260px;
    --sidebar-collapsed: 0px;
    --sidebar-bg: var(--deep-blue-dark);
    --sidebar-text: rgba(255,255,255,0.7);
    --sidebar-text-active: #FFFFFF;
    --sidebar-hover: rgba(255,255,255,0.08);
    --sidebar-active-bg: var(--accent-orange);

    /* Sizing */
    --top-bar-height: 64px;
    --radius: 12px;
    --radius-sm: 8px;
    --radius-xs: 6px;

    /* Shadows */
    --shadow-sm: 0 1px 3px rgba(15, 23, 42, 0.06);
    --shadow-md: 0 4px 12px rgba(15, 23, 42, 0.08);
    --shadow-lg: 0 12px 32px rgba(15, 23, 42, 0.12);
    --shadow-card: 0 1px 3px rgba(15, 23, 42, 0.04), 0 1px 2px rgba(15, 23, 42, 0.06);

    /* Typography */
    --font-main: 'DM Sans', -apple-system, BlinkMacSystemFont, sans-serif;
    --font-mono: 'JetBrains Mono', monospace;
}

/* ══════ Reset ══════ */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 15px; scroll-behavior: smooth; }
body {
    font-family: var(--font-main);
    background: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.6;
    overflow-x: hidden;
}
a { text-decoration: none; color: inherit; }
button { cursor: pointer; border: none; background: none; font-family: inherit; }
input, select, textarea {
    font-family: inherit;
    font-size: 0.933rem;
    border: 1.5px solid var(--border-color);
    border-radius: var(--radius-sm);
    padding: 0.6rem 0.85rem;
    background: var(--bg-card);
    color: var(--text-primary);
    transition: border-color 0.2s, box-shadow 0.2s;
    width: 100%;
}
input:focus, select:focus, textarea:focus {
    outline: none;
    border-color: var(--accent-orange);
    box-shadow: 0 0 0 3px var(--accent-orange-glow);
}
table { width: 100%; border-collapse: collapse; }

/* ══════ Sidebar ══════ */
.sidebar {
    position: fixed;
    left: 0; top: 0;
    width: var(--sidebar-width);
    height: 100vh;
    background: var(--sidebar-bg);
    display: flex;
    flex-direction: column;
    z-index: 100;
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    overflow-y: auto;
}
.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 1.25rem 1.25rem 1.5rem;
    border-bottom: 1px solid rgba(255,255,255,0.08);
}
.brand-icon {
    width: 36px; height: 36px;
    background: var(--accent-orange);
    border-radius: var(--radius-sm);
    display: grid;
    place-items: center;
    flex-shrink: 0;
}
.brand-icon svg { width: 20px; height: 20px; color: white; }
.brand-name {
    font-size: 1.15rem;
    font-weight: 700;
    color: white;
    letter-spacing: -0.02em;
}
.sidebar-nav {
    flex: 1;
    padding: 0.75rem 0.75rem;
    display: flex;
    flex-direction: column;
    gap: 2px;
}
.nav-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.65rem 0.85rem;
    border-radius: var(--radius-sm);
    color: var(--sidebar-text);
    font-size: 0.9rem;
    font-weight: 500;
    transition: all 0.2s;
}
.nav-item svg { width: 19px; height: 19px; flex-shrink: 0; opacity: 0.7; }
.nav-item:hover { background: var(--sidebar-hover); color: var(--sidebar-text-active); }
.nav-item:hover svg { opacity: 1; }
.nav-item.active {
    background: var(--sidebar-active-bg);
    color: white;
    font-weight: 600;
}
.nav-item.active svg { opacity: 1; }

.sidebar-footer {
    padding: 1rem;
    border-top: 1px solid rgba(255,255,255,0.08);
}
.user-card {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    padding: 0.5rem;
}
.user-avatar {
    width: 36px; height: 36px;
    border-radius: 50%;
    background: var(--accent-orange);
    color: white;
    display: grid;
    place-items: center;
    font-size: 0.85rem;
    font-weight: 700;
    flex-shrink: 0;
}
.user-info { display: flex; flex-direction: column; }
.user-name { color: white; font-size: 0.85rem; font-weight: 600; }
.user-role { color: var(--sidebar-text); font-size: 0.75rem; }

/* ══════ Main Content ══════ */
.main-content {
    margin-left: var(--sidebar-width);
    min-height: 100vh;
    transition: margin-left 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ══════ Top Bar ══════ */
.top-bar {
    height: var(--top-bar-height);
    background: var(--bg-card);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    padding: 0 1.5rem;
    gap: 1rem;
    position: sticky;
    top: 0;
    z-index: 50;
}
.menu-toggle {
    display: none;
    padding: 0.4rem;
    border-radius: var(--radius-xs);
}
.menu-toggle svg { width: 22px; height: 22px; color: var(--text-secondary); }
.page-title {
    font-size: 1.15rem;
    font-weight: 700;
    letter-spacing: -0.02em;
    flex: 1;
}
.top-bar-actions {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    position: relative;
}

/* Notification Bell */
.notification-bell {
    position: relative;
    padding: 0.5rem;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: background 0.2s;
}
.notification-bell:hover { background: var(--bg-primary); }
.notification-bell svg { width: 20px; height: 20px; color: var(--text-secondary); }
.notif-badge {
    position: absolute;
    top: 2px; right: 2px;
    background: var(--red);
    color: white;
    font-size: 0.65rem;
    font-weight: 700;
    min-width: 17px; height: 17px;
    border-radius: 99px;
    display: grid;
    place-items: center;
    padding: 0 4px;
}

/* Notification Panel */
.notification-panel {
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    width: 360px;
    max-height: 420px;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    display: none;
    flex-direction: column;
    overflow: hidden;
    z-index: 200;
}
.notification-panel.open { display: flex; }
.notif-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.85rem 1rem;
    border-bottom: 1px solid var(--border-color);
    font-weight: 600;
    font-size: 0.9rem;
}
.notif-list { overflow-y: auto; flex: 1; }
.notif-item {
    padding: 0.75rem 1rem;
    border-bottom: 1px solid var(--border-light);
    cursor: pointer;
    transition: background 0.15s;
}
.notif-item:hover { background: var(--bg-primary); }
.notif-item.unread { background: var(--accent-orange-glow); }
.notif-item .notif-title { font-weight: 600; font-size: 0.85rem; margin-bottom: 2px; }
.notif-item .notif-msg { font-size: 0.8rem; color: var(--text-secondary); }
.notif-item .notif-time { font-size: 0.72rem; color: var(--text-muted); margin-top: 4px; }
.notif-loading { padding: 2rem; text-align: center; color: var(--text-muted); }

.btn-logout {
    padding: 0.5rem;
    border-radius: var(--radius-sm);
    transition: background 0.2s;
}
.btn-logout:hover { background: var(--red-bg); }
.btn-logout svg { width: 20px; height: 20px; color: var(--text-secondary); }

/* ══════ Page Content ══════ */
.page-content {
    padding: 1.5rem;
    max-width: 1400px;
}

/* ══════ Cards ══════ */
.card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    box-shadow: var(--shadow-card);
    overflow: hidden;
}
.card-header {
    padding: 1rem 1.25rem;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.card-header h3 {
    font-size: 0.95rem;
    font-weight: 700;
    letter-spacing: -0.01em;
}
.card-body { padding: 1.25rem; }

/* ══════ Dashboard Grid ══════ */
.dashboard-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 1rem;
    margin-bottom: 1.5rem;
}

/* Stat Cards */
.stat-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    padding: 1.25rem;
    display: flex;
    align-items: flex-start;
    gap: 1rem;
    box-shadow: var(--shadow-card);
    transition: transform 0.2s, box-shadow 0.2s;
}
.stat-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}
.stat-icon {
    width: 44px; height: 44px;
    border-radius: var(--radius-sm);
    display: grid;
    place-items: center;
    flex-shrink: 0;
}
.stat-icon svg { width: 22px; height: 22px; }
.stat-icon.green { background: var(--green-bg); color: var(--green); }
.stat-icon.red { background: var(--red-bg); color: var(--red); }
.stat-icon.orange { background: var(--orange-bg); color: var(--orange); }
.stat-icon.blue { background: var(--blue-bg); color: var(--blue); }
.stat-icon.gray { background: var(--gray-bg); color: var(--gray); }
.stat-info { flex: 1; }
.stat-label { font-size: 0.8rem; color: var(--text-muted); font-weight: 500; margin-bottom: 2px; }
.stat-value { font-size: 1.5rem; font-weight: 800; letter-spacing: -0.03em; line-height: 1.2; }
.stat-sub { font-size: 0.78rem; color: var(--text-secondary); margin-top: 2px; }

/* ══════ Buttons ══════ */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.55rem 1.1rem;
    border-radius: var(--radius-sm);
    font-size: 0.875rem;
    font-weight: 600;
    transition: all 0.2s;
    white-space: nowrap;
}
.btn svg { width: 16px; height: 16px; }
.btn-primary { background: var(--accent-orange); color: white; }
.btn-primary:hover { background: var(--accent-orange-hover); }
.btn-secondary { background: var(--deep-blue); color: white; }
.btn-secondary:hover { background: var(--deep-blue-light); }
.btn-success { background: var(--green); color: white; }
.btn-danger { background: var(--red); color: white; }
.btn-outline {
    background: transparent;
    border: 1.5px solid var(--border-color);
    color: var(--text-secondary);
}
.btn-outline:hover { border-color: var(--accent-orange); color: var(--accent-orange); }
.btn-sm { padding: 0.35rem 0.75rem; font-size: 0.8rem; }
.btn-lg { padding: 0.75rem 1.5rem; font-size: 1rem; }
.btn-link {
    background: none;
    color: var(--accent-orange);
    font-weight: 600;
    font-size: 0.8rem;
    padding: 0;
}
.btn-link:hover { text-decoration: underline; }

.btn-group { display: flex; gap: 0.5rem; flex-wrap: wrap; }

/* ══════ Tables ══════ */
.table-wrapper { overflow-x: auto; }
.data-table { width: 100%; }
.data-table th {
    background: var(--bg-primary);
    padding: 0.7rem 1rem;
    text-align: left;
    font-size: 0.78rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
    border-bottom: 1px solid var(--border-color);
}
.data-table td {
    white-space: nowrap;
    padding: 0.75rem 1rem;
    font-size: 0.875rem;
    border-bottom: 1px solid var(--border-light);
    vertical-align: middle;
}
.data-table tbody tr:hover { background: var(--bg-card-hover); }

/* ══════ Status Badges ══════ */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 0.2rem 0.65rem;
    border-radius: 99px;
    font-size: 0.75rem;
    font-weight: 600;
}
.badge-green { background: var(--green-bg); color: var(--green); }
.badge-red { background: var(--red-bg); color: var(--red); }
.badge-orange { background: var(--orange-bg); color: var(--orange); }
.badge-blue { background: var(--blue-bg); color: var(--blue); }
.badge-gray { background: var(--gray-bg); color: var(--gray); }

/* ══════ Forms ══════ */
.form-group { margin-bottom: 1rem; }
.form-group label {
    display: block;
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 0.35rem;
}
.form-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
}
.form-error { font-size: 0.78rem; color: var(--red); margin-top: 0.25rem; }

/* ══════ Modal ══════ */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.5);
    backdrop-filter: blur(4px);
    z-index: 500;
    display: none;
    place-items: center;
    padding: 1rem;
}
.modal-overlay.open { display: grid; }
.modal {
    background: var(--bg-card);
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    width: 100%;
    max-width: 560px;
    max-height: 85vh;
    overflow-y: auto;
    animation: modalIn 0.25s ease;
}
@keyframes modalIn {
    from { transform: translateY(20px) scale(0.97); opacity: 0; }
    to { transform: translateY(0) scale(1); opacity: 1; }
}
.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 1.25rem;
    border-bottom: 1px solid var(--border-color);
}
.modal-header h3 { font-size: 1.05rem; font-weight: 700; }
.modal-close {
    width: 32px; height: 32px;
    border-radius: var(--radius-xs);
    display: grid;
    place-items: center;
    transition: background 0.2s;
}
.modal-close:hover { background: var(--bg-primary); }
.modal-body { padding: 1.25rem; }
.modal-footer {
    padding: 1rem 1.25rem;
    border-top: 1px solid var(--border-color);
    display: flex;
    justify-content: flex-end;
    gap: 0.5rem;
}

/* ══════ Toast ══════ */
#toast-container {
    position: fixed;
    top: 1rem;
    right: 1rem;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}
.toast {
    padding: 0.85rem 1.25rem;
    border-radius: var(--radius-sm);
    font-size: 0.875rem;
    font-weight: 500;
    color: white;
    box-shadow: var(--shadow-lg);
    animation: toastIn 0.3s ease, toastOut 0.3s ease forwards;
    animation-delay: 0s, 3s;
    min-width: 280px;
    max-width: 420px;
}
.toast-success { background: var(--green); }
.toast-error { background: var(--red); }
.toast-warning { background: var(--orange); }
.toast-info { background: var(--blue); }

@keyframes toastIn { from { transform: translateX(100%); opacity: 0; } to { transform: translateX(0); opacity: 1; } }
@keyframes toastOut { from { opacity: 1; } to { opacity: 0; transform: translateY(-10px); } }

/* ══════ Calendar ══════ */
.calendar {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 4px;
}
.calendar-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}
.calendar-day-label {
    text-align: center;
    font-size: 0.72rem;
    font-weight: 700;
    text-transform: uppercase;
    color: var(--text-muted);
    padding: 0.5rem;
}
.calendar-day {
    aspect-ratio: 1;
    display: grid;
    place-items: center;
    border-radius: var(--radius-xs);
    font-size: 0.82rem;
    font-weight: 500;
    position: relative;
    cursor: default;
}
.calendar-day.empty { visibility: hidden; }
.calendar-day.today { font-weight: 800; box-shadow: inset 0 0 0 2px var(--accent-orange); }
.calendar-day.full_day { background: var(--green-bg); color: var(--green); }
.calendar-day.half_day { background: var(--orange-bg); color: var(--orange); }
.calendar-day.short_day { background: var(--orange-bg); color: var(--orange); }
.calendar-day.absent { background: var(--red-bg); color: var(--red); }
.calendar-day.leave { background: var(--blue-bg); color: var(--blue); }
.calendar-day.wfh { background: var(--blue-bg); color: var(--blue); }
.calendar-day.holiday, .calendar-day.sunday { background: var(--gray-bg); color: var(--gray); }

/* ══════ Progress Ring ══════ */
.progress-ring-container { position: relative; display: inline-flex; }
.progress-ring-text {
    position: absolute;
    inset: 0;
    display: grid;
    place-items: center;
    font-weight: 800;
    font-size: 1.2rem;
}

/* ══════ Check-in Card ══════ */
.checkin-card {
    background: linear-gradient(135deg, var(--deep-blue), var(--deep-blue-light));
    border-radius: var(--radius);
    padding: 2rem;
    color: white;
    text-align: center;
    margin-bottom: 1.5rem;
}
.checkin-card h2 { font-size: 1.3rem; margin-bottom: 0.5rem; }
.checkin-card .time-display { font-size: 2.5rem; font-weight: 800; font-family: var(--font-mono); margin: 1rem 0; }
.checkin-btn {
    background: var(--accent-orange);
    color: white;
    padding: 0.85rem 2.5rem;
    border-radius: 99px;
    font-size: 1rem;
    font-weight: 700;
    transition: all 0.2s;
    position: relative;
    overflow: hidden;
}
.checkin-btn:hover { transform: scale(1.05); box-shadow: 0 8px 24px rgba(255, 107, 53, 0.4); }
.checkin-btn:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }
.checkin-btn .spinner {
    display: none;
    width: 18px; height: 18px;
    border: 2px solid rgba(255,255,255,0.3);
    border-top-color: white;
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
}
.checkin-btn.loading .spinner { display: inline-block; }
.checkin-btn.loading span { display: none; }

@keyframes spin { to { transform: rotate(360deg); } }

/* ══════ Loading ══════ */
.loading-spinner {
    width: 32px; height: 32px;
    border: 3px solid var(--border-color);
    border-top-color: var(--accent-orange);
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
    margin: 2rem auto;
}

/* ══════ Login Page ══════ */
.login-page {
    min-height: 100vh;
    display: grid;
    place-items: center;
    background: linear-gradient(135deg, var(--deep-blue-dark) 0%, var(--deep-blue) 50%, var(--deep-blue-light) 100%);
    padding: 1rem;
}
.login-card {
    background: var(--bg-card);
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    width: 100%;
    max-width: 420px;
    padding: 2.5rem;
}
.login-card .brand-logo {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
    margin-bottom: 2rem;
}
.login-card .brand-logo .brand-icon { width: 44px; height: 44px; }
.login-card .brand-logo .brand-name { font-size: 1.4rem; color: var(--deep-blue); }
.login-card h2 { text-align: center; margin-bottom: 0.5rem; font-size: 1.25rem; }
.login-card p { text-align: center; color: var(--text-muted); margin-bottom: 1.5rem; font-size: 0.9rem; }
.login-error {
    background: var(--red-bg);
    color: var(--red);
    padding: 0.65rem 1rem;
    border-radius: var(--radius-sm);
    font-size: 0.85rem;
    margin-bottom: 1rem;
}
.demo-info {
    margin-top: 1.5rem;
    padding-top: 1rem;
    border-top: 1px solid var(--border-color);
}
.demo-info h4 { font-size: 0.8rem; color: var(--text-muted); margin-bottom: 0.5rem; text-transform: uppercase; letter-spacing: 0.05em; }
.demo-account {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.4rem 0;
    font-size: 0.82rem;
}
.demo-account .role { color: var(--text-secondary); font-weight: 600; }
.demo-account .email { color: var(--text-muted); font-family: var(--font-mono); font-size: 0.78rem; }

/* ══════ Two-Column Layout ══════ */
.grid-2 {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.5rem;
}
.grid-3 {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1rem;
}

/* ══════ Responsive ══════ */
@media (max-width: 1024px) {
    .grid-2 { grid-template-columns: 1fr; }
    .grid-3 { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 768px) {
    .sidebar {
        transform: translateX(-100%);
    }
    .sidebar.open {
        transform: translateX(0);
    }
    .sidebar-overlay {
        position: fixed;
        inset: 0;
        background: rgba(0,0,0,0.5);
        z-index: 99;
        display: none;
    }
    .sidebar-overlay.open { display: block; }
    .main-content { margin-left: 0; }
    .menu-toggle { display: block; }
    .page-content { padding: 1rem; }
    .dashboard-grid { grid-template-columns: 1fr; }
    .grid-3 { grid-template-columns: 1fr; }
    .notification-panel { width: 300px; right: -1rem; }
}

/* ══════ Animations ══════ */
.fade-in { animation: fadeIn 0.4s ease; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }

/* ══════ Empty State ══════ */
.empty-state {
    text-align: center;
    padding: 3rem 1rem;
    color: var(--text-muted);
}
.empty-state svg { width: 48px; height: 48px; margin-bottom: 1rem; opacity: 0.4; }
.empty-state p { font-size: 0.9rem; }

/* ══════ Chart Container ══════ */
.chart-container {
    position: relative;
    height: 280px;
    padding: 1rem;
}

/* ══════ Streak Badge ══════ */
.streak-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    background: linear-gradient(135deg, #FF6B35, #FF8F5E);
    color: white;
    padding: 0.35rem 0.85rem;
    border-radius: 99px;
    font-size: 0.82rem;
    font-weight: 700;
}

/* ══════ Action Buttons Inline ══════ */
.action-btns { display: flex; gap: 0.35rem; }
.action-btns .btn { padding: 0.3rem 0.6rem; font-size: 0.78rem; }

/* ══════ Filter Bar ══════ */
.filter-bar {
    display: flex;
    gap: 0.75rem;
    align-items: center;
    flex-wrap: wrap;
    margin-bottom: 1.25rem;
}
.filter-bar select, .filter-bar input { width: auto; min-width: 140px; }
