/* Página compartilhável de horários livres (tokens em tokens.css) */
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 400 14px/1.45 Inter, system-ui, -apple-system, "Segoe UI", sans-serif;
  letter-spacing: -0.006em; -webkit-font-smoothing: antialiased;
}
button, select { font: inherit; color: inherit; }
button { cursor: pointer; }
[hidden] { display: none !important; }
.muted { color: var(--muted); }
.ms {
  font-family: "Material Symbols Outlined"; font-weight: normal; font-style: normal; font-size: 20px; line-height: 1;
  display: inline-block; white-space: nowrap; font-feature-settings: "liga"; flex-shrink: 0; user-select: none;
  font-variation-settings: "FILL" 0, "wght" 400, "opsz" 20;
}

.page { max-width: 1120px; margin: 0 auto; padding: 28px 24px 40px; display: flex; flex-direction: column; gap: 18px; }

/* Cabeçalho */
.hero { display: flex; justify-content: space-between; align-items: center; gap: 16px; }
.who { display: flex; align-items: center; gap: 14px; min-width: 0; }
.avatar {
  width: 52px; height: 52px; border-radius: 50%; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, var(--accent), var(--free)); color: #fff; font-weight: 700; font-size: 19px;
}
.hero h1 { margin: 0; font-size: 24px; font-weight: 600; letter-spacing: -0.025em; line-height: 1.2; }
.hero p { margin: 3px 0 0; font-size: 13px; }

.icon-btn {
  width: 36px; height: 36px; display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0;
  border-radius: var(--radius); border: 1px solid var(--border); background: var(--panel); color: var(--muted);
}
.icon-btn:hover:not(:disabled) { background: var(--surface-low); color: var(--text); }
.icon-btn:disabled { opacity: .35; cursor: default; }

