/* ===== RosterSure Base (Layout + Primitives) ===== */
:root{
  /* Brand + status */
  --brand:#2563EB; --brand-600:#1D4ED8; --accent:#F59E0B;
  --ok:#16A34A; --warn:#F59E0B; --bad:#DC2626; --info:#2563EB;

  /* Surface + text */
  --text:#0F172A; --muted:#64748B; --panel:#fff; --bg:#F8FAFC; --border:#E2E8F0; --bg2:#F1F5F9;

  /* Layout tokens */
  --content-max: 1200px;
  --radius-4:4px; --radius-6:6px; --radius-8:8px; --radius-12:12px;
  --shadow-1:0 4px 12px rgba(0,0,0,.06);
  --space-1:.25rem; --space-2:.5rem; --space-3:.75rem; --space-4:1rem; --space-5:1.25rem; --space-6:1.5rem;

  /* Type scale */
  --fs-12:.75rem; --fs-14:.875rem; --fs-16:1rem; --fs-18:1.125rem; --fs-24:1.5rem; --fs-32:2rem;

  /* Transitions */
  --transition-normal: 0.2s ease;
  --transition-fast: 0.15s ease;
}

*{ box-sizing:border-box; }
html:focus-within { scroll-behavior: smooth; }
@media (prefers-reduced-motion:reduce){ html:focus-within{ scroll-behavior: auto; } }

body{
  margin:0;
  background:var(--bg);
  color:var(--text);
  font: 15px/1.6 system-ui, Segoe UI, Inter, Roboto, Arial, sans-serif;
  overflow-x:hidden;
}

/* Improve default link styling */
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }

/* Skip link for keyboard users */
.skip-link{
  position:absolute; left:-999px; top:auto; width:1px; height:1px; overflow:hidden;
}
.skip-link:focus{
  position:fixed; left:var(--space-4); top:var(--space-4);
  width:auto; height:auto; padding:var(--space-3) var(--space-4);
  background:#fff; border:2px solid var(--brand); border-radius:var(--radius-8); z-index:3000;
}

/* Focus ring */
:where(a, button, input, select, textarea, [tabindex]):focus-visible{
  outline: 3px solid color-mix(in srgb, var(--brand), white 10%);
  outline-offset: 2px;
  border-radius: 6px;
}

/* ===== App Layout ===== */
.app{ display:flex; flex-direction:column; min-height:100vh; }
.main{ flex:1; width:100%; }

.container{
  width:100%;
  padding:var(--space-4);
  display:grid;
  gap:var(--space-4);
}

/* Sidebar (mobile-first) */
.aside{
  position:fixed; top:0; left:-240px; width:240px; height:100%;
  z-index:1000; background:#fff; border-right:1px solid var(--border);
  transition:left .25s ease; box-shadow: 2px 0 5px rgba(0,0,0,.08);
  display:flex; flex-direction:column;
}
.aside.open{ left:0; }

/* Mobile backdrop for drawer */
.sidebar-backdrop{
  position:fixed; inset:0; background:rgba(0,0,0,.3); z-index:900;
}
body.has-sidebar-open{ overflow:hidden; }

/* Brand */
.brand{ padding:16px; border-bottom:1px solid var(--border); display:flex; align-items:center; }
.brand__link{ display:flex; align-items:center; gap:10px; color:inherit; text-decoration:none; }
.brand__name{ font-weight:700; color:var(--text); }
.brand__tag{ font-size:12px; }

