/* Dashboard Ambulatorització MI · HUSE
   Estil compartit per tots els dashboards (diari, setmanal, índex).
   Dark mode automàtic segons preferència del sistema. */

:root {
  color-scheme: light dark;
  --bg: #ffffff;
  --surface: #fafafa;
  --surface-2: #f4f4f5;
  --text: #0a0a0a;
  --text-dim: #6b7280;
  --border: #e5e5e5;
  --green-bg: #dcfce7;   --green-fg: #166534;   --green-strong: #16a34a;
  --blue-bg:  #dbeafe;   --blue-fg:  #1e40af;   --blue-strong:  #2563eb;
  --orange-bg:#ffedd5;   --orange-fg:#9a3412;   --orange-strong:#ea580c;
  --red-bg:   #fee2e2;   --red-fg:   #991b1b;   --red-strong:   #dc2626;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0b0b0b;
    --surface: #171717;
    --surface-2: #1f1f1f;
    --text: #f5f5f5;
    --text-dim: #9ca3af;
    --border: #2a2a2a;
    --green-bg: #14532d;   --green-fg: #86efac;   --green-strong: #22c55e;
    --blue-bg:  #1e3a8a;   --blue-fg:  #93c5fd;   --blue-strong:  #3b82f6;
    --orange-bg:#7c2d12;   --orange-fg:#fdba74;   --orange-strong:#f97316;
    --red-bg:   #7f1d1d;   --red-fg:   #fca5a5;   --red-strong:   #ef4444;
  }
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  padding: 1rem;
  max-width: 1100px;
  margin: 0 auto;
}

a { color: inherit; }

.nav-back {
  display: inline-block;
  font-size: 0.85rem;
  color: var(--text-dim);
  text-decoration: none;
  margin-bottom: 0.75rem;
}
.nav-back:hover { color: var(--text); }

.header { margin-bottom: 0.5rem; }
.header h1 { font-size: 1.25rem; font-weight: 600; }
.header .date { font-size: 0.95rem; color: var(--text-dim); margin-top: 0.1rem; }

.banner {
  padding: 1.25rem 1rem;
  border-radius: 12px;
  margin: 1rem 0 1.5rem;
  text-align: center;
}
.banner .state { font-size: 1.05rem; font-weight: 700; letter-spacing: 0.3px; }
.banner .sub { font-size: 0.9rem; margin-top: 0.25rem; opacity: 0.9; }
.banner.green  { background: var(--green-bg);  color: var(--green-fg); }
.banner.orange { background: var(--orange-bg); color: var(--orange-fg); }
.banner.red    { background: var(--red-bg);    color: var(--red-fg); }

h2 { font-size: 1rem; font-weight: 600; margin: 1.5rem 0 0.75rem; letter-spacing: 0.2px; }

/* Equip */
.grid-team {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.5rem;
}
@media (min-width: 720px) { .grid-team { grid-template-columns: repeat(4, 1fr); } }
.member {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0.75rem;
}
.member .name { font-weight: 600; font-size: 0.95rem; }
.member .status { font-size: 0.8rem; color: var(--text-dim); margin-top: 0.2rem; }
.member.absent { opacity: 0.55; }
.member.reduced .status { color: var(--orange-strong); }

/* Cards d'assignació */
.cards {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.5rem;
}
@media (min-width: 720px) { .cards { grid-template-columns: repeat(2, 1fr); } }
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0.9rem;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}
.card .title { font-weight: 600; font-size: 0.95rem; }
.card .assignee { font-size: 0.9rem; color: var(--text-dim); }
.card .resident { font-size: 0.8rem; color: var(--text-dim); font-style: italic; }

/* Badges de càrrega */
.badge {
  align-self: flex-start;
  font-size: 0.8rem;
  font-weight: 600;
  padding: 0.2rem 0.6rem;
  border-radius: 6px;
}
.badge.green  { background: var(--green-bg);  color: var(--green-fg); }
.badge.blue   { background: var(--blue-bg);   color: var(--blue-fg); }
.badge.orange { background: var(--orange-bg); color: var(--orange-fg); }
.badge.red    { background: var(--red-bg);    color: var(--red-fg); }

/* Mètrica destacada (ingressos) */
.metric {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 1rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
}
.metric.green  { border-color: var(--green-strong); }
.metric.blue   { border-color: var(--blue-strong); }
.metric.orange { border-color: var(--orange-strong); }
.metric.red    { border-color: var(--red-strong); }
.metric .label { font-size: 0.9rem; color: var(--text-dim); }
.metric .value {
  font-size: 1.8rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}
.metric.green  .value { color: var(--green-strong); }
.metric.blue   .value { color: var(--blue-strong); }
.metric.orange .value { color: var(--orange-strong); }
.metric.red    .value { color: var(--red-strong); }

/* Notes i info secundària */
.note {
  background: var(--surface-2);
  border-left: 3px solid var(--border);
  padding: 0.6rem 0.9rem;
  border-radius: 6px;
  font-size: 0.9rem;
  color: var(--text-dim);
  margin: 0.5rem 0;
}

/* Llistes d'eventualitats */
ul.events { list-style: none; padding: 0.25rem 0; }
ul.events li {
  padding: 0.4rem 0;
  border-bottom: 1px solid var(--border);
  font-size: 0.9rem;
}
ul.events li:last-child { border-bottom: 0; }

/* Peu */
.foot {
  font-size: 0.75rem;
  color: var(--text-dim);
  text-align: center;
  margin-top: 2rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
}

/* Índex: llista de dashboards */
.index-list {
  display: grid;
  gap: 0.5rem;
  list-style: none;
  padding: 0;
  margin-top: 0.5rem;
}
.index-list a {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.75rem 0.9rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  text-decoration: none;
  color: var(--text);
  font-size: 0.95rem;
}
.index-list a:hover { background: var(--surface-2); }
.index-list .dot {
  width: 10px; height: 10px; border-radius: 50%;
  display: inline-block; margin-right: 0.6rem;
}
.dot.green  { background: var(--green-strong); }
.dot.orange { background: var(--orange-strong); }
.dot.red    { background: var(--red-strong); }
