/* css/base.css — Calibrate component styles
 * Tokens are defined in css/tokens.css which must load first.
 * This file contains layout, components, and utilities only.
 * No colour values are hardcoded here. */

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { font-size: 16px; }
body {
  font-family: var(--font-body);
  background: var(--color-bg);
  color: var(--color-text-primary);
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3 { font-family: var(--font-display); font-weight: 400; }
a { color: inherit; text-decoration: none; }

/* ── Layout ──────────────────────────────────────────────────────────────── */
.app-shell    { display: flex; height: 100vh; overflow: hidden; }
.main-content { flex: 1; overflow-y: auto; height: 100vh; }
.page         { padding: 2rem; max-width: 1380px; margin: 0 auto; }
.page-header  { margin-bottom: 2rem; }
.page-header h1 { font-size: 1.6rem; color: var(--color-text-primary); }
.page-header p  { color: var(--color-text-secondary); font-size: 0.875rem; margin-top: 0.25rem; }

/* ── Cards ───────────────────────────────────────────────────────────────── */
.card        { background: var(--color-bg-surface); border-radius: var(--radius-lg); border: 1px solid var(--color-border); box-shadow: var(--shadow-card); }
.card-header { padding: 1rem 1.5rem; border-bottom: 1px solid var(--color-border); display: flex; align-items: center; justify-content: space-between; }
.card-header h2 { font-family: var(--font-body); font-size: 0.875rem; font-weight: 600; color: var(--color-text-primary); }
.card-body   { padding: 1.25rem 1.5rem; }

/* ── Stat cards ──────────────────────────────────────────────────────────── */
.stat-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 1rem; margin-bottom: 1.5rem; }
.stat-card { background: var(--color-bg-surface); border-radius: var(--radius-lg); border: 1px solid var(--color-border); box-shadow: var(--shadow-card); padding: 1.25rem; }
.stat-card .label { font-size: 0.75rem; font-weight: 600; color: var(--color-text-secondary); margin-bottom: 0.5rem; }
.stat-card .value { font-size: 1.75rem; font-weight: 700; color: var(--color-text-primary); }
.stat-card .sub   { font-size: 0.75rem; color: var(--color-text-secondary); margin-top: 0.2rem; }

/* ── Buttons ─────────────────────────────────────────────────────────────── */
.btn           { display: inline-flex; align-items: center; gap: 0.4rem; padding: 0.5rem 1rem; border-radius: var(--radius); font-size: 0.875rem; font-weight: 500; font-family: var(--font-body); cursor: pointer; border: none; transition: all 0.15s; }
.btn:active    { transform: scale(0.98); }
.btn-primary   { background: var(--brand-700); color: white; box-shadow: 0 1px 2px rgba(0,0,0,.1); }
.btn-primary:hover { background: var(--brand-900); }
.btn-secondary { background: var(--color-bg-surface); color: var(--color-text-primary); border: 1px solid var(--color-border); }
.btn-secondary:hover { background: var(--color-bg); }
.btn-ghost     { background: transparent; color: var(--color-text-secondary); }
.btn-ghost:hover { background: var(--color-bg-subtle); }
.btn-sm        { padding: 0.35rem 0.75rem; font-size: 0.8rem; }
.btn-danger    { background: var(--danger); color: white; }

/* ── Form elements ───────────────────────────────────────────────────────── */
.form-group    { margin-bottom: 1rem; }
.form-label    { display: block; font-size: 0.875rem; font-weight: 500; color: var(--color-text-primary); margin-bottom: 0.4rem; }
.form-label span { font-weight: 400; color: var(--color-text-hint); }
.form-input, .form-select, .form-textarea {
  width: 100%; padding: 0.625rem 0.875rem; border-radius: var(--radius);
  border: 1px solid var(--color-border); background: var(--color-bg-surface);
  font-size: 0.875rem; font-family: var(--font-body); color: var(--color-text-primary);
  transition: border-color 0.15s, box-shadow 0.15s;
}
.form-input::placeholder, .form-textarea::placeholder { color: var(--color-text-hint); }
.form-input:focus, .form-select:focus, .form-textarea:focus {
  outline: none; border-color: var(--brand-500);
  box-shadow: 0 0 0 3px rgba(0,119,182,.15);
}
.form-textarea { resize: vertical; min-height: 80px; }
.form-row      { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }

/* ── Badges ──────────────────────────────────────────────────────────────── */
.badge         { display: inline-flex; align-items: center; gap: 0.2rem; padding: 0.2rem 0.6rem; border-radius: var(--radius-full); font-size: 0.75rem; font-weight: 500; }
.badge-success { color: var(--success); background: var(--green-bg); }
.badge-warning { color: var(--warning); background: var(--warn-bg); }
.badge-danger  { color: var(--danger);  background: var(--red-light); }
.badge-slate   { color: var(--color-text-secondary); background: var(--color-bg-subtle); }