/* Primary nav */
.nav a{
  display:block; padding:10px 14px; border-radius:8px; margin:6px 8px;
  color:inherit; text-decoration:none;
}
.nav a:hover{ background:#f1f5f9; }
.nav a.active{ background:#e2e8f0; font-weight:600; }

/* Top bar */
.topbar{
  display:flex; justify-content:space-between; align-items:center;
  background:#fff; border-bottom:1px solid var(--border);
  padding:10px 16px; position:sticky; top:0; z-index:800;
}
.topbar__right{ display:flex; align-items:center; gap:1rem; }
.topbar .left-items{ display:flex; align-items:center; gap:1rem; }

.hamburger{ display:block; background:none; border:none; padding:6px; cursor:pointer; }
.hamburger-icon{ width:24px; height:24px; }

/* ===== Cards, tables, components ===== */
.card{
  background:var(--panel);
  border:1px solid var(--border);
  border-radius:var(--radius-12);
  overflow:hidden;
  box-shadow: var(--shadow-1);
}
.card .head{
  padding:12px 14px; border-bottom:1px solid var(--border);
  display:flex; flex-wrap:wrap; gap:10px; justify-content:space-between; align-items:center;
}
.card .body{ padding:12px 14px; }

/* Forms (baseline; page-specific CSS may refine) */
.form-group{ display:block; }
label{ display:block; font-weight:500; margin-bottom:.35rem; }
input, select, textarea{
  width:100%; padding:10px 12px; border:1px solid var(--border); border-radius:8px; font-size:var(--fs-16);
  background:#fff;
}
input::placeholder{ color:color-mix(in srgb, var(--muted), white 30%); }

/* --- Consolidated Button Styles --- */
.btn{
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-8);
  font-size: var(--fs-14);
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
  transition: all var(--transition-fast);
  background: var(--panel);
  color: var(--text);
}

.btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.1), 0 1px 2px 0 rgba(0, 0, 0, 0.06);
  text-decoration: none;
}

.btn-primary {
  background: var(--brand);
  border-color: var(--brand);
  color: white;
}
.btn-primary:hover {
  background: var(--brand-600);
  border-color: var(--brand-600);
}

.btn-secondary {
  background: var(--bg2);
  border-color: var(--border);
  color: var(--text);
}
.btn-secondary:hover {
  background: var(--border);
}

.btn-danger {
  background: var(--bad);
  border-color: var(--bad);
  color: white;
}
.btn-danger:hover {
  filter: brightness(0.9);
}

.btn-sm {
  padding: 0.5rem 1rem;
  font-size: var(--fs-14);
}

.btn-lg {
  padding: 0.875rem 1.75rem;
  font-size: 1rem;
}

/* Text helpers */
.muted{ color:var(--muted); }
[hidden]{ display:none !important; }

/* Tables */
.table-scroll{ overflow-x:auto; }
table{ width:100%; border-collapse:separate; border-spacing:0; min-width:600px; }
th, td{ padding:8px 10px; border-bottom:1px solid var(--border); text-align:left; vertical-align:middle; }
thead th{ background:#f8fafc; position:sticky; top:0; }

/* Optional: equal-width column helper */
.table-equal-cols{ table-layout:fixed; }
.table-equal-cols th:first-child,.table-equal-cols td:first-child{
  width:140px; overflow:hidden; text-overflow:ellipsis; white-space:nowrap;
}
.table-equal-cols th:nth-child(2),.table-equal-cols td:nth-child(2){ width:125px; }
.table-equal-cols th:nth-child(3),.table-equal-cols td:nth-child(3){ width:140px; }
.table-equal-cols th:nth-child(4),.table-equal-cols td:nth-child(4){ width:135px; }

/* Status pills */
.status-indicator{ display:inline-block; width:10px; height:10px; border-radius:50%; margin-right:8px; flex-shrink:0; }
.status-compliant{ background-color:var(--ok); }
.status-expiring{ background-color:var(--warn); }
.status-expired{ background-color:var(--bad); }
.status-unknown{ background-color:var(--border); }

/* Pagination */
.pagination-controls{
  display:flex; justify-content:space-between; align-items:center;
  padding-top:1rem; border-top:1px solid var(--border);
}

/* Mobile-first popover (already used on Dashboard) */
.popover-overlay{
  position:fixed; inset:0; background-color:rgba(0,0,0,.4);
  display:flex; justify-content:center; align-items:center; z-index:2000; padding:1rem;
  opacity:0; visibility:hidden; transition:opacity .2s ease, visibility .2s ease;
}
.popover-overlay.visible{ opacity:1; visibility:visible; }
.popover-content{
  background:#fff; border-radius:8px; padding:1.25rem; width:100%; max-width:360px;
  box-shadow:0 4px 12px rgba(0,0,0,.15); text-align:center; position:relative;
}
.popover-close{
  position:absolute; top:8px; right:10px; background:none; border:none; font-size:1.5rem; line-height:1; cursor:pointer; color:var(--muted);
}
.popover-trigger{ flex-shrink:0; }

/* Stat cards grid */
.stat-cards{ display:grid; grid-template-columns:repeat(2, 1fr); gap:1rem; }
@media (min-width:768px){ .stat-cards{ grid-template-columns:repeat(4, 1fr); } }

/* Visually hidden (but accessible) text */
.visually-hidden,
.sr-only {
  position: absolute !important;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}

/* ===================================================================
   Enhanced Topbar Styles
   =================================================================== */

.topbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: #fff;
    border-bottom: 1px solid var(--border);
    padding: 10px 16px;
    position: sticky;
    top: 0;
    z-index: 800;
}

