/*
 * Library Name: Shared Layout
 * Current Version: 0.2.0
 * Last Updated: 2026-09-07
 * Maintainer: DAWG
 * Purpose: Provide responsive dashboard, sidebar, card, and frame layout styles.
 * Public API: CSS classes and data-state selectors used by the dashboard shell.
 * Dependencies: shared/css/tokens.css.
 * Used By: DAWG Staff Tools dashboard.
 */
.app-shell {
  min-height: 100vh;
  min-height: 100dvh;
  display: grid;
  grid-template-columns: var(--sidebar-expanded) minmax(0, 1fr);
  transition: grid-template-columns .2s ease;
}

body.sidebar-collapsed .app-shell {
  grid-template-columns: var(--sidebar-collapsed) minmax(0, 1fr);
}

body.sidebar-collapsed.sidebar-peek .app-shell {
  grid-template-columns: var(--sidebar-expanded) minmax(0, 1fr);
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
  background: #10344f;
  color: white;
  border-right: 1px solid rgba(255,255,255,.08);
  z-index: 40;
}

.sidebar-inner {
  height: 100%;
  display: flex;
  flex-direction: column;
}

.sidebar-brand {
  height: var(--header-height);
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 16px;
  border-bottom: 1px solid rgba(255,255,255,.10);
  text-decoration: none;
  white-space: nowrap;
}

.brand-mark {
  flex: 0 0 44px;
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  border-radius: 14px;
  background: rgba(255,255,255,.12);
  font-size: 23px;
}

.brand-mark img {
  width: 40px;
  height: 40px;
  object-fit: contain;
}

.brand-copy {
  min-width: 0;
  transition: opacity .18s ease, width .18s ease;
}

.brand-copy strong,
.brand-copy span {
  display: block;
}

.brand-copy span {
  color: rgba(255,255,255,.66);
  font-size: 12px;
  margin-top: 2px;
}

body.sidebar-collapsed .brand-copy,
body.sidebar-collapsed .nav-label,
body.sidebar-collapsed .nav-section-title,
body.sidebar-collapsed .sidebar-footer-copy {
  opacity: 0;
  width: 0;
  overflow: hidden;
  pointer-events: none;
}

body.sidebar-collapsed.sidebar-peek .brand-copy,
body.sidebar-collapsed.sidebar-peek .nav-label,
body.sidebar-collapsed.sidebar-peek .nav-section-title,
body.sidebar-collapsed.sidebar-peek .sidebar-footer-copy {
  opacity: 1;
  width: auto;
  overflow: visible;
  pointer-events: auto;
}

.nav {
  flex: 1;
  overflow-y: auto;
  padding: 14px 10px;
}

.nav-section-title {
  padding: 10px 12px 8px;
  color: rgba(255,255,255,.45);
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: .12em;
  white-space: nowrap;
}

.nav-link {
  min-height: 48px;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 12px;
  border-radius: 12px;
  text-decoration: none;
  color: rgba(255,255,255,.84);
  margin-bottom: 5px;
}

.nav-link:hover,
.nav-link.active {
  color: white;
  background: rgba(255,255,255,.12);
}

.nav-icon {
  flex: 0 0 32px;
  width: 32px;
  text-align: center;
  font-size: 19px;
}

.nav-icon svg {
  display: block;
  width: 20px;
  height: 20px;
  margin: auto;
  fill: currentColor;
}

.nav-label {
  display: block;
  min-width: 0;
  flex: 1 1 auto;
  white-space: nowrap;
  transition: opacity .18s ease, width .18s ease;
}

.sidebar-footer {
  padding: 12px;
  border-top: 1px solid rgba(255,255,255,.10);
}

.sidebar-toggle {
  width: 100%;
  min-height: 44px;
  display: flex;
  align-items: center;
  gap: 12px;
  border: 0;
  border-radius: 11px;
  padding: 0 11px;
  background: rgba(255,255,255,.10);
  color: white;
  cursor: pointer;
}

.main-area {
  min-width: 0;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  height: var(--header-height);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 0 max(clamp(16px, 3vw, 32px), env(safe-area-inset-right)) 0 max(clamp(16px, 3vw, 32px), env(safe-area-inset-left));
  background: rgba(255,255,255,.9);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(15px);
}

[data-theme="dark"] .topbar { background: rgba(26,34,41,.92); }

.theme-toggle {
  min-height: 38px;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 7px 11px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
}