/* Barra de controles */
.toolbar { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; }
.nav { display: flex; align-items: center; gap: 8px; }
.week-label { font-size: 17px; font-weight: 600; letter-spacing: -0.015em; min-width: 210px; text-align: center; }
.controls { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.segmented { display: flex; background: var(--surface-low); border: 1px solid var(--border); border-radius: var(--radius); padding: 2px; }
.segmented button {
  border: 0; background: transparent; padding: 5px 12px; border-radius: 6px; font-size: 13px; font-weight: 500; color: var(--muted);
  display: inline-flex; align-items: center; gap: 6px; white-space: nowrap;
}
.segmented button .ms { font-size: 17px; }
.segmented button:hover { color: var(--text); }
.segmented button.active { background: var(--panel); color: var(--text); font-weight: 600; box-shadow: 0 1px 2px rgba(0,0,0,.08); }
.select {
  display: inline-flex; align-items: center; gap: 6px; height: 34px; padding: 0 4px 0 10px;
  border: 1px solid var(--border); border-radius: var(--radius); background: var(--panel); color: var(--muted);
}
.select .ms { font-size: 17px; }
.select select { border: 0; background: transparent; height: 100%; font-size: 13px; font-weight: 500; color: var(--text); padding-right: 4px; cursor: pointer; }
.select select:focus { outline: none; }
.select:focus-within { outline: 2px solid var(--accent); outline-offset: 1px; }
.select.tz select { max-width: 260px; text-overflow: ellipsis; }

/* Resumo */
.stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.stat {
  background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 14px 16px; display: flex; flex-direction: column; gap: 4px; min-width: 0;
}
.stat .lbl { font-size: 12px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; display: flex; align-items: center; gap: 6px; }
.stat .lbl .ms { font-size: 16px; }
.stat .val { font-size: 22px; font-weight: 600; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }
.stat .val small { font-size: 14px; font-weight: 500; color: var(--muted); margin-left: 4px; }
.stat.highlight { border-color: color-mix(in srgb, var(--free) 45%, var(--border)); background: var(--free-soft); }
.stat.highlight .lbl, .stat.highlight .val { color: var(--on-free); }
.stat .copy {
  margin-top: 4px; align-self: flex-start; border: 0; border-radius: 6px; padding: 7px 12px;
  background: var(--primary); color: var(--on-primary); font-size: 13px; font-weight: 600;
  display: inline-flex; align-items: center; gap: 6px;
}
.stat .copy .ms { font-size: 17px; }
.stat .copy:hover { opacity: .9; }

.notice {
  display: flex; gap: 10px; align-items: flex-start; padding: 10px 14px; border-radius: var(--radius);
  background: var(--error-soft); color: var(--on-error-soft); font-size: 13px;
}

/* Grade semanal */
.view { min-height: 200px; }
.grid-card { background: var(--panel); border: 1px solid var(--border); border-radius: 12px; overflow: hidden; }
.grid-head, .grid-body { display: grid; grid-template-columns: 56px repeat(var(--days), minmax(0, 1fr)); }
.grid-head { border-bottom: 1px solid var(--border); }
.grid-head .corner { font-size: 11px; color: var(--muted); display: flex; align-items: flex-end; justify-content: center; padding-bottom: 10px; }
.dh { text-align: center; padding: 10px 4px; border-left: 1px solid var(--grid-line); display: flex; flex-direction: column; align-items: center; gap: 2px; }
.dh .dow { font-size: 11px; font-weight: 600; letter-spacing: .05em; color: var(--muted); text-transform: uppercase; }
.dh .dnum { font-size: 19px; font-weight: 600; width: 34px; height: 34px; display: flex; align-items: center; justify-content: center; border-radius: 50%; }
.dh.today .dow { color: var(--accent); }
.dh.today .dnum { background: var(--accent); color: #fff; }
.dh .sum { font-size: 11px; font-weight: 600; color: var(--on-free); }
.dh .sum.none { color: var(--faint); font-weight: 500; }
.dh.past { opacity: .55; }

.hours { position: relative; }
.hours span { position: absolute; right: 8px; transform: translateY(-50%); font-size: 11px; font-weight: 500; color: var(--muted); }
.col {
  position: relative; border-left: 1px solid var(--grid-line);
  background-color: var(--panel);
  background-image: repeating-linear-gradient(-45deg, var(--grid-line) 0 1px, transparent 1px 8px);
}
.col .lines {
  position: absolute; inset: 0; pointer-events: none;
  background-image: repeating-linear-gradient(to bottom, transparent 0, transparent calc(var(--hour) - 1px), var(--grid-line) calc(var(--hour) - 1px), var(--grid-line) var(--hour));
}
.win { position: absolute; left: 0; right: 0; background: var(--panel); }
.blk {
  position: absolute; left: 4px; right: 4px; border-radius: 6px; overflow: hidden; z-index: 2;
  padding: 4px 8px; font-size: 12px; line-height: 1.25; text-align: left; border: 0;
}
.blk.busy { background: var(--busy-soft); color: var(--on-busy); border-left: 3px solid var(--busy); cursor: default; }
.blk.free {
  background: var(--free-soft); color: var(--on-free); border-left: 3px solid var(--free);
  transition: box-shadow .15s, transform .15s;
}
.blk.free:hover { box-shadow: 0 0 0 1.5px var(--free), var(--shadow); z-index: 3; }
.blk.free:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.blk .k { font-weight: 600; display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.blk .t { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; display: block; font-variant-numeric: tabular-nums; }
.blk.tiny { padding-top: 1px; padding-bottom: 1px; display: flex; gap: 6px; align-items: center; }
.blk.tiny .k { flex-shrink: 0; }
.past-shade { position: absolute; left: 0; right: 0; top: 0; z-index: 4; pointer-events: none; background: color-mix(in srgb, var(--bg) 62%, transparent); }
.now { position: absolute; left: 0; right: 0; height: 2px; background: var(--error-strong); z-index: 5; pointer-events: none; }
.now::before { content: ""; position: absolute; left: -4px; top: -4px; width: 10px; height: 10px; border-radius: 50%; background: var(--error-strong); }

/* Lista */
.days { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 12px; }
.day {
  background: var(--panel); border: 1px solid var(--border); border-radius: 12px; padding: 14px 16px;
  display: flex; flex-direction: column; gap: 10px;
}
.day.today { border-color: color-mix(in srgb, var(--accent) 50%, var(--border)); }
.day-top { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.day-top h3 { margin: 0; font-size: 15px; font-weight: 600; }
.day-top h3 small { font-size: 12px; font-weight: 600; color: var(--accent); background: var(--accent-soft); padding: 1px 7px; border-radius: 10px; margin-left: 6px; }
.day-top .tot { font-size: 12px; font-weight: 600; color: var(--on-free); white-space: nowrap; }
.bar { display: flex; height: 8px; border-radius: 4px; overflow: hidden; background: var(--busy-soft); }
.bar i { display: block; height: 100%; }
.bar i.f { background: var(--free); }
.bar i.b { background: var(--busy); opacity: .55; }
.bar i.p { background: var(--grid-line); }
.slots { display: flex; flex-wrap: wrap; gap: 8px; }
.slot {
  border: 1px solid color-mix(in srgb, var(--free) 45%, transparent); background: var(--free-soft); color: var(--on-free);
  border-radius: 8px; padding: 7px 11px; font-size: 14px; font-weight: 600; font-variant-numeric: tabular-nums;
  display: inline-flex; align-items: baseline; gap: 6px;
}
.slot small { font-size: 11px; font-weight: 500; opacity: .8; }
.slot:hover { box-shadow: 0 0 0 1.5px var(--free); }
.none { color: var(--muted); font-size: 13px; display: flex; align-items: center; gap: 6px; }
.none .ms { font-size: 17px; }

.empty, .loading { text-align: center; color: var(--muted); padding: 48px 16px; }
.loading .ms { animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* Rodapé */
.foot { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; font-size: 12px; padding-top: 4px; }
.legend { display: flex; gap: 16px; flex-wrap: wrap; color: var(--muted); }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.sw { width: 14px; height: 14px; border-radius: 4px; display: inline-block; }
.sw.free { background: var(--free-soft); border: 1px solid var(--free); border-left-width: 3px; }
.sw.busy { background: var(--busy-soft); border: 1px solid var(--busy); border-left-width: 3px; }
.sw.off { border: 1px solid var(--border); background: repeating-linear-gradient(-45deg, var(--border) 0 1px, transparent 1px 4px); }

.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); z-index: 50;
  background: var(--primary); color: var(--on-primary); padding: 10px 16px; border-radius: 10px;
  font-size: 13px; font-weight: 500; box-shadow: var(--shadow); display: flex; align-items: center; gap: 8px; max-width: calc(100vw - 32px);
}
.toast .ms { font-size: 18px; color: var(--free); }

@media (max-width: 760px) {
  .page { padding: 18px 16px 32px; gap: 14px; }
  .hero h1 { font-size: 20px; }
  .avatar { width: 44px; height: 44px; font-size: 16px; }
  .toolbar { flex-direction: column; align-items: stretch; }
  .nav { justify-content: space-between; }
  .week-label { min-width: 0; flex: 1; font-size: 16px; }
  .controls { justify-content: space-between; }
  .select.tz { flex: 1; min-width: 0; }
  .select.tz select { max-width: none; width: 100%; }
  .stats { grid-template-columns: 1fr 1fr; }
  .stats .stat:last-child { grid-column: span 2; }
  .stat .val { font-size: 19px; }
  .days { grid-template-columns: 1fr; }
  #view-switch { display: none; }
}