.topbar__left, .topbar__right {
    flex: 1 0 0;
}

.topbar__right {
    display: flex;
    justify-content: flex-end;
}

.topbar__center {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    flex: 2 1 0;
}

.page-title {
    font-size: var(--fs-18);
    font-weight: 700;
    line-height: 1.2;
}

.user-info {
    display: flex;
    flex-direction: column;
    align-items: center;
    margin-top: 2px;
}

.user-name {
    font-size: var(--fs-14);
    color: var(--text);
}

.account-name {
    font-size: var(--fs-12);
}

/* === Desktop layout ≥ 901px (BASE — no header rules here) === */
@media (min-width: 901px){
  .main{
    display: grid;
    grid-template-columns: 1fr minmax(0, var(--content-max)) 1fr;
    padding-left: var(--space-4);
    padding-right: var(--space-4);
    width: 100%;
    box-sizing: border-box;
  }
  .main > *{
    grid-column: 2;
    max-width: none;
    width: auto;
    margin: 0;
    min-width: 0;
  }
  .main > .full-bleed{ grid-column: 1 / -1; width: 100%; }
}


/* === Desktop APP layout ≥ 901px (scoped) === */
@media (min-width: 901px){
  .app{
    display: grid;
    grid-template-columns: 240px 1fr;
    grid-template-rows: auto max-content 1fr;
    grid-template-areas:
      "aside topbar"
      "aside banner"
      "aside main";
  }
  .app .aside{
    grid-area: aside;
    position: sticky;
    top: 0;
    left: 0;
    height: 100vh;
    box-shadow: none;
    width: auto;
  }
  .app .topbar{ grid-area: topbar; }
  .app .trial-banner{ grid-area: banner; }
  .app .main{ grid-area: main; }

  /* App-only: sidebar backdrop disabled on desktop */
  .app .sidebar-backdrop{ display: none !important; }

  /* App-only: hide hamburger on desktop (sidebar is persistent) */
  .app :is(.hamburger, .menu-toggle, .nav-toggle, .header-toggle, [data-nav-toggle]){
    display: none !important;
  }
}

/* ===================================================================
   Public Header & Footer Styles
   =================================================================== */

/* Public Header */
.public-header {
    background: #fff;
    border-bottom: 1px solid var(--border);
    padding: var(--space-4) var(--space-lg);
    position: sticky;
    top: 0;
    z-index: 800;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
}

.header-container {
    max-width: 1200px;
    margin: 0 auto;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
}

.brand-link {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: var(--text);
    text-decoration: none;
    font-weight: 700;
    font-size: 1.125rem;
    transition: color var(--transition-fast);
}

.brand-link:hover {
    color: var(--brand);
    text-decoration: none;
}

.brand-link svg {
    color: var(--brand);
    flex-shrink: 0;
}

.brand-name {
    white-space: nowrap;
}

.public-nav {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex-wrap: wrap;
}

.public-nav > a:not(.btn) {
    color: var(--text);
    font-weight: 500;
    padding: 0.5rem 0.75rem;
    transition: color var(--transition-fast);
}

.public-nav > a:not(.btn):hover {
    color: var(--brand);
    text-decoration: none;
}

/* Responsive navigation */
@media (max-width: 600px) {
    .public-nav {
        gap: 0.5rem;
    }

    .public-nav > a:not(.btn) {
        display: none;
    }
}

/* Public Footer */
.public-footer {
    background: var(--bg2);
    border-top: 1px solid var(--border);
    padding: 2.5rem var(--space-lg);
    text-align: center;
    margin-top: auto;
}

.public-footer .container {
    max-width: 1024px;
    margin: 0 auto;
}

.public-footer nav {
    margin-bottom: 1rem;
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 0.5rem 1.5rem;
}

.public-footer nav a {
    color: var(--text);
    font-size: var(--fs-14);
    transition: color var(--transition-fast);
}

.public-footer nav a:hover {
    color: var(--brand);
    text-decoration: none;
}

.public-footer p {
    color: var(--muted);
    font-size: var(--fs-14);
    margin: 0;
}