/* ── Reset & base ─────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html {
  font-size: var(--font-size-base);
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
}

body {
  font-family: var(--font-base);
  font-size: 1rem;
  line-height: 1.6;
  color: var(--color-text);
  background: var(--color-surface);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* ── Custom scrollbar ─────────────────────────────────────────────────────── */
::-webkit-scrollbar              { width: 6px; height: 6px; }
::-webkit-scrollbar-track        { background: transparent; }
::-webkit-scrollbar-thumb        { background: var(--color-border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover  { background: var(--color-text-muted); }

/* ── Focus ring ───────────────────────────────────────────────────────────── */
:focus-visible {
  outline: 2px solid var(--color-border-focus);
  outline-offset: 2px;
  border-radius: var(--radius-sm);
}
:focus:not(:focus-visible) { outline: none; }

/* ── Links ────────────────────────────────────────────────────────────────── */
a {
  color: var(--color-primary);
  text-decoration: none;
  transition: color var(--transition-fast);
}
a:hover { text-decoration: underline; }

/* ── Images & media ───────────────────────────────────────────────────────── */
img, svg { display: block; max-width: 100%; }

/* ── Typography ───────────────────────────────────────────────────────────── */
h1, h2, h3, h4 {
  line-height: 1.25;
  font-weight: 700;
  color: var(--color-text);
  letter-spacing: -0.02em;
}

h1 { font-size: 1.875rem; }
h2 { font-size: 1.375rem; }
h3 { font-size: 1.125rem; }
h4 { font-size: 1rem; }

p { margin-bottom: var(--space-md); }
p:last-child { margin-bottom: 0; }

code, pre {
  font-family: var(--font-mono);
  font-size: 0.875em;
  background: var(--color-surface);
  border-radius: var(--radius-sm);
}

code { padding: 1px 5px; border: 1px solid var(--color-border); }

hr {
  border: none;
  border-top: 1px solid var(--color-border);
  margin: var(--space-lg) 0;
}

/* ── App layout — sidebar model ───────────────────────────────────────────── */
/* Sidebar is position:fixed independently; app-main just clears it with margin */
.app-main {
  margin-left: var(--sidebar-width, 240px);
  min-height: 100vh;
  background: var(--color-surface);
  transition: margin-left var(--transition-base);
}

.page-body {
  padding: var(--space-xl) var(--space-xl) var(--space-2xl);
  max-width: 1400px;
  animation: fadeIn 0.2s ease;
}

/* Legacy container — max-width clamp for wide screens */
.container {
  width: 100%;
  max-width: 1200px;
  margin: 0 auto;
}

.container--narrow { max-width: 680px; }
.container--wide   { max-width: 1440px; }

/* ── Auth layout (signup / recover — centred single column) ──────────────── */
.auth-wrap {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: var(--color-auth-bg);
  padding: var(--space-xl) var(--space-md);
}

.auth-logo {
  font-size: 2rem;
  font-weight: 700;
  color: var(--color-auth-logo);
  letter-spacing: -0.04em;
  margin-bottom: var(--space-xs);
  text-decoration: none;
}
.auth-logo:hover { text-decoration: none; }
.auth-logo span  { color: var(--color-primary-light); }

.auth-tagline {
  font-size: 0.875rem;
  color: var(--color-auth-tagline);
  margin-bottom: var(--space-xl);
  letter-spacing: 0.01em;
}

.auth-card {
  background: var(--color-bg);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-lg);
  padding: var(--space-xl) var(--space-2xl);
  width: 100%;
  max-width: 420px;
  animation: slideUp 0.3s ease;
}

.auth-card h1 {
  font-size: 1.375rem;
  margin-bottom: var(--space-lg);
}

.auth-footer {
  margin-top: var(--space-lg);
  font-size: 0.875rem;
  color: var(--color-auth-footer);
  text-align: center;
}

.auth-footer a { color: var(--color-primary-light); }
.auth-footer a:hover { text-decoration: underline; }

/* ── Auth split layout (login page) ──────────────────────────────────────── */
.auth-split {
  display: grid;
  grid-template-columns: 1fr 480px;
  min-height: 100vh;
}

/* Hero — left panel */
.auth-hero {
  position: relative;
  background-image: url('https://images.unsplash.com/photo-1477959858617-67f85cf4f1df?auto=format&fit=crop&w=1920&q=80');
  background-size: cover;
  background-position: center;
  display: flex;
  align-items: flex-end;
  padding: var(--space-2xl);
}

.auth-hero::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(
    160deg,
    rgba(0,0,0,0.55) 0%,
    rgba(0,0,0,0.3) 50%,
    rgba(0,0,0,0.75) 100%
  );
}

