/* ==========================================================================
   Biritex SMS Reach brand palette: white, deep navy and teal.
   Supporting shades are mixed from these colors for readable UI states.
   ========================================================================== */

:root {
    --color-primary: #087F8C;
    --color-neutral: #001214;
    --color-accent:  #01535c;

    /* Surfaces */
    --bg:           #FFFFFF;
    --surface:      #FFFFFF;
    --surface-alt:  color-mix(in srgb, var(--color-neutral) 3%, white);

    /* Text */
    --text:         var(--color-neutral);
    --text-muted:   color-mix(in srgb, var(--color-neutral) 55%, white);
    --text-invert:  #FFFFFF;

    /* Borders & focus */
    --border:       color-mix(in srgb, var(--color-neutral) 12%, white);
    --border-strong:color-mix(in srgb, var(--color-neutral) 22%, white);
    --focus-ring:   color-mix(in srgb, var(--color-primary) 35%, white);

    /* Primary states */
    --primary-100:  color-mix(in srgb, var(--color-primary) 8%, white);
    --primary-200:  color-mix(in srgb, var(--color-primary) 16%, white);
    --primary-600:  var(--color-primary);
    --primary-700:  color-mix(in srgb, var(--color-primary) 85%, black);

    /* Accent states */
    --accent-100:   color-mix(in srgb, var(--color-accent) 14%, white);
    --accent-600:   var(--color-accent);

    /* Semantic helpers */
    --success:      #00b828;
    --danger:       #db0000;
    --danger-100:   color-mix(in srgb, var(--color-neutral) 8%, white);

    /* Spacing scale (8px base) */
    --sp-1: 4px;  --sp-2: 8px;  --sp-3: 12px; --sp-4: 16px;
    --sp-5: 24px; --sp-6: 32px; --sp-7: 48px; --sp-8: 64px;

    /* Radii */
    --r-sm: 6px;
    --r-md: 10px;
    --r-lg: 14px;
    --r-pill: 999px;

    /* Shadows */
    --sh-1: 0 1px 2px rgba(18, 48, 71, .06), 0 1px 1px rgba(18, 48, 71, .04);
    --sh-2: 0 4px 12px rgba(18, 48, 71, .08), 0 2px 4px rgba(18, 48, 71, .04);
    --sh-3: 0 12px 32px rgba(18, 48, 71, .12), 0 4px 8px rgba(18, 48, 71, .06);

    /* Motion */
    --ease: cubic-bezier(.2, .7, .2, 1);
    --dur-1: 120ms;
    --dur-2: 180ms;
    --dur-3: 260ms;

    --sidebar-w: 240px;
    --topbar-h: 60px;
}

@font-face {
    font-family: "Poppins";
    font-style: normal;
    font-weight: 400;
    font-display: swap;
    src: url("../fonts/poppins-regular.woff2") format("woff2");
}
@font-face {
    font-family: "Poppins";
    font-style: normal;
    font-weight: 500;
    font-display: swap;
    src: url("../fonts/poppins-medium.woff2") format("woff2");
}
@font-face {
    font-family: "Poppins";
    font-style: normal;
    font-weight: 600;
    font-display: swap;
    src: url("../fonts/poppins-semibold.woff2") format("woff2");
}
@font-face {
    font-family: "Poppins";
    font-style: normal;
    font-weight: 700;
    font-display: swap;
    src: url("../fonts/poppins-bold.woff2") format("woff2");
}
@font-face {
    font-family: "Poppins";
    font-style: normal;
    font-weight: 800;
    font-display: swap;
    src: url("../fonts/poppins-extrabold.woff2") format("woff2");
}

@media (prefers-reduced-motion: reduce) {
    :root { --dur-1: 0ms; --dur-2: 0ms; --dur-3: 0ms; }
    * { animation-duration: 0ms !important; transition-duration: 0ms !important; }
}

/* ==========================================================================
   Reset
   ========================================================================== */
