/* App shell + shared components. Semantic classes only — no utility framework. */

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  height: 100%;
}

body {
  font-family: var(--font);
  font-size: var(--text-base);
  color: var(--ink);
  background: var(--surface-2);
}

a {
  color: var(--blue);
}

/* ---- Shell: header on top, sidebar + main below ---- */
.shell {
  display: grid;
  grid-template-rows: var(--header-height) 1fr;
  grid-template-columns: var(--sidebar-width) 1fr;
  grid-template-areas:
    "header header"
    "sidebar main";
  height: 100vh;
}

.shell--bare {
  grid-template-columns: 1fr;
  grid-template-areas:
    "header"
    "main";
}

.header {
  grid-area: header;
  display: flex;
  align-items: center;
  gap: var(--space-4);
  padding: 0 var(--space-4);
  background: var(--surface);
  border-bottom: 1px solid var(--line);
}

.header__brand {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  font-weight: 600;
  font-size: var(--text-lg);
  color: var(--ink);
  text-decoration: none;
}

.header__brand-mark {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--blue) 0%, var(--leaf) 100%);
}

.header__spacer {
  flex: 1;
}

.header__user {
  color: var(--ink-soft);
  font-size: var(--text-sm);
}

.sidebar {
  grid-area: sidebar;
  background: var(--surface);
  border-right: 1px solid var(--line);
  overflow-y: auto;
  padding: var(--space-3);
}

.main {
  grid-area: main;
  overflow-y: auto;
  padding: var(--space-6);
}

/* ---- Buttons ---- */
.btn {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-4);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--ink);
  font-size: var(--text-sm);
  font-family: inherit;
  cursor: pointer;
  text-decoration: none;
}

.btn:hover {
  background: var(--surface-2);
}

.btn--primary {
  background: var(--blue);
  border-color: var(--blue);
  color: #fff;
}

.btn--primary:hover {
  background: var(--blue-deep);
}

.btn--leaf {
  background: var(--leaf);
  border-color: var(--leaf);
  color: #fff;
}

.btn--leaf:hover {
  background: var(--leaf-deep);
}

/* ---- Forms ---- */
.field {
  margin-bottom: var(--space-4);
}

.field label {
  display: block;
  margin-bottom: var(--space-1);
  font-size: var(--text-sm);
  color: var(--ink-soft);
}

.field input,
.field textarea,
.field select {
  width: 100%;
  padding: var(--space-2) var(--space-3);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  font-family: inherit;
  font-size: var(--text-base);
  background: var(--surface);
  color: var(--ink);
}

.field input:focus,
.field textarea:focus {
  outline: 2px solid var(--blue-soft);
  border-color: var(--blue);
}

.errorlist {
  margin: var(--space-1) 0;
  padding: 0;
  list-style: none;
  color: var(--error);
  font-size: var(--text-sm);
}

/* ---- Cards / panels ---- */
.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: var(--space-6);
  box-shadow: var(--shadow);
}

.panel--narrow {
  max-width: 26rem;
  margin: 10vh auto 0;
}

/* ---- Messages framework ---- */
.flash {
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius);
  margin-bottom: var(--space-3);
  font-size: var(--text-sm);
}

.flash--info {
  background: var(--blue-soft);
  color: var(--blue-deep);
}

.flash--success {
  background: var(--ok-soft);
  color: var(--ok);
}

.flash--error {
  background: var(--error-soft);
  color: var(--error);
}

/* ---- Mobile shell ---- */
.header__menu {
  display: none;
  border: none;
  background: none;
  font-size: var(--text-xl);
  color: var(--ink);
  cursor: pointer;
  padding: var(--space-1) var(--space-2);
}

.shell__overlay {
  display: none;
}

@media (max-width: 768px) {
  .shell {
    grid-template-columns: 1fr;
    grid-template-areas:
      "header"
      "main";
  }

  .header__menu {
    display: block;
  }

  .sidebar {
    position: fixed;
    top: var(--header-height);
    bottom: 0;
    left: 0;
    width: min(85vw, var(--sidebar-width));
    z-index: 60;
    transform: translateX(-105%);
    transition: transform 0.2s ease;
    box-shadow: none;
  }

  .shell--sidebar-open .sidebar {
    transform: none;
    box-shadow: 4px 0 16px rgba(28, 39, 51, 0.25);
  }

  .shell__overlay {
    display: block;
    position: fixed;
    inset: var(--header-height) 0 0 0;
    background: rgba(28, 39, 51, 0.4);
    z-index: 50;
  }

  .shell__overlay[hidden] {
    display: none;
  }

  .main {
    padding: var(--space-3);
  }

  .msg {
    max-width: 95%;
  }

  .panel--narrow {
    margin-top: var(--space-6);
  }

  .agent-grid {
    grid-template-columns: 1fr;
  }
}
