/* ---------------------------------------------------------------------------
   HRMS + Secure Mail CRM
   Layout, sidebar, and the mailbox three-pane view.
   --------------------------------------------------------------------------- */

:root {
    --sidebar-w: 250px;
    --topbar-h: 60px;
    --brand: #4f46e5;
    --brand-dark: #4338ca;
    --sidebar-bg: #111827;
    --sidebar-fg: #9ca3af;
    --sidebar-fg-active: #ffffff;
    --border: #e5e7eb;
    --muted: #6b7280;
    --body-bg: #f4f6fb;
}

body {
    background: var(--body-bg);
    font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
    font-size: 0.9rem;
    color: #1f2937;
}

/* --- shell ---------------------------------------------------------------- */

.app-shell { display: flex; min-height: 100vh; }

.app-sidebar {
    width: var(--sidebar-w);
    flex: 0 0 var(--sidebar-w);
    background: var(--sidebar-bg);
    color: var(--sidebar-fg);
    position: fixed;
    inset: 0 auto 0 0;
    overflow-y: auto;
    z-index: 1040;
}

.app-main {
    flex: 1 1 auto;
    margin-left: var(--sidebar-w);
    min-width: 0;
    display: flex;
    flex-direction: column;
}

.app-content { padding: 1.25rem; flex: 1 1 auto; }

/* --- sidebar -------------------------------------------------------------- */

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: .6rem;
    padding: 1rem 1.1rem;
    color: #fff;
    font-weight: 600;
    border-bottom: 1px solid rgba(255, 255, 255, .08);
}

.brand-mark {
    width: 34px; height: 34px;
    display: grid; place-items: center;
    background: var(--brand);
    border-radius: 9px;
    color: #fff;
}

.sidebar-nav { padding: .5rem 0 2rem; }

.nav-heading {
    padding: 1rem 1.1rem .35rem;
    font-size: .68rem;
    letter-spacing: .08em;
    text-transform: uppercase;
    color: #6b7280;
}

.app-sidebar .nav-item {
    display: flex;
    align-items: center;
    gap: .7rem;
    padding: .5rem 1.1rem;
    color: var(--sidebar-fg);
    text-decoration: none;
    border-left: 3px solid transparent;
}

.app-sidebar .nav-item:hover {
    background: rgba(255, 255, 255, .05);
    color: #fff;
}

.app-sidebar .nav-item.active {
    background: rgba(79, 70, 229, .18);
    border-left-color: var(--brand);
    color: var(--sidebar-fg-active);
}

.app-sidebar .nav-item i { width: 18px; text-align: center; }

/* --- topbar --------------------------------------------------------------- */

.app-topbar {
    height: var(--topbar-h);
    background: #fff;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    gap: .75rem;
    padding: 0 1.25rem;
    position: sticky;
    top: 0;
    z-index: 1030;
}

.topbar-title { font-size: 1.05rem; font-weight: 600; margin: 0; flex: 1 1 auto; }

.topbar-actions { display: flex; align-items: center; gap: .35rem; }

.topbar-icon {
    position: relative;
    width: 38px; height: 38px;
    display: grid; place-items: center;
    border-radius: 8px;
    color: #4b5563;
    text-decoration: none;
}