.topbar-layout {
  min-height: 38px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.topbar-layout[hidden] { display: none; }

.topbar-layout select {
  min-height: 38px;
  padding: 7px 30px 7px 10px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
  color: var(--text);
  font: inherit;
}

.topbar h1 {
  margin: 0;
  font-size: 20px;
  letter-spacing: -.02em;
}

.topbar-meta {
  color: var(--muted);
  font-size: 13px;
}

.content {
  width: min(1320px, calc(100% - 32px));
  margin: 0 auto;
  padding: 28px 0 56px;
}

.hero {
  padding: clamp(24px, 5vw, 48px);
  border-radius: var(--radius-lg);
  color: white;
  background: linear-gradient(135deg, #0f4f83, #1d79b9);
  box-shadow: var(--shadow-md);
}

.hero h2 {
  margin: 0 0 10px;
  font-size: clamp(30px, 4vw, 48px);
  letter-spacing: -.04em;
  line-height: 1.05;
}

.hero p {
  margin: 0;
  max-width: 760px;
  color: rgba(255,255,255,.86);
  font-size: 17px;
  line-height: 1.55;
}

.section-heading {
  display: flex;
  justify-content: space-between;
  align-items: end;
  gap: 20px;
  margin: 30px 0 14px;
}

.section-heading h3 {
  margin: 0;
  font-size: 22px;
}

.section-heading p {
  margin: 4px 0 0;
  color: var(--muted);
}

.tool-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(245px, 1fr));
  gap: 18px;
}

.tool-card {
  min-height: 190px;
  display: flex;
  flex-direction: column;
  position: relative;
  padding: 22px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
  text-decoration: none;
  transition: transform .18s ease, box-shadow .18s ease, border-color .18s ease;
}

.tool-card:hover {
  transform: translateY(-3px);
  border-color: #9dc4df;
  box-shadow: var(--shadow-md);
}

@media (hover: none) {
  .tool-card:hover { transform: none; }
}

.tool-card.disabled {
  opacity: .66;
}

.tool-card .icon {
  width: 48px;
  height: 48px;
  display: grid;
  place-items: center;
  border-radius: 14px;
  background: var(--accent-soft);
  font-size: 24px;
}

.tool-card h4 {
  margin: 18px 0 8px;
  font-size: 20px;
}

.tool-card p {
  margin: 0;
  color: var(--muted);
  line-height: 1.5;
}

.tool-card .status {
  margin-top: auto;
  padding-top: 18px;
  color: var(--accent-strong);
  font-size: 14px;
  font-weight: 800;
}

.dashboard-footer {
  margin-top: 30px;
  color: var(--muted);
  font-size: 13px;
  text-align: center;
}

.badge {
  position: absolute;
  top: 16px;
  right: 16px;
  padding: 6px 9px;
  border-radius: 999px;
  background: var(--surface-3);
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: .06em;
}

.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
}

.sidebar-scrim { display: none; }

@media (max-width: 820px) {
  .app-shell,
  body.sidebar-collapsed .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    width: min(86vw, 300px);
    padding-left: env(safe-area-inset-left);
    transform: translateX(-100%);
    transition: transform .2s ease;
    box-shadow: 20px 0 50px rgba(0,0,0,.25);
  }

  body.sidebar-open .sidebar { transform: translateX(0); }

  /* A desktop-collapsed preference must not hide labels in the mobile drawer. */
  body.sidebar-collapsed .sidebar .brand-copy,
  body.sidebar-collapsed .sidebar .nav-label,
  body.sidebar-collapsed .sidebar .sidebar-footer-copy {
    opacity: 1;
    width: auto;
    overflow: visible;
    pointer-events: auto;
  }

  .sidebar-scrim {
    position: fixed;
    inset: 0;
    z-index: 35;
    display: block;
    border: 0;
    padding: 0;
    background: rgba(0,0,0,.45);
    opacity: 0;
    pointer-events: none;
    transition: opacity .2s ease;
  }

  body.sidebar-open .sidebar-scrim { opacity: 1; pointer-events: auto; }

  .mobile-menu-button {
    display: inline-grid !important;
  }

  .content {
    width: min(100% - 20px, 1320px);
    padding-top: 18px;
  }

  .topbar-layout > span { display: none; }
  .topbar-layout select { max-width: 150px; }
}

.mobile-menu-button {
  display: none;
  width: 42px;
  height: 42px;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 11px;
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
}

.tool-frame {
  display: block;
  width: 100%;
  height: calc(100vh - var(--header-height));
  height: calc(100dvh - var(--header-height));
  border: 0;
  background: var(--bg);
}

.tool-frame[hidden] { display: none; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition-duration: .01ms !important; animation-duration: .01ms !important; animation-iteration-count: 1 !important; }
}
