/* ============================================================================
   static/css/base.css
   ========================================================================== */
/* ============================================================================
   BASE.CSS
   Global tokens, resets, layout shell, topbar, generic utilities & components.
   This file should be included on every page.
   ========================================================================== */

/* 1) Design Tokens (CSS Custom Properties) */
:root {
  --color-primary: #292661;   /* deep indigo (inverted bars) */
  --color-secondary: #313845; /* slate (content accents) */
  --color-accent: #a3adbf;    /* muted steel */
  --color-bg: #ffffff;        /* content cards bg */
  --color-bg-2: #f6f8fc;      /* app shell bg */

  --color-text: #111827;      /* content text */
  --color-text-dim: #4b5563;  /* content text dim */

  --radius-xl: 16px;
  --radius-lg: 12px;

  --shadow-1: 0 8px 20px rgba(0,0,0,0.07);
  --shadow-2: 0 10px 30px rgba(0,0,0,0.10);
  --ring: 0 2px 8px rgba(0,0,0,0.10);

  --transition-fast: 180ms cubic-bezier(.2,.8,.2,1);
  --transition-slow: 300ms cubic-bezier(.2,.8,.2,1);

  --sidebar-w: 210px;
  --sidebar-w-collapsed: 80px;
  --topbar-h: 64px;

  --shell-pad: clamp(10px, 2.2vw, 18px);
  --gap: 12px;
}

/* 2) Resets */
* { box-sizing: border-box; }
html, body { height: 100%; background: var(--color-bg-2); }
body {
  margin: 0;
  font-family: ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, "Helvetica Neue", Arial, "Noto Sans", "Apple Color Emoji", "Segoe UI Emoji";
  color: var(--color-text);
}

/* 3) Shell & App Layout */
.shell { min-height: 100vh; height: 100dvh; padding: var(--shell-pad); }

.app {
  display: grid;
  grid-template-rows: var(--topbar-h) minmax(0, 1fr);
  grid-template-columns: var(--sidebar-w) minmax(0, 1fr);
  grid-template-areas:
    "topbar topbar"
    "sidebar content";
  gap: var(--gap);
  height: 100%;
  min-height: 0;
  min-width: 0;
  overflow: hidden;
  transition: grid-template-columns var(--transition-slow);
}

.topbar { grid-area: topbar; min-width: 0; }
.sidebar { grid-area: sidebar; min-height: 0; min-width: 0; }
.content-area {
  grid-area: content;
  min-height: 0;
  min-width: 0;
  overflow: auto;
  padding: 20px;
  position: relative;
}

/* 4) Cards & Buttons */
.card { background: var(--color-bg); border-radius: var(--radius-xl); box-shadow: var(--shadow-1); }

.btn { cursor: pointer; border: 0; border-radius: 12px; padding: 12px 16px; font-weight: 600; }
.btn-primary { background: var(--color-primary); color: #fff;}
.btn-ghost { background: transparent; color: var(--color-primary); }
.btn-secondary { background: var(--color-secondary); color: #fff; }
.btn:active { transform: translateY(1px); }

.muted { color: var(--color-text-dim); }
.chip { background: #eceff6; color: #374151; padding: 4px 10px; border-radius: 999px; font-size: 12px; }
.icon { width: 20px; height: 20px; color: currentColor; }
.icon-lg { width: 24px; height: 24px; }

/* 5) Inverted Topbar (dark bg, white content) */
.topbar {
  position: sticky; top: 0; z-index: 40;
  display: flex; align-items: center; gap: 12px;
  background: var(--color-primary);
  border: 1px solid rgba(255,255,255,0.08);
  height: var(--topbar-h);
  padding: 0 16px;
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-1);
  color: #fff;
  overflow: hidden;
}
.brand { display: flex; align-items: center; gap: 12px; min-width: 0; flex: 1 1 auto; }
.brand-toggle {
  width: 36px; height: 36px; border-radius: 10px; background: rgba(255,255,255,0.16);
  display: grid; place-items: center; box-shadow: var(--shadow-1);
  border: none; cursor: pointer;
}
.brand-toggle:focus-visible { outline: 2px solid #fff; outline-offset: 2px; }
.brand-toggle svg { width: 22px; height: 22px; color: #fff; }
.brand-name {
  font-size: 18px;
  font-weight: 800;
  letter-spacing: .2px;
  color: #fff;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.topbar .chip { background: rgba(255,255,255,0.18); color: #fff; }

.topbar-right { margin-left: auto; display:flex; align-items:center; gap: 8px; flex: 0 0 auto; }
.topbar-form { margin: 0; display: inline-flex; }
.topbar .btn-ghost { color: #fff; border: 1px solid rgba(255,255,255,0.24); }
.topbar .btn-ghost:hover { background: rgba(255,255,255,0.10); }
.topbar .btn-primary { background: #fff; color: var(--color-primary); }

/* 6) Responsive Tweaks */
@media (max-width: 1200px) {
  :root{ --sidebar-w: 260px; --sidebar-w-collapsed: 78px; }
}
@media (max-width: 980px) {
  .topbar .chip { display: none; }
  .topbar-right .btn-ghost { display: none; }
}
@media (max-width: 760px) {
  .topbar-right { display: none; }
  .brand-name { font-size: 16px; }
}
@media (max-width: 720px) {
  :root{ --shell-pad: 8px; --gap: 10px; }
}

@media (max-height: 860px) {
  :root { --topbar-h: 56px; --shell-pad: 8px; --gap: 8px; }

  .topbar { padding: 0 12px; }
  .brand-name { font-size: 16px; }
  .topbar .chip { display: none; }

  .topbar .btn {
    padding: 0.4rem 0.75rem;
    font-size: 13px;
  }
}
a.btn,
button.btn {
  display: inline-flex;         /* consistent layout */
  align-items: center;          /* vertical centering */
  justify-content: center;      /* horizontal centering */
  padding: 0.5rem 1rem;         /* same spacing */
  font-size: 14px;              /* lock in font size */
  line-height: 1.2;             /* avoid inherited line-height issues */
  border: none;                 /* buttons already have this, links don’t */
  text-decoration: none;        /* remove underline */
  cursor: pointer;              /* make link behave like button */
}

/* remove padding for specific pages */
.content-area.no-pad { padding: 0; }