.topbar-icon:hover { background: #f3f4f6; color: #111827; }

.topbar-icon .badge {
    position: absolute;
    top: 2px; right: 0;
    font-size: .6rem;
    padding: .18em .4em;
}

.topbar-user {
    display: flex;
    align-items: center;
    gap: .55rem;
    text-decoration: none;
    color: #1f2937;
}

.topbar-user .user-name { display: block; font-weight: 600; font-size: .85rem; line-height: 1.1; }
.topbar-user .user-role { display: block; color: var(--muted); font-size: .72rem; }

.avatar {
    width: 34px; height: 34px;
    border-radius: 50%;
    display: grid; place-items: center;
    color: #fff;
    font-weight: 600;
    font-size: .78rem;
    flex: 0 0 34px;
}

.avatar-sm { width: 28px; height: 28px; flex-basis: 28px; font-size: .68rem; }

/* --- cards / tables ------------------------------------------------------- */

.card { border: 1px solid var(--border); border-radius: 10px; box-shadow: 0 1px 2px rgba(16, 24, 40, .04); }
.card-header { background: #fff; border-bottom: 1px solid var(--border); font-weight: 600; }

.stat-card { display: flex; align-items: center; gap: .9rem; padding: 1rem; }
.stat-icon {
    width: 46px; height: 46px;
    border-radius: 10px;
    display: grid; place-items: center;
    font-size: 1.2rem;
}
.stat-value { font-size: 1.5rem; font-weight: 700; line-height: 1.1; }
.stat-label { color: var(--muted); font-size: .8rem; }

.table > :not(caption) > * > * { padding: .6rem .75rem; }
.table thead th { font-size: .74rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }

.empty-state { text-align: center; padding: 2.5rem 1rem; color: var(--muted); }
.empty-state i { font-size: 2rem; display: block; margin-bottom: .5rem; opacity: .5; }

/* --- auth ----------------------------------------------------------------- */

.auth-body {
    min-height: 100vh;
    display: grid;
    place-items: center;
    background: linear-gradient(135deg, #4f46e5, #0891b2);
}

.auth-wrap { width: 100%; max-width: 420px; padding: 1rem; }

.auth-card { background: #fff; border-radius: 14px; padding: 2rem; box-shadow: 0 20px 45px rgba(0, 0, 0, .18); }

.auth-brand { text-align: center; margin-bottom: 1.5rem; }
.auth-brand .brand-mark { margin: 0 auto .7rem; width: 48px; height: 48px; font-size: 1.3rem; }
.auth-brand h1 { font-size: 1.25rem; font-weight: 700; margin: 0; }
.auth-brand p { color: var(--muted); font-size: .82rem; margin: .2rem 0 0; }

.auth-footnote { text-align: center; color: var(--muted); font-size: .78rem; margin: 1.1rem 0 0; }

/* --- mailbox -------------------------------------------------------------- */

.mail-layout {
    display: grid;
    grid-template-columns: 210px minmax(320px, 1fr);
    gap: 1rem;
    align-items: start;
}

.mail-sidebar .list-group-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: .5rem;
    border: 0;
    border-radius: 8px;
    padding: .5rem .7rem;
    color: #374151;
}

.mail-sidebar .list-group-item.active { background: #eef2ff; color: var(--brand-dark); font-weight: 600; }

.mail-list { max-height: calc(100vh - 220px); overflow-y: auto; }

.mail-row {
    display: flex;
    gap: .75rem;
    padding: .7rem .9rem;
    border-bottom: 1px solid var(--border);
    text-decoration: none;
    color: inherit;
}

.mail-row:hover { background: #f9fafb; }
.mail-row.unread { background: #fdfdff; }
.mail-row.unread .mail-from,
.mail-row.unread .mail-subject { font-weight: 700; color: #111827; }

.mail-body-col { min-width: 0; flex: 1 1 auto; }
.mail-from { font-size: .85rem; }
.mail-subject { font-size: .85rem; }
.mail-snippet { color: var(--muted); font-size: .78rem; }
.mail-meta { text-align: right; white-space: nowrap; color: var(--muted); font-size: .74rem; }

.mail-truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.mail-reading-body {
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 1rem;
    background: #fff;
    overflow-x: auto;
}

.mail-reading-body img { max-width: 100%; height: auto; }

.mail-quote { border-left: 3px solid var(--border); padding-left: .85rem; color: var(--muted); }

/* --- payslip print -------------------------------------------------------- */

@media print {
    .app-sidebar, .app-topbar, .no-print { display: none !important; }
    .app-main { margin-left: 0; }
    .app-content { padding: 0; }
    body { background: #fff; }
    .card { border: 0; box-shadow: none; }
}

/* --- responsive ----------------------------------------------------------- */

@media (max-width: 991.98px) {
    .app-sidebar { transform: translateX(-100%); transition: transform .2s ease; }
    .app-sidebar.open { transform: translateX(0); }
    .app-main { margin-left: 0; }
    .mail-layout { grid-template-columns: 1fr; }
}
