/* =========================================================
   Telmia Dashboard — Stylesheet único
   Paleta: #2e7df5 (primario), #0e1726 (dark), grises Linear-style
   Mobile-first, sin frameworks, generoso en spacing
   ========================================================= */

/* ---------- Reset & base ---------- */
* { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; -webkit-text-size-adjust: 100%; }
body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  background: #f7f8fa;
  color: #1a2233;
  line-height: 1.55;
  font-size: 15px;
}
a { color: #2e7df5; text-decoration: none; }
a:hover { color: #1f5fc8; }
button, input, select, textarea { font-family: inherit; font-size: inherit; }
button { cursor: pointer; }

/* ---------- Tokens (variables CSS) ---------- */
:root {
  --primary: #2e7df5;
  --primary-dark: #1f5fc8;
  --primary-soft: #e8f0fd;
  --dark: #0e1726;
  --text: #1a2233;
  --muted: #6b7689;
  --muted-light: #98a1b3;
  --border: #e6e9ef;
  --border-strong: #d4d9e2;
  --bg: #f7f8fa;
  --card: #ffffff;
  --success: #10b981;
  --success-soft: #ecfdf5;
  --warn: #f59e0b;
  --warn-soft: #fffbeb;
  --danger: #ef4444;
  --danger-soft: #fef2f2;
  --shadow-sm: 0 1px 2px rgba(14, 23, 38, 0.04);
  --shadow: 0 1px 3px rgba(14, 23, 38, 0.06), 0 1px 2px rgba(14, 23, 38, 0.04);
  --shadow-lg: 0 10px 30px rgba(14, 23, 38, 0.08);
  --radius: 10px;
  --radius-lg: 14px;
}

/* ---------- Layout shell ---------- */
.app {
  display: grid;
  grid-template-columns: 240px 1fr;
  min-height: 100vh;
}
@media (max-width: 860px) {
  .app { grid-template-columns: 1fr; }
}

/* ---------- Sidebar ---------- */
.sidebar {
  background: var(--card);
  border-right: 1px solid var(--border);
  padding: 24px 18px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.sidebar .brand {
  font-size: 20px;
  font-weight: 700;
  letter-spacing: 0.2px;
  margin-bottom: 20px;
  color: var(--dark);
}
.sidebar .brand .dot { color: var(--primary); }
.sidebar .studio-name {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: var(--muted-light);
  margin-bottom: 6px;
}
.sidebar .studio-value {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 24px;
  word-break: break-word;
}
.sidebar nav { display: flex; flex-direction: column; gap: 2px; }
.sidebar nav a {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 12px;
  border-radius: 8px;
  color: var(--muted);
  font-size: 14px;
  font-weight: 500;
  transition: background 0.12s, color 0.12s;
}
.sidebar nav a:hover { background: #f1f3f7; color: var(--text); }
.sidebar nav a.active { background: var(--primary-soft); color: var(--primary-dark); }
.sidebar nav a .icon { width: 16px; height: 16px; flex-shrink: 0; }
.sidebar .footer-links {
  margin-top: auto;
  padding-top: 16px;
  border-top: 1px solid var(--border);
  display: flex; flex-direction: column; gap: 2px;
}

@media (max-width: 860px) {
  .sidebar {
    border-right: none;
    border-bottom: 1px solid var(--border);
    padding: 14px 18px;
    flex-direction: row;
    align-items: center;
    gap: 12px;
    overflow-x: auto;
  }
  .sidebar .brand { margin-bottom: 0; font-size: 18px; }
  .sidebar .studio-name, .sidebar .studio-value { display: none; }
  .sidebar nav { flex-direction: row; gap: 4px; }
  .sidebar nav a { padding: 8px 10px; font-size: 13px; white-space: nowrap; }
  .sidebar .footer-links { display: none; }
}

/* ---------- Main ---------- */
.main {
  padding: 32px 40px 64px;
  max-width: 1200px;
  width: 100%;
}
@media (max-width: 860px) { .main { padding: 20px 18px 48px; } }

.page-header {
  display: flex; justify-content: space-between; align-items: flex-start;
  flex-wrap: wrap; gap: 12px;
  margin-bottom: 28px;
}
.page-header h1 {
  font-size: 24px; font-weight: 700; color: var(--dark);
  letter-spacing: -0.2px;
}
.page-header .subtitle {
  font-size: 14px; color: var(--muted); margin-top: 4px;
}
.page-header .actions { display: flex; gap: 10px; flex-wrap: wrap; }

/* ---------- KPI cards ---------- */
.kpis {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 14px;
  margin-bottom: 32px;
}
.kpi {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px 22px;
  box-shadow: var(--shadow-sm);
  transition: box-shadow 0.15s, transform 0.15s;
}
.kpi:hover { box-shadow: var(--shadow); }
.kpi .label {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: var(--muted);
  font-weight: 600;
  margin-bottom: 10px;
}
.kpi .value {
  font-size: 32px;
  font-weight: 700;
  color: var(--dark);
  letter-spacing: -0.5px;
  line-height: 1;
}
.kpi .delta {
  font-size: 12px;
  color: var(--muted);
  margin-top: 8px;
}
.kpi.accent .value { color: var(--primary); }
.kpi.success .value { color: var(--success); }
.kpi.warn .value { color: var(--warn); }
.kpi.danger .value { color: var(--danger); }

/* ---------- Card / section ---------- */
.section {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  margin-bottom: 24px;
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}
.section-header {
  display: flex; justify-content: space-between; align-items: center;
  padding: 16px 22px;
  border-bottom: 1px solid var(--border);
  gap: 12px;
  flex-wrap: wrap;
}
.section-header h2 {
  font-size: 15px;
  font-weight: 600;
  color: var(--dark);
}
.section-header .controls { display: flex; gap: 8px; flex-wrap: wrap; }
.section-body { padding: 20px 22px; }
.section-body.flush { padding: 0; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 9px 16px;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 500;
  border: 1px solid var(--border-strong);
  background: var(--card);
  color: var(--text);
  transition: background 0.12s, border-color 0.12s, transform 0.05s;
  text-decoration: none;
}
.btn:hover { background: #f1f3f7; }
.btn:active { transform: translateY(1px); }
.btn-primary {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
}
.btn-primary:hover { background: var(--primary-dark); border-color: var(--primary-dark); color: #fff; }
.btn-ghost {
  background: transparent;
  border-color: transparent;
  color: var(--muted);
}
.btn-ghost:hover { background: #f1f3f7; color: var(--text); }
.btn-danger {
  background: var(--danger);
  border-color: var(--danger);
  color: #fff;
}
.btn-danger:hover { background: #c62828; border-color: #c62828; color: #fff; }
.btn-sm { padding: 6px 12px; font-size: 13px; }
.btn-block { width: 100%; justify-content: center; }
.btn[disabled] { opacity: 0.55; cursor: not-allowed; }

/* ---------- Filters / chip group ---------- */
.chip-group { display: flex; gap: 6px; flex-wrap: wrap; }
.chip {
  padding: 5px 11px;
  border: 1px solid var(--border-strong);
  border-radius: 999px;
  background: var(--card);
  font-size: 12px;
  font-weight: 500;
  color: var(--muted);
  cursor: pointer;
  transition: all 0.12s;
}
.chip:hover { color: var(--text); border-color: var(--muted-light); }
.chip.active {
  background: var(--primary-soft);
  border-color: var(--primary);
  color: var(--primary-dark);
}

/* ---------- Table ---------- */
.table-wrap { overflow-x: auto; }
.table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}
.table thead th {
  position: sticky; top: 0;
  background: #fafbfc;
  text-align: left;
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--muted);
  padding: 12px 22px;
  border-bottom: 1px solid var(--border);
  z-index: 1;
  white-space: nowrap;
}
.table tbody td {
  padding: 14px 22px;
  border-bottom: 1px solid var(--border);
  color: var(--text);
  vertical-align: top;
}
.table tbody tr:last-child td { border-bottom: none; }
.table tbody tr:hover { background: #fafbfc; }
.table .time { font-variant-numeric: tabular-nums; color: var(--muted); white-space: nowrap; }
.table .caller-name { font-weight: 600; }
.table .caller-phone { font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
.table .notes { color: var(--muted); font-size: 13px; max-width: 320px; }
.table .empty {
  padding: 40px 22px;
  text-align: center;
  color: var(--muted);
}

/* ---------- Badges (outcome) ---------- */
.badge {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 3px 9px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
}
.badge .dot { width: 6px; height: 6px; border-radius: 999px; background: currentColor; }
.badge.booked { background: var(--success-soft); color: #047857; }
.badge.info   { background: var(--primary-soft); color: var(--primary-dark); }
.badge.emergency { background: var(--danger-soft); color: #b91c1c; }
.badge.missed { background: #f3f4f7; color: #4b5566; }
.badge.cancelled { background: var(--warn-soft); color: #92400e; }
.badge.transferred { background: #ede9fe; color: #6d28d9; }

/* ---------- Alert / problemi ---------- */
.alert {
  display: flex; gap: 14px;
  padding: 16px 18px;
  border-radius: var(--radius);
  border: 1px solid var(--warn);
  background: var(--warn-soft);
  margin-bottom: 12px;
}
.alert:last-child { margin-bottom: 0; }
.alert .alert-icon {
  font-size: 18px;
  flex-shrink: 0;
}
.alert .alert-title { font-weight: 600; color: #78350f; margin-bottom: 4px; }
.alert .alert-body { color: #92400e; font-size: 13.5px; line-height: 1.55; }
.alert.success { border-color: var(--success); background: var(--success-soft); }
.alert.success .alert-title { color: #065f46; }
.alert.success .alert-body { color: #047857; }
.alert.danger { border-color: var(--danger); background: var(--danger-soft); }
.alert.danger .alert-title { color: #991b1b; }
.alert.danger .alert-body { color: #b91c1c; }

/* ---------- Forms ---------- */
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 18px; }
.field label {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
}
.field .hint {
  font-size: 12px;
  color: var(--muted);
}
.field input[type="text"],
.field input[type="date"],
.field input[type="email"],
.field select,
.field textarea {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border-strong);
  border-radius: 8px;
  background: var(--card);
  color: var(--text);
  transition: border-color 0.12s, box-shadow 0.12s;
}
.field input:focus,
.field select:focus,
.field textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(46, 125, 245, 0.15);
}
.field textarea { min-height: 130px; resize: vertical; }

.radio-stack { display: flex; flex-direction: column; gap: 10px; }
.radio-card {
  display: flex; gap: 12px;
  padding: 14px 16px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  cursor: pointer;
  transition: all 0.12s;
}
.radio-card:hover { border-color: var(--muted-light); }
.radio-card input[type="radio"] { margin-top: 3px; accent-color: var(--primary); }
.radio-card.selected { border-color: var(--primary); background: var(--primary-soft); }
.radio-card .rc-title { font-weight: 600; color: var(--text); margin-bottom: 2px; }
.radio-card .rc-desc { font-size: 13px; color: var(--muted); }

.date-row { display: flex; gap: 12px; flex-wrap: wrap; }
.date-row .field { flex: 1 1 160px; margin-bottom: 0; }

/* ---------- Pre-login pages ---------- */
.centered {
  min-height: 100vh;
  display: flex; align-items: center; justify-content: center;
  padding: 24px;
}
.card-md {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 40px;
  max-width: 460px;
  width: 100%;
  text-align: center;
  box-shadow: var(--shadow-lg);
}
.card-md .brand { font-size: 22px; font-weight: 700; color: var(--dark); margin-bottom: 24px; }
.card-md .brand .dot { color: var(--primary); }
.card-md h1 {
  font-size: 22px;
  font-weight: 700;
  color: var(--dark);
  margin-bottom: 10px;
  letter-spacing: -0.2px;
}
.card-md p { color: var(--muted); margin-bottom: 24px; font-size: 15px; }
.card-md .icon-circle {
  width: 56px; height: 56px;
  border-radius: 999px;
  background: var(--primary-soft);
  color: var(--primary);
  display: flex; align-items: center; justify-content: center;
  font-size: 24px;
  margin: 0 auto 18px;
}
.card-md .icon-circle.warn { background: var(--warn-soft); color: var(--warn); }

/* ---------- Modal-ish container ---------- */
.form-narrow { max-width: 640px; }

/* ---------- Utility ---------- */
.muted { color: var(--muted); }
.row { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.spacer { flex: 1; }
.hidden { display: none !important; }
.text-right { text-align: right; }
.mt-2 { margin-top: 12px; }
.mt-4 { margin-top: 24px; }
.tag {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 6px;
  background: #f1f3f7;
  color: var(--muted);
  font-size: 12px;
  font-weight: 500;
}

/* ---------- Spinner ---------- */
.spinner {
  width: 18px; height: 18px;
  border: 2px solid rgba(46, 125, 245, 0.25);
  border-top-color: var(--primary);
  border-radius: 999px;
  animation: spin 0.7s linear infinite;
  display: inline-block;
}
@keyframes spin { to { transform: rotate(360deg); } }
.loading-block {
  display: flex; align-items: center; justify-content: center;
  padding: 60px 0;
  color: var(--muted);
  gap: 10px;
  font-size: 14px;
}

/* ---------- Toast ---------- */
.toast {
  position: fixed;
  bottom: 24px; right: 24px;
  background: var(--dark);
  color: #fff;
  padding: 12px 18px;
  border-radius: 10px;
  box-shadow: var(--shadow-lg);
  font-size: 14px;
  font-weight: 500;
  opacity: 0;
  transform: translateY(8px);
  transition: opacity 0.2s, transform 0.2s;
  z-index: 100;
}
.toast.show { opacity: 1; transform: translateY(0); }
.toast.success { background: var(--success); }
.toast.danger { background: var(--danger); }

/* ---------- Font: Inter (fallback to system) ---------- */
@font-face {
  font-family: 'Inter';
  font-style: normal;
  font-weight: 400 700;
  font-display: swap;
  src: local('Inter');
}
