/* ===========================================================
   Voltech HRIS — App Stylesheet
   =========================================================== */

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

/* ── Design Tokens ── */
:root {
    --primary: #2563EB; --primary-dark: #1d4ed8; --primary-light: #dbeafe;
    --success: #10B981; --success-light: #d1fae5;
    --warning: #F59E0B; --warning-light: #fef3c7;
    --danger:  #EF4444; --danger-light:  #fee2e2;
    --purple:  #8B5CF6; --purple-light:  #ede9fe;
    --orange:  #F97316; --orange-light:  #ffedd5;
    --white:   #ffffff;
    --sidebar-w: 256px;
    --topbar-h:  64px;
    --radius:    12px;
    --radius-sm: 6px;
    --radius-lg: 16px;
    --shadow-sm: 0 1px 3px rgba(15,23,42,0.06), 0 1px 2px rgba(15,23,42,0.04);
    --shadow-md: 0 8px 30px rgba(15,23,42,0.10), 0 2px 8px rgba(15,23,42,0.05);
    --transition: all 0.18s cubic-bezier(0.4,0,0.2,1);

    /* Light theme */
    --bg:        #f8fafc;
    --surface:   #ffffff;
    --border:    #e2e8f0;
    --text:      #1e293b;
    --text-muted:#64748b;
    --sidebar-bg:#ffffff;
    --sidebar-text: #475569;
    --sidebar-active-bg: #eff6ff;
    --sidebar-active-text: #2563EB;
    --topbar-bg: #ffffff;
    --input-bg:  #f8fafc;
    --shadow:    0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.06);
    --shadow-md: 0 4px 12px rgba(0,0,0,.10);
}
[data-theme="dark"] {
    --bg:        #0f172a;
    --surface:   #1e293b;
    --border:    #334155;
    --text:      #f1f5f9;
    --text-muted:#94a3b8;
    --sidebar-bg:#1e293b;
    --sidebar-text: #94a3b8;
    --sidebar-active-bg: rgba(37,99,235,.15);
    --sidebar-active-text: #60a5fa;
    --topbar-bg: #1e293b;
    --input-bg:  #0f172a;
    --shadow:    0 1px 3px rgba(0,0,0,.3);
    --shadow-md: 0 4px 12px rgba(0,0,0,.4);
    --shadow-sm: 0 1px 3px rgba(0,0,0,.4), 0 1px 2px rgba(0,0,0,.3);
}

html { overflow-x: hidden; }
body {
    font-family: 'DM Sans', sans-serif;
    background: var(--bg); color: var(--text);
    display: flex; min-height: 100vh;
    transition: background .2s, color .2s;
    overflow-x: hidden;
}

/* ── Sidebar ── */
.sidebar {
    width: var(--sidebar-w); height: 100vh;
    background: var(--sidebar-bg); border-right: 1px solid var(--border);
    display: flex; flex-direction: column;
    position: fixed; top: 0; left: 0; z-index: 200;
    overflow: hidden;
    transition: transform .25s ease, background .2s;
}
.sidebar-brand {
    height: var(--topbar-h); display: flex; align-items: center; gap: .75rem;
    padding: 0 1.25rem; border-bottom: 1px solid var(--border); flex-shrink: 0;
}
.brand-logo {
    width: 36px; height: 36px; background: var(--primary);
    border-radius: 10px; display: flex; align-items: center; justify-content: center;
    font-family: 'Sora', sans-serif; font-weight: 700; font-size: .85rem; color: #fff;
    flex-shrink: 0;
}
.brand-text { font-family: 'Sora', sans-serif; font-weight: 700; font-size: .95rem; color: var(--text); line-height: 1.2; }
.brand-sub { font-size: .7rem; color: var(--text-muted); font-weight: 400; }

.sidebar-nav {
    flex: 1; padding: .75rem 0;
    overflow-y: auto; overflow-x: hidden;
    scrollbar-width: thin; scrollbar-color: var(--border) transparent;
}
.sidebar-nav::-webkit-scrollbar { width: 3px; }
.sidebar-nav::-webkit-scrollbar-track { background: transparent; }
.sidebar-nav::-webkit-scrollbar-thumb { background: var(--border); border-radius: 99px; }
.nav-section { padding: .5rem 1.25rem .25rem; font-size: .65rem; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--text-muted); }