*, *::before, *::after { box-sizing: border-box; }
* { margin: 0; }
html, body { height: 100%; }
body {
    font-family: "Poppins", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    font-size: 15px;
    line-height: 1.5;
    color: var(--text);
    background: var(--bg);
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
}
img, svg, video { display: block; max-width: 100%; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--primary-600); text-decoration: none; }
a:hover { text-decoration: underline; }
:focus-visible { outline: 2px solid var(--focus-ring); outline-offset: 2px; border-radius: var(--r-sm); }
[hidden] { display: none !important; }

/* ==========================================================================
   App shell
   ========================================================================== */
.app-shell {
    display: grid;
    grid-template-columns: var(--sidebar-w) 1fr;
    min-height: 100dvh;
}
.app-main {
    display: flex;
    flex-direction: column;
    min-width: 0;
}
.app-content {
    flex: 1;
    padding: var(--sp-5);
    max-width: 1200px;
    width: 100%;
    margin-inline: auto;
    animation: fade-slide var(--dur-3) var(--ease) both;
}

@keyframes fade-slide {
    from { opacity: 0; transform: translateY(4px); }
    to   { opacity: 1; transform: translateY(0); }
}

.skip-link {
    position: absolute; left: -9999px; top: 8px;
    background: var(--color-neutral); color: white;
    padding: 8px 12px; border-radius: var(--r-sm); z-index: 100;
}
.skip-link:focus { left: 8px; }

/* ==========================================================================
   Sidebar
   ========================================================================== */
.sidebar {
    background: var(--surface);
    border-right: 1px solid var(--border);
    padding: var(--sp-4) 0;
    display: flex;
    flex-direction: column;
    position: sticky; top: 0; height: 100dvh;
    z-index: 40;
}
.sidebar-head {
    display: flex; align-items: center; gap: var(--sp-2);
    padding: 0 var(--sp-5) var(--sp-4);
    border-bottom: 1px solid var(--border);
    margin-bottom: var(--sp-3);
}
.brand-logo { width: 32px; height: 32px; flex: none; }
.brand-name { font-weight: 750; font-size: 17px; letter-spacing: -.045em; }
.sidebar-close {
    display: none;
    margin-left: auto;
    background: transparent; border: 0;
    font-size: 24px; line-height: 1; cursor: pointer;
    color: var(--text-muted);
}

.sidebar-nav { padding: var(--sp-2) var(--sp-2); display: flex; flex-direction: column; gap: 2px; }
.nav-item {
    display: flex; align-items: center; gap: var(--sp-3);
    padding: 10px var(--sp-3);
    border-radius: var(--r-md);
    color: var(--text);
    font-weight: 500;
    transition: background var(--dur-1) var(--ease), color var(--dur-1) var(--ease);
}
.nav-item:hover { background: var(--surface-alt); text-decoration: none; }
.nav-item.is-active { background: var(--primary-100); color: var(--primary-700); }
.nav-icon { width: 18px; height: 18px; flex: none; }
.nav-divider {
    margin: var(--sp-4) var(--sp-3) var(--sp-2);
    font-size: 11px; text-transform: uppercase; letter-spacing: .08em;
    color: var(--text-muted); font-weight: 600;
}
.sidebar-backdrop {
    position: fixed; inset: 0; background: rgba(18,48,71,.4);
    z-index: 39; opacity: 0; transition: opacity var(--dur-2) var(--ease);
}
.sidebar-backdrop.is-open { opacity: 1; }

/* ==========================================================================
   Topbar
   ========================================================================== */
