/* =========================================================================
   FIRMEZA "LEDGER" APP SHELL
   Sidebar (248px) + 64px top bar + content (max 1280px, 32px padding).
   Below 1024px the sidebar is a drawer; employees get bottom tabs below 768px.
   Markup: resources/views/shell/*.blade.php, layouts/backend-layout.blade.php
   ========================================================================= */

:root { --fz-topbar-h: 64px; --fz-sidebar-w: 248px; }

html, body { background: var(--ground); }
.fz-shell { display: flex; min-height: 100vh; }

/* ---------- Sidebar -------------------------------------------------- */
.fz-sidebar {
    flex: none;
    width: var(--fz-sidebar-w);
    box-sizing: border-box;
    position: sticky;
    top: 0;
    height: 100vh;
    overflow-y: auto;
    background: var(--surface);
    border-right: 1px solid var(--line);
    padding: 20px 12px;
    display: flex;
    flex-direction: column;
    gap: 20px;
}
.fz-sidebar__head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.fz-brand { display: flex; align-items: center; gap: 10px; min-width: 0; height: 40px; padding: 0 8px; text-decoration: none; color: var(--navy-800); }
.fz-brand:hover { color: var(--navy-800); }
.fz-brand__mark { position: relative; overflow: hidden; flex: none; width: 32px; height: 32px; border-radius: 8px; background: var(--navy-800); color: #fff; font-weight: 800; display: inline-flex; align-items: center; justify-content: center; }
.fz-brand__mark::after { content: ""; position: absolute; right: 0; bottom: 0; width: 10px; height: 10px; background: var(--amber-500); border-top-left-radius: 8px; }
.fz-brand__img { flex: none; width: 32px; height: 32px; object-fit: contain; border-radius: 8px; }
.fz-brand__name { font-weight: 800; font-size: 16px; line-height: 1.2; letter-spacing: -.01em; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.fz-sidebar .fz-sidebar__close { display: none; }

.fz-nav { display: flex; flex-direction: column; gap: 16px; }
.fz-nav__group { display: flex; flex-direction: column; gap: 2px; }
.fz-nav__label { padding: 0 10px 6px; font-size: 11px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
.fz-nav__item {
    display: flex; align-items: center; gap: 10px;
    height: 36px; padding: 0 10px;
    border-radius: var(--radius-sm);
    font-size: 14px; font-weight: 500; text-decoration: none;
    color: var(--slate);
}
.fz-nav__item:hover { background: var(--header-row); color: var(--ink); }
.fz-nav__item.is-active { background: var(--navy-100); color: var(--navy-800); font-weight: 600; }
.fz-nav__item .fz-icon { flex: none; }
.fz-nav__text { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.fz-nav__badge { min-width: 20px; height: 20px; padding: 0 6px; box-sizing: border-box; border-radius: 999px; background: #FEF0C7; color: var(--warning); font-size: 12px; font-weight: 700; display: inline-flex; align-items: center; justify-content: center; }

/* ---------- Main column + top bar ------------------------------------ */
.fz-main { flex: 1 1 0; min-width: 0; display: flex; flex-direction: column; }
.fz-topbar {
    position: sticky; top: 0; z-index: 1020;
    min-height: var(--fz-topbar-h);
    box-sizing: border-box;
    background: var(--surface);
    border-bottom: 1px solid var(--line);
    padding: 10px 32px;
    display: flex; align-items: center; gap: 12px;
}
.fz-topbar__spacer { flex: 1; }
.fz-icon-btn {
    width: 40px; height: 40px; flex: none;
    display: inline-flex; align-items: center; justify-content: center;
    border: 1px solid var(--line); border-radius: var(--radius-sm);
    background: #fff; color: var(--slate);
}
.fz-icon-btn:hover { background: var(--header-row); color: var(--ink); }
.fz-topbar .fz-menu-btn { display: none; }

/* Search */
.fz-search { position: relative; flex: 1 1 280px; max-width: 480px; display: flex; align-items: center; }
.fz-search__icon { position: absolute; left: 12px; color: var(--muted); pointer-events: none; }
.fz-search__input {
    width: 100%; height: 40px; box-sizing: border-box;
    padding: 0 56px 0 40px;
    border: 1px solid var(--line); border-radius: var(--radius-sm);
    background: var(--header-row); color: var(--ink);
    font: 400 14px var(--font);
}
.fz-search__input::-webkit-search-cancel-button { display: none; }
.fz-search__kbd { position: absolute; right: 10px; font-family: var(--mono); font-size: 11px; color: var(--slate); border: 1px solid var(--line-strong); border-radius: 4px; padding: 2px 6px; background: #fff; }
.fz-search__list { position: absolute; top: 46px; left: 0; right: 0; z-index: 1040; margin: 0; padding: 6px; list-style: none; background: #fff; border: 1px solid var(--line); border-radius: var(--radius-md); box-shadow: var(--shadow-overlay); max-height: 320px; overflow-y: auto; }
.fz-search__list[hidden] { display: none; }
.fz-search__opt { display: flex; justify-content: space-between; gap: 12px; padding: 9px 10px; border-radius: var(--radius-sm); font-size: 14px; color: var(--ink); text-decoration: none; cursor: pointer; }
.fz-search__opt small { color: var(--muted); font-size: 12px; }
.fz-search__opt[aria-selected="true"], .fz-search__opt:hover { background: var(--header-row); color: var(--ink); }
.fz-search__empty { padding: 10px; font-size: 13px; color: var(--muted); }

/* Clock status chip (employee) */
.fz-clock-chip { height: 32px; padding: 0 14px; font-size: 13px; text-decoration: none; }
.fz-clock-chip:hover { filter: brightness(.97); }
.fz-clock-chip__time { font-weight: 500; font-variant-numeric: tabular-nums; }

/* Profile */
.fz-profile { height: 44px; border: 0; background: transparent; display: inline-flex; align-items: center; gap: 10px; padding: 0 4px; color: var(--ink); border-radius: var(--radius-sm); }
.fz-avatar-36 { width: 36px; height: 36px; flex: none; border-radius: 999px; object-fit: cover; display: inline-flex; align-items: center; justify-content: center; }
.fz-avatar-36--initials { background: var(--navy-100); color: var(--navy-800); font-weight: 700; font-size: 13px; }
.fz-profile__meta { display: flex; flex-direction: column; align-items: flex-start; line-height: 1.25; min-width: 0; }
.fz-profile__name { font-weight: 600; font-size: 14px; max-width: 160px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.fz-profile__sub { font-size: 12px; color: var(--muted); }
.fz-profile__caret { color: var(--muted); }
.fz-profile-menu { min-width: 240px; margin-top: 8px !important; }
.fz-profile-menu .dropdown-item { display: flex; align-items: center; gap: 10px; min-height: 40px; }
.fz-profile-menu__head { display: flex; flex-direction: column; padding: 8px 10px 10px; border-bottom: 1px solid var(--line-soft); margin-bottom: 6px; overflow-wrap: anywhere; }

/* ---------- Content --------------------------------------------------- */
.fz-content { flex: 1; width: 100%; max-width: 1312px; box-sizing: border-box; padding: 32px; display: flex; flex-direction: column; gap: 24px; }
.fz-content > .main-content { flex: 1; }
.fz-footer { padding-top: 16px; font-size: 12px; color: var(--muted); text-align: left; }

/* Page header: H1 + one-line subtitle on the left, at most one primary button on the right */
.fz-page-head { gap: 12px; margin-bottom: 24px; flex-wrap: wrap; align-items: flex-end; }
.fz-page-head-icon { display: none; }
.fz-page-title { font-size: 24px; line-height: 32px; font-weight: 700; letter-spacing: -.015em; }
.fz-page-subtitle { font-size: 14px; color: var(--muted); }

/* ---------- Drawer + phone (below 1024px) ----------------------------- */
.fz-scrim { display: none; }
@media (max-width: 1023.98px) {
    .fz-topbar .fz-menu-btn { display: inline-flex; }
    .fz-sidebar {
        position: fixed; z-index: 1050; top: 0; left: 0; bottom: 0;
        width: min(300px, 86vw);
        transform: translateX(-100%);
        visibility: hidden;
        transition: transform .2s ease, visibility 0s linear .2s;
        box-shadow: var(--shadow-overlay);
    }
    .fz-sidebar .fz-sidebar__close { display: inline-flex; }
    body.fz-nav-open .fz-sidebar { transform: none; visibility: visible; transition: transform .2s ease; }
    body.fz-nav-open .fz-scrim { display: block; position: fixed; inset: 0; z-index: 1045; background: rgba(16, 27, 51, .4); }
    body.fz-nav-open { overflow: hidden; }
    .fz-nav__item { height: 44px; }
    .fz-topbar { padding: 10px 16px; }
    .fz-content { padding: 24px 16px; }
}

/* Employee bottom tabs (below 768px) */
.fz-tabs { display: none; }
@media (max-width: 767.98px) {
    .fz-profile__meta, .fz-profile__caret { display: none; }
    .fz-search { flex-basis: 0; }
    .fz-search__kbd { display: none; }
    .fz-search__input { padding-right: 12px; }
    body.fz-has-tabs .fz-content { padding-bottom: 96px; }
    .fz-tabs {
        display: grid; grid-template-columns: repeat(5, minmax(0, 1fr));
        position: fixed; z-index: 1030; left: 0; right: 0; bottom: 0;
        height: 72px; background: var(--surface); border-top: 1px solid var(--line);
        padding-bottom: env(safe-area-inset-bottom);
    }
    .fz-tabs__item { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; min-height: 44px; font-size: 11px; font-weight: 500; text-decoration: none; color: var(--muted); }
    .fz-tabs__item.is-active { font-weight: 700; color: var(--navy-800); }
    .fz-clock-chip { max-width: calc(100vw - 150px); overflow: hidden; }
}
@media (max-width: 479.98px) {
    .fz-clock-chip__time { display: none; }
}
@media (prefers-reduced-motion: reduce) { .fz-sidebar { transition: none; } }

/* Legacy shim (until the Dashboard is rebuilt in Phase 3): wide team table scrolls in its card, not the page */
.fz-team-card { overflow-x: auto; }