/* ── Tables ──────────────────────────────────────────────────────────────── */
.data-table    { width: 100%; border-collapse: collapse; font-size: 0.875rem; }
.data-table th { padding: 0.75rem 1.25rem; text-align: left; font-size: 0.7rem; font-weight: 600; color: var(--color-text-secondary); text-transform: uppercase; letter-spacing: 0.04em; background: var(--color-bg); border-bottom: 1px solid var(--color-border); }
.data-table td { padding: 0.875rem 1.25rem; border-bottom: 1px solid var(--color-border); vertical-align: middle; color: var(--color-text-primary); }
.data-table tr:hover td { background: rgba(248,250,252,.6); }
.data-table tr:last-child td { border-bottom: none; }

/* ── Modal ───────────────────────────────────────────────────────────────── */
.modal-overlay { position: fixed; inset: 0; background: rgba(0,0,0,.4); backdrop-filter: blur(4px); display: flex; align-items: center; justify-content: center; z-index: 50; padding: 1rem; opacity: 0; pointer-events: none; transition: opacity 0.2s; }
.modal-overlay.open { opacity: 1; pointer-events: all; }
.modal         { background: var(--color-bg-surface); border-radius: var(--radius-xl); box-shadow: var(--shadow-lg); width: 100%; max-width: 520px; max-height: 90vh; display: flex; flex-direction: column; transform: translateY(10px); transition: transform 0.25s cubic-bezier(0.16,1,0.3,1); }
.modal-overlay.open .modal { transform: translateY(0); }
.modal-header  { padding: 1.25rem 1.5rem; border-bottom: 1px solid var(--color-border); display: flex; align-items: center; justify-content: space-between; flex-shrink: 0; }
.modal-header h2 { font-family: var(--font-body); font-size: 1rem; font-weight: 600; color: var(--color-text-primary); }
.modal-body    { padding: 1.5rem; overflow-y: auto; flex: 1; }
.modal-footer  { padding: 1rem 1.5rem; border-top: 1px solid var(--color-border); display: flex; gap: 0.75rem; justify-content: flex-end; flex-shrink: 0; }
.modal-close   { background: none; border: none; cursor: pointer; color: var(--color-text-hint); padding: 0.25rem; border-radius: var(--radius); }
.modal-close:hover { background: var(--color-bg-subtle); color: var(--color-text-secondary); }

/* ── Progress bar ────────────────────────────────────────────────────────── */
.progress-bar  { height: 6px; background: var(--color-bg-subtle); border-radius: var(--radius-full); overflow: hidden; }
.progress-fill { height: 100%; border-radius: var(--radius-full); background: var(--brand-500); transition: width 0.4s ease; }

/* ── Callout ─────────────────────────────────────────────────────────────── */
.callout         { padding: 0.875rem 1rem; border-radius: var(--radius); display: flex; gap: 0.75rem; font-size: 0.875rem; }
.callout-info    { background: var(--brand-50); border-left: 3px solid var(--brand-500); color: var(--brand-900); }
.callout-warning { background: var(--warn-bg); border-left: 3px solid var(--warning); color: var(--warn-text); }

/* ── Area dot ────────────────────────────────────────────────────────────── */
.area-dot { width: 28px; height: 28px; border-radius: 7px; display: flex; align-items: center; justify-content: center; color: white; font-size: 0.75rem; font-weight: 700; flex-shrink: 0; }

/* ── Spinner ─────────────────────────────────────────────────────────────── */
.spinner { width: 20px; height: 20px; border: 2px solid var(--color-border); border-top-color: var(--brand-500); border-radius: 50%; animation: spin 0.7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Loading state ───────────────────────────────────────────────────────── */
.loading-screen { display: flex; align-items: center; justify-content: center; min-height: 60vh; }

/* ── Animations ──────────────────────────────────────────────────────────── */
.animate-in { animation: slideUp 0.3s cubic-bezier(0.16,1,0.3,1) both; }
@keyframes slideUp { from { opacity:0; transform:translateY(8px); } to { opacity:1; transform:translateY(0); } }

/* ── Scrollbar ───────────────────────────────────────────────────────────── */
::-webkit-scrollbar       { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: var(--color-bg-subtle); }
::-webkit-scrollbar-thumb { background: var(--color-border-strong); border-radius: var(--radius-full); }

/* ── Toast ───────────────────────────────────────────────────────────────── */
.toast-container { position: fixed; bottom: 1.5rem; right: 1.5rem; z-index: 100; display: flex; flex-direction: column; gap: 0.5rem; }
.toast           { background: var(--color-text-primary); color: white; padding: 0.75rem 1rem; border-radius: var(--radius); font-size: 0.875rem; box-shadow: var(--shadow-lg); animation: slideUp 0.25s ease both; min-width: 200px; }
.toast.success   { background: var(--success); }
.toast.error     { background: var(--danger); }