.topbar {
    height: var(--topbar-h);
    display: flex; align-items: center; gap: var(--sp-3);
    padding: 0 var(--sp-5);
    background: color-mix(in srgb, var(--surface) 88%, transparent);
    backdrop-filter: saturate(180%) blur(8px);
    border-bottom: 1px solid var(--border);
    position: sticky; top: 0; z-index: 30;
}
.topbar-org { font-weight: 600; }
.topbar-title { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.topbar-actions { display: flex; align-items: center; gap: var(--sp-3); }

.icon-btn {
    display: none;
    background: transparent; border: 1px solid var(--border);
    width: 38px; height: 38px; border-radius: var(--r-md);
    align-items: center; justify-content: center; cursor: pointer;
    color: var(--text);
    transition: background var(--dur-1) var(--ease);
}
.icon-btn:hover { background: var(--surface-alt); }
.icon-btn svg { width: 18px; height: 18px; }

.credit-chip {
    display: inline-flex; align-items: center; gap: var(--sp-2);
    background: var(--accent-100);
    color: color-mix(in srgb, var(--color-accent) 80%, black);
    border: 1px solid color-mix(in srgb, var(--color-accent) 35%, white);
    padding: 6px 12px; border-radius: var(--r-pill);
    font-weight: 600; font-size: 13px;
}
.credit-chip-dot {
    width: 8px; height: 8px; border-radius: 50%;
    background: var(--color-accent);
    animation: pulse 2.4s var(--ease) infinite;
}
.credit-chip-label { font-weight: 500; opacity: .8; }

@keyframes pulse {
    0%, 100% { transform: scale(1); opacity: 1; }
    50% { transform: scale(1.25); opacity: .6; }
}

.user-menu { position: relative; }
.user-trigger {
    display: inline-flex; align-items: center; gap: var(--sp-2);
    background: transparent; border: 1px solid var(--border);
    padding: 4px 8px 4px 4px; border-radius: var(--r-pill);
    cursor: pointer;
    transition: background var(--dur-1) var(--ease), border-color var(--dur-1) var(--ease);
}
.user-trigger:hover { background: var(--surface-alt); border-color: var(--border-strong); }
.avatar {
    width: 28px; height: 28px; border-radius: 50%;
    background: var(--primary-100); color: var(--primary-700);
    display: inline-flex; align-items: center; justify-content: center;
    font-weight: 700; font-size: 12px;
}
.user-name { font-weight: 500; font-size: 13px; }
.chev { width: 14px; height: 14px; transition: transform var(--dur-1) var(--ease); }
.user-trigger[aria-expanded="true"] .chev { transform: rotate(180deg); }

.user-menu-pop {
    position: absolute; right: 0; top: calc(100% + 8px);
    min-width: 180px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--r-md);
    box-shadow: var(--sh-3);
    padding: 6px;
    z-index: 50;
    animation: pop var(--dur-2) var(--ease) both;
}
.user-menu-pop a,
.user-menu-pop button {
    display: block; width: 100%; text-align: left;
    padding: 8px 12px; border-radius: var(--r-sm);
    background: transparent; border: 0; cursor: pointer;
    color: var(--text); text-decoration: none; font-size: 14px;
}
.user-menu-pop a:hover,
.user-menu-pop button:hover { background: var(--surface-alt); text-decoration: none; }

@keyframes pop {
    from { opacity: 0; transform: translateY(-4px) scale(.98); }
    to   { opacity: 1; transform: translateY(0)    scale(1); }
}

/* ==========================================================================
   Typography helpers
   ========================================================================== */
.page-header { display: flex; align-items: flex-end; justify-content: space-between; gap: var(--sp-4); margin-bottom: var(--sp-5); flex-wrap: wrap; }
.page-title { font-size: 22px; font-weight: 700; letter-spacing: -.02em; }
.page-sub   { color: var(--text-muted); font-size: 14px; margin-top: 4px; }
.section-title { font-size: 16px; font-weight: 600; margin-bottom: var(--sp-3); }

/* ==========================================================================
   Responsive
   ========================================================================== */
@media (max-width: 900px) {
    .app-shell { grid-template-columns: 1fr; }
    .sidebar {
        position: fixed; inset: 0 auto 0 0; width: 84vw; max-width: 320px;
        transform: translateX(-100%);
        transition: transform var(--dur-3) var(--ease);
        box-shadow: var(--sh-3);
    }
    .sidebar.is-open { transform: translateX(0); }
    .sidebar-close { display: inline-block; }
    .icon-btn { display: inline-flex; }
    .app-content { padding: var(--sp-4); }
    .topbar { padding: 0 var(--sp-4); }
    .user-name { display: none; }
    .credit-chip-label { display: none; }
}
@media (max-width: 480px) {
    .page-title { font-size: 19px; }
    .app-content { padding: var(--sp-3); }
}