.nav-item { display: block; position: relative; }
.nav-link {
    display: flex; align-items: center; gap: .65rem;
    padding: .55rem 1.25rem; color: var(--sidebar-text);
    text-decoration: none; font-size: .875rem; font-weight: 500;
    border-radius: 0; transition: all .15s; cursor: pointer;
    border: none; background: none; width: 100%;
}
.nav-link:hover { background: var(--sidebar-active-bg); color: var(--sidebar-active-text); }
.nav-link.active { background: var(--sidebar-active-bg); color: var(--sidebar-active-text); font-weight: 600; }
.nav-link.active::before { content: ''; position: absolute; left: 0; top: 20%; bottom: 20%; width: 3px; background: var(--primary); border-radius: 0 3px 3px 0; }
.nav-icon { width: 18px; text-align: center; font-size: .85rem; flex-shrink: 0; }
.nav-badge { margin-left: auto; padding: .15rem .45rem; background: var(--primary); color: #fff; border-radius: 20px; font-size: .65rem; font-weight: 700; }
.nav-badge.new { background: var(--success); }
.nav-badge.warn { background: var(--warning); }

.nav-group-toggle { justify-content: space-between; }
.nav-group-toggle .toggle-arrow { margin-left: auto; transition: transform .2s; font-size: .7rem; color: var(--text-muted); }
.nav-group-toggle.open .toggle-arrow { transform: rotate(90deg); }
.nav-children { display: none; padding-left: .5rem; }
.nav-children.open { display: block; }
.nav-children .nav-link { font-size: .83rem; padding: .45rem 1.25rem .45rem 2.25rem; font-weight: 400; }
.nav-children .nav-link.active { font-weight: 600; }

.sidebar-footer {
    border-top: 1px solid var(--border); padding: .875rem 1.25rem;
    display: flex; align-items: center; gap: .65rem;
    flex-shrink: 0; /* always visible at bottom, never scrolls */
}
.sidebar-user-avatar {
    width: 34px; height: 34px; border-radius: 50%; object-fit: cover;
    flex-shrink: 0; border: 2px solid var(--border);
}
.sidebar-user-info { flex: 1; min-width: 0; }
.sidebar-user-name { font-size: .8rem; font-weight: 600; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sidebar-user-role { font-size: .7rem; color: var(--text-muted); }
.sidebar-signout { background: none; border: none; color: var(--text-muted); cursor: pointer; padding: .25rem; border-radius: 6px; }
.sidebar-signout:hover { color: var(--danger); background: var(--danger-light); }

/* ── Main Layout ── */
.main-wrapper { margin-left: var(--sidebar-w); flex: 1; min-width: 0; display: flex; flex-direction: column; min-height: 100vh; }

/* ── Topbar ── */
.topbar {
    height: var(--topbar-h); background: var(--topbar-bg);
    border-bottom: 1px solid var(--border);
    display: flex; align-items: center; gap: 1rem;
    padding: 0 1.5rem; position: sticky; top: 0; z-index: 100;
    box-shadow: var(--shadow);
}
.topbar-spacer { flex: 1; }
.topbar-search {
    display: flex; align-items: center; gap: .5rem;
    background: var(--input-bg); border: 1px solid var(--border);
    border-radius: 8px; padding: .45rem .75rem; width: 240px;
}
.topbar-search input { background: none; border: none; outline: none; font-size: .85rem; color: var(--text); width: 100%; }
.topbar-search i { color: var(--text-muted); font-size: .8rem; }
.topbar-actions { display: flex; align-items: center; gap: .5rem; }
.topbar-btn {
    width: 36px; height: 36px; border-radius: 8px;
    display: flex; align-items: center; justify-content: center;
    background: none; border: 1px solid var(--border); color: var(--text-muted);
    cursor: pointer; transition: all .15s; position: relative;
}
.topbar-btn:hover { background: var(--sidebar-active-bg); color: var(--primary); border-color: var(--primary); }
.notif-dot {
    position: absolute; top: 4px; right: 4px;
    width: 8px; height: 8px; background: var(--danger);
    border-radius: 50%; border: 2px solid var(--surface);
}

/* ── Notification bell + dropdown ── */
.notif-wrap { position: relative; }
.notif-badge {
    position: absolute; top: -5px; right: -5px; min-width: 17px; height: 17px;
    padding: 0 4px; background: var(--danger); color: #fff;
    border-radius: 20px; font-size: .62rem; font-weight: 700;
    display: flex; align-items: center; justify-content: center;
    border: 2px solid var(--surface); line-height: 1;
}
.notif-dropdown {
    position: absolute; top: calc(100% + 10px); right: 0; width: 380px; max-width: 92vw;
    background: var(--surface); border: 1px solid var(--border); border-radius: 14px;
    box-shadow: var(--shadow-md); z-index: 300; overflow: hidden;
    opacity: 0; visibility: hidden; transform: translateY(-8px);
    transition: opacity .18s, transform .18s, visibility .18s;
}
.notif-dropdown.open { opacity: 1; visibility: visible; transform: translateY(0); }
.notif-dd-head { display: flex; align-items: center; justify-content: space-between; padding: .85rem 1rem; border-bottom: 1px solid var(--border); }
.notif-dd-title { font-family: 'Sora', sans-serif; font-weight: 700; font-size: .92rem; color: var(--text); }
.notif-dd-allread { background: none; border: none; color: var(--primary); font-size: .76rem; font-weight: 600; cursor: pointer; }
.notif-dd-allread:hover { text-decoration: underline; }
.notif-dd-list { max-height: 380px; overflow-y: auto; scrollbar-width: thin; }
.notif-dd-item { display: flex; gap: .7rem; padding: .75rem 1rem; border-bottom: 1px solid var(--border); text-decoration: none; color: inherit; transition: background .15s; }
.notif-dd-item:hover { background: var(--sidebar-active-bg); }
.notif-dd-item.unread { background: linear-gradient(90deg, rgba(37,99,235,.06), transparent 70%); }
.notif-dd-ic { width: 36px; height: 36px; border-radius: 9px; display: flex; align-items: center; justify-content: center; color: #fff; font-size: .85rem; flex-shrink: 0; }
.notif-dd-body { flex: 1; min-width: 0; }
.notif-dd-itemtitle { font-size: .83rem; font-weight: 600; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.notif-dd-msg { font-size: .77rem; color: var(--text-muted); margin-top: .1rem; line-height: 1.35; }
.notif-dd-time { font-size: .7rem; color: var(--text-muted); margin-top: .25rem; }
.notif-dd-empty { text-align: center; padding: 2.5rem 1rem; color: var(--text-muted); font-size: .82rem; }
.notif-dd-empty i { font-size: 1.8rem; opacity: .35; display: block; margin-bottom: .5rem; }
.notif-dd-foot { display: flex; align-items: center; justify-content: center; gap: .4rem; padding: .8rem; font-size: .82rem; font-weight: 600; color: var(--primary); text-decoration: none; border-top: 1px solid var(--border); }
.notif-dd-foot:hover { background: var(--sidebar-active-bg); }
.user-menu { display: flex; align-items: center; gap: .5rem; cursor: pointer; padding: .35rem .6rem; border-radius: 8px; border: 1px solid var(--border); }
.user-menu:hover { background: var(--sidebar-active-bg); }
.user-avatar { width: 30px; height: 30px; border-radius: 50%; object-fit: cover; }
.user-name { font-size: .82rem; font-weight: 600; color: var(--text); max-width: 100px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ── Page Content ── */
.page-content { flex: 1; padding: 1.5rem; }

/* ── Standardized Page Header ── */
.page-header {
    display: flex; align-items: flex-start; justify-content: space-between;
    gap: 1.25rem; flex-wrap: wrap; margin-bottom: 1.5rem;
}
.page-header__left { min-width: 0; }
.page-breadcrumb {
    display: flex; align-items: center; gap: .5rem;
    font-size: .82rem; color: var(--text-muted); margin-bottom: 1rem;
}
.page-breadcrumb a { color: var(--primary); text-decoration: none; font-weight: 600; }
.page-breadcrumb a:hover { text-decoration: underline; }
.page-breadcrumb i { font-size: .6rem; }
.page-breadcrumb .current { color: var(--text-muted); font-weight: 500; }
.page-header__heading { display: flex; align-items: center; gap: .9rem; }
.page-header__icon {
    width: 48px; height: 48px; border-radius: 12px; flex-shrink: 0;
    display: flex; align-items: center; justify-content: center;
    font-size: 1.25rem; color: #fff;
}
.page-header__title {
    font-family: 'Sora', sans-serif; font-size: 1.6rem; font-weight: 700;
    color: var(--text); margin: 0; line-height: 1.15; letter-spacing: -.02em;
}
.page-header__subtitle { font-size: .875rem; color: var(--text-muted); margin: .2rem 0 0; }
.page-header__actions { display: flex; align-items: center; gap: .6rem; flex-wrap: wrap; }
@media (max-width: 640px) {
    .page-header__title { font-size: 1.3rem; }
    .page-header__icon { width: 42px; height: 42px; font-size: 1.1rem; }
    .page-header__actions { width: 100%; }
}

/* ── Cards ── */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; box-shadow: var(--shadow); }
.card-header { padding: 1rem 1.25rem; border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; gap: 1rem; flex-wrap: wrap; }
.card-title { font-family: 'Sora', sans-serif; font-size: .95rem; font-weight: 700; color: var(--text); }
.card-body { padding: 1.25rem; }

/* ── KPI Strip ── */
.kpi-strip { display: grid; gap: 1rem; margin-bottom: 1.25rem; }
.kpi-strip.cols-4 { grid-template-columns: repeat(4, 1fr); }
.kpi-strip.cols-5 { grid-template-columns: repeat(5, 1fr); }
.kpi-card {
    background: var(--surface); border: 1px solid var(--border);
    border-radius: 12px; padding: 1rem 1.25rem;
    display: flex; align-items: center; gap: 1rem;
    box-shadow: var(--shadow);
}
.kpi-icon { width: 44px; height: 44px; border-radius: 10px; display: flex; align-items: center; justify-content: center; font-size: 1.1rem; flex-shrink: 0; }
.kpi-value { font-family: 'Sora', sans-serif; font-size: 1.5rem; font-weight: 700; color: var(--text); line-height: 1; }
.kpi-label { font-size: .75rem; color: var(--text-muted); margin-top: .2rem; }

/* ── Buttons ── */
.btn { display: inline-flex; align-items: center; gap: .4rem; padding: .5rem 1rem; border-radius: 8px; font-size: .85rem; font-weight: 600; cursor: pointer; border: none; transition: all .15s; text-decoration: none; font-family: inherit; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-outline { background: transparent; color: var(--text); border: 1px solid var(--border); }
.btn-outline:hover { background: var(--sidebar-active-bg); border-color: var(--primary); color: var(--primary); }
.btn-sm { padding: .35rem .75rem; font-size: .8rem; }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { background: #dc2626; }
.btn-success { background: var(--success); color: #fff; }

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

/* ── Badges ── */
.badge { display: inline-flex; align-items: center; gap: .3rem; padding: .25rem .6rem; border-radius: 20px; font-size: .72rem; font-weight: 600; }
.badge-active  { background: var(--success-light); color: #065f46; }
.badge-expiring { background: var(--warning-light); color: #92400e; }
.badge-expired  { background: var(--danger-light); color: #991b1b; }
.badge-pending  { background: var(--purple-light); color: #5b21b6; }
.badge-draft    { background: var(--border); color: var(--text-muted); }
.badge-blue  { background: var(--primary-light); color: #1d4ed8; }
.badge-green { background: var(--success-light); color: #065f46; }
.badge-orange { background: var(--orange-light); color: #9a3412; }
.badge-purple { background: var(--purple-light); color: #5b21b6; }

/* ── Forms ── */
.form-group { margin-bottom: 1rem; }
.form-label { display: block; font-size: .82rem; font-weight: 600; color: var(--text-muted); margin-bottom: .4rem; }
.form-label .req { color: var(--danger); }
.form-control, .form-select {
    width: 100%; padding: .6rem .85rem; border: 1.5px solid var(--border);
    border-radius: 8px; font-size: .875rem; color: var(--text);
    background: var(--input-bg); font-family: inherit; outline: none;
    transition: border-color .15s, box-shadow .15s;
}
.form-control:focus, .form-select:focus { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-light); }
.form-control.is-invalid { border-color: var(--danger); }
.invalid-feedback { font-size: .78rem; color: var(--danger); margin-top: .25rem; display: block; }
.form-hint { font-size: .78rem; color: var(--text-muted); margin-top: .25rem; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.form-row-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 1rem; }

/* ── Modals ── */
.modal-backdrop { position: fixed; inset: 0; background: rgba(0,0,0,.5); z-index: 500; display: flex; align-items: center; justify-content: center; padding: 1rem; opacity: 0; pointer-events: none; transition: opacity .2s; }
.modal-backdrop.open { opacity: 1; pointer-events: all; }
.modal { background: var(--surface); border-radius: 16px; width: 100%; max-width: 640px; max-height: 90vh; min-height: 0; display: flex; flex-direction: column; box-shadow: 0 20px 60px rgba(0,0,0,.2); transform: translateY(12px); transition: transform .2s; overflow: hidden; }
.modal-backdrop.open .modal { transform: translateY(0); }
.modal-lg { max-width: 900px; }
.modal-header { padding: 1.25rem 1.5rem; border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; flex-shrink: 0; }
.modal-title { font-family: 'Sora', sans-serif; font-size: 1rem; font-weight: 700; color: var(--text); }
.modal-close { background: none; border: none; color: var(--text-muted); cursor: pointer; padding: .3rem; border-radius: 6px; }
.modal-close:hover { background: var(--danger-light); color: var(--danger); }
.modal-body { padding: 1.5rem; overflow-y: auto; flex: 1; min-height: 0; -webkit-overflow-scrolling: touch; }
.modal-footer { padding: 1rem 1.5rem; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: .75rem; flex-shrink: 0; }

/* ── Alerts ── */
.alert { padding: .875rem 1rem; border-radius: 10px; margin-bottom: 1rem; display: flex; align-items: flex-start; gap: .75rem; font-size: .875rem; }
.alert-success { background: var(--success-light); color: #065f46; border: 1px solid #a7f3d0; }
.alert-error   { background: var(--danger-light);  color: #991b1b; border: 1px solid #fca5a5; }
.alert-warning { background: var(--warning-light); color: #92400e; border: 1px solid #fcd34d; }

/* ── Pagination ── */
.pagination { display: flex; align-items: center; gap: .35rem; }
.page-btn { width: 32px; height: 32px; border-radius: 7px; display: flex; align-items: center; justify-content: center; font-size: .8rem; border: 1px solid var(--border); background: var(--surface); color: var(--text); cursor: pointer; text-decoration: none; }
.page-btn:hover { background: var(--primary-light); border-color: var(--primary); color: var(--primary); }
.page-btn.active { background: var(--primary); border-color: var(--primary); color: #fff; }
.page-btn:disabled, .page-btn.disabled { opacity: .4; cursor: not-allowed; }

/* ── Utilities ── */
.text-muted { color: var(--text-muted) !important; }
.text-primary { color: var(--primary) !important; }
.text-success { color: var(--success) !important; }
.text-warning { color: var(--warning) !important; }
.text-danger { color: var(--danger) !important; }
.fw-600 { font-weight: 600; }
.fw-700 { font-weight: 700; }
.font-mono { font-family: 'Courier New', monospace; }
.d-flex { display: flex; }
.align-center { align-items: center; }
.gap-1 { gap: .5rem; }
.gap-2 { gap: 1rem; }
.mt-1 { margin-top: .5rem; }
.mb-1 { margin-bottom: .75rem; }
.mb-2 { margin-bottom: 1.25rem; }

/* ── Responsive ── */
.sidebar-overlay { display: none; position: fixed; inset: 0; background: rgba(0,0,0,.5); z-index: 190; }
/* Hamburger: hidden on desktop, shown on tablet/mobile via CSS */
.sidebar-toggle-btn { display: none; }
@media (max-width: 1024px) { .sidebar-toggle-btn { display: flex; } }
@media (max-width: 1024px) {
    .sidebar { transform: translateX(-100%); }
    .sidebar.open { transform: translateX(0); }
    .sidebar-overlay.open { display: block; }
    .main-wrapper { margin-left: 0; }
    .kpi-strip.cols-4 { grid-template-columns: repeat(2, 1fr); }
    .kpi-strip.cols-5 { grid-template-columns: repeat(3, 1fr); }
    .form-row-3 { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 768px) {
    .topbar { padding: 0 1rem; gap: .5rem; }
    .topbar-search { display: none; }
    .user-name { display: none; }
    .kpi-strip.cols-5 { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 640px) {
    .topbar { padding: 0 .75rem; }
    .kpi-strip.cols-4, .kpi-strip.cols-5 { grid-template-columns: 1fr 1fr; }
    .form-row, .form-row-3 { grid-template-columns: 1fr; }
    .page-content { padding: .875rem; }
    .table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
    .card-header { flex-direction: column; align-items: flex-start; }
}
@media (max-width: 420px) {
    .kpi-strip.cols-4, .kpi-strip.cols-5 { grid-template-columns: 1fr; }
    .page-content { padding: .75rem; }
}