.auth-hero__inner {
  position: relative;
  z-index: 1;
  max-width: 520px;
}

.auth-hero__logo {
  font-size: 2.5rem;
  font-weight: 800;
  letter-spacing: -0.05em;
  color: #fff;
  margin-bottom: var(--space-xs);
  display: block;
}

.auth-hero__logo span { color: #c9a84c; }

.auth-hero__tagline {
  font-size: 0.9rem;
  color: rgba(255,255,255,0.65);
  margin-bottom: var(--space-xl);
  letter-spacing: 0.03em;
  text-transform: uppercase;
}

.auth-hero__quote {
  font-size: 1.1rem;
  font-style: italic;
  color: rgba(255,255,255,0.9);
  line-height: 1.6;
  border-left: 3px solid #c9a84c;
  padding-left: var(--space-md);
  margin: 0;
}

.auth-hero__quote cite {
  display: block;
  margin-top: var(--space-sm);
  font-size: 0.8rem;
  font-style: normal;
  color: rgba(255,255,255,0.5);
  letter-spacing: 0.04em;
}

/* Form — right panel */
.auth-panel {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: var(--space-2xl) var(--space-xl);
  background: var(--color-bg);
  gap: var(--space-md);
}

.auth-panel .auth-card {
  max-width: 100%;
  box-shadow: none;
  border: 1px solid var(--color-border);
  animation: slideUp 0.35s ease;
}

.auth-panel .auth-card h1 {
  font-size: 1.5rem;
  margin-bottom: var(--space-lg);
}

.auth-panel .auth-footer {
  color: var(--color-text-muted);
  margin-top: 0;
}

@media (max-width: 768px) {
  .auth-split              { grid-template-columns: 1fr; }
  .auth-hero               { display: none; }
  .auth-panel              { padding: var(--space-xl) var(--space-md); }
  .auth-panel .auth-card   { border: none; box-shadow: none; padding: var(--space-lg) 0; }
}

/* ── Page transitions ─────────────────────────────────────────────────────── */
@keyframes slideUp {
  from { opacity: 0; transform: translateY(12px); }
  to   { opacity: 1; transform: translateY(0); }
}

@keyframes fadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}

/* ── Utilities ────────────────────────────────────────────────────────────── */
.text-muted   { color: var(--color-text-muted); }
.text-sm      { font-size: 0.875rem; }
.text-xs      { font-size: 0.75rem; }
.text-center  { text-align: center; }
.text-right   { text-align: right; }
.text-danger  { color: var(--color-danger); }
.text-success { color: var(--color-success); }

.font-mono    { font-family: var(--font-mono); }
.font-bold    { font-weight: 700; }
.font-medium  { font-weight: 500; }

.mt-xs  { margin-top: var(--space-xs); }
.mt-sm  { margin-top: var(--space-sm); }
.mt-md  { margin-top: var(--space-md); }
.mt-lg  { margin-top: var(--space-lg); }
.mt-xl  { margin-top: var(--space-xl); }
.mb-sm  { margin-bottom: var(--space-sm); }
.mb-md  { margin-bottom: var(--space-md); }
.mb-lg  { margin-bottom: var(--space-lg); }

.d-flex       { display: flex; }
.d-inline     { display: inline; }
.d-none       { display: none; }
.gap-xs       { gap: var(--space-xs); }
.gap-sm       { gap: var(--space-sm); }
.gap-md       { gap: var(--space-md); }
.gap-lg       { gap: var(--space-lg); }
.align-center { align-items: center; }
.align-start  { align-items: flex-start; }
.justify-between { justify-content: space-between; }
.justify-center  { justify-content: center; }
.flex-wrap    { flex-wrap: wrap; }
.flex-1       { flex: 1; }
.w-full       { width: 100%; }
.ml-sm        { margin-left: var(--space-sm); }
.ml-auto      { margin-left: auto; }
.truncate     { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ── Selection ────────────────────────────────────────────────────────────── */
::selection {
  background: var(--color-primary-light);
  color: var(--color-primary-dark);
}

/* ── Print ────────────────────────────────────────────────────────────────── */
@media print {
  .sidebar, .btn, .task-row__actions, .chat-input-bar { display: none !important; }
  .app-main   { margin-left: 0; }
  .page-body  { padding: 0; }
  body        { background: white; color: black; }
  a           { color: black; text-decoration: underline; }
}

/* ── Mobile responsive ────────────────────────────────────────────────────── */
@media (max-width: 768px) {
  .app-main   { margin-left: 0; }
  .page-body  { padding: var(--space-md) var(--space-md) var(--space-2xl); }
  h1          { font-size: 1.5rem; }
  .auth-card  { padding: var(--space-lg); }
}
