/* Zenda — sistema de agendamento para clínica de massoterapia */

@import url('https://fonts.googleapis.com/css2?family=Fraunces:opsz,wght@9..144,400;9..144,500;9..144,600;9..144,700&family=Sora:wght@400;500;600;700&display=swap');

:root {
  --bg: #EEF1EC;
  --surface: #FFFFFF;
  --surface-2: #F5F6F0;
  --border: #DBDFD3;
  --text: #202821;
  --text-muted: #5C6459;
  --primary: #1E3A34;
  --primary-strong: #142823;
  --primary-contrast: #FFFFFF;
  --accent: #9C4A63;
  --accent-strong: #7E3A50;
  --accent-contrast: #FFFFFF;
  --success: #3F7D58;
  --success-bg: #E4F0E7;
  --warning: #B98A2E;
  --warning-bg: #F6EBD6;
  --danger: #B3483D;
  --danger-bg: #F5E1DE;
  --shadow: 0 1px 2px rgba(20, 30, 25, 0.06), 0 8px 24px -12px rgba(20, 30, 25, 0.18);
  --radius-sm: 8px;
  --radius: 12px;
  --radius-lg: 18px;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #10201B;
    --surface: #16261F;
    --surface-2: #1C2E27;
    --border: #2A3B33;
    --text: #E7ECE6;
    --text-muted: #9FAEA3;
    --primary: #7FB3A0;
    --primary-strong: #99C4B3;
    --primary-contrast: #0E1A16;
    --accent: #D98BA0;
    --accent-strong: #E4A2B4;
    --accent-contrast: #2A1017;
    --success: #5FAE79;
    --success-bg: #1C3327;
    --warning: #D9A94A;
    --warning-bg: #362A14;
    --danger: #D9695D;
    --danger-bg: #38201C;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 8px 24px -12px rgba(0, 0, 0, 0.5);
    color-scheme: dark;
  }
}

:root[data-theme="dark"] {
  --bg: #10201B;
  --surface: #16261F;
  --surface-2: #1C2E27;
  --border: #2A3B33;
  --text: #E7ECE6;
  --text-muted: #9FAEA3;
  --primary: #7FB3A0;
  --primary-strong: #99C4B3;
  --primary-contrast: #0E1A16;
  --accent: #D98BA0;
  --accent-strong: #E4A2B4;
  --accent-contrast: #2A1017;
  --success: #5FAE79;
  --success-bg: #1C3327;
  --warning: #D9A94A;
  --warning-bg: #362A14;
  --danger: #D9695D;
  --danger-bg: #38201C;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 8px 24px -12px rgba(0, 0, 0, 0.5);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: 'Sora', system-ui, sans-serif;
  font-size: 14px;
  line-height: 1.5;
}
h1, h2, h3, .display {
  font-family: 'Fraunces', Georgia, serif;
  text-wrap: balance;
  margin: 0;
}
a { color: inherit; }
button { font-family: inherit; }
[hidden] { display: none !important; }

::selection { background: var(--accent); color: var(--accent-contrast); }

.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 16px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  font-family: 'Sora', sans-serif;
  font-weight: 600;
  font-size: 13.5px;
  cursor: pointer;
  transition: transform .08s ease, filter .15s ease;
  white-space: nowrap;
}
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--primary); color: var(--primary-contrast); }
.btn-primary:hover { filter: brightness(1.08); }
.btn-accent { background: var(--accent); color: var(--accent-contrast); }
.btn-accent:hover { filter: brightness(1.08); }
.btn-ghost { background: transparent; color: var(--text); border-color: var(--border); }
.btn-ghost:hover { background: var(--surface-2); }
.btn-danger { background: transparent; color: var(--danger); border-color: var(--danger); }
.btn-danger:hover { background: var(--danger-bg); }
.btn-sm { padding: 6px 12px; font-size: 12.5px; border-radius: 7px; }
.btn-icon { padding: 8px; border-radius: 8px; background: transparent; border: 1px solid var(--border); color: var(--text-muted); }
.btn-icon:hover { background: var(--surface-2); color: var(--text); }
.btn:disabled { opacity: .5; cursor: not-allowed; }

.icon { width: 18px; height: 18px; flex-shrink: 0; stroke: currentColor; fill: none; stroke-width: 1.8; }

input, select, textarea {
  font-family: 'Sora', sans-serif;
  font-size: 13.5px;
  padding: 9px 11px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  width: 100%;
}
input:focus, select:focus, textarea:focus {
  outline: 2px solid var(--primary);
  outline-offset: 1px;
}
label { font-size: 12.5px; font-weight: 600; color: var(--text-muted); display: block; margin-bottom: 5px; }
.field { margin-bottom: 14px; }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
textarea { resize: vertical; min-height: 70px; }

.chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 10px;
  border-radius: 100px;
  font-size: 11.5px;
  font-weight: 700;
  letter-spacing: .02em;
  text-transform: uppercase;
}
.chip::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.chip-success { background: var(--success-bg); color: var(--success); }
.chip-warning { background: var(--warning-bg); color: var(--warning); }
.chip-danger { background: var(--danger-bg); color: var(--danger); }
.chip-primary { background: var(--surface-2); color: var(--primary); }

/* ---------- Login ---------- */
.login-wrap {
  min-height: 100vh;
  display: grid;
  place-items: center;
  background:
    radial-gradient(1100px 600px at 12% -10%, color-mix(in srgb, var(--primary) 22%, transparent), transparent),
    radial-gradient(900px 500px at 100% 110%, color-mix(in srgb, var(--accent) 18%, transparent), transparent),
    var(--bg);
  padding: 24px;
}
.login-card {
  width: 100%;
  max-width: 380px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  padding: 36px 32px 30px;
}
.login-mark {
  width: 46px; height: 46px;
  border-radius: 12px;
  background: var(--primary);
  color: var(--primary-contrast);
  display: grid; place-items: center;
  font-family: 'Fraunces', serif;
  font-weight: 600;
  font-size: 20px;
  margin-bottom: 18px;
}
.login-card h1 { font-size: 26px; font-weight: 600; }
.login-sub { color: var(--text-muted); font-size: 13px; margin: 6px 0 26px; }
.login-hint {
  margin-top: 18px;
  font-size: 12px;
  color: var(--text-muted);
  background: var(--surface-2);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  line-height: 1.5;
}
.login-hint b { color: var(--text); }
.login-check { display: flex; align-items: center; gap: 8px; margin: 4px 0 20px; font-size: 12.5px; color: var(--text-muted); }
.login-check input { width: auto; }
.login-error {
  background: var(--danger-bg); color: var(--danger);
  padding: 9px 12px; border-radius: var(--radius-sm);
  font-size: 12.5px; margin-bottom: 14px;
}

/* ---------- App shell ---------- */
#app { display: flex; height: 100vh; overflow: hidden; }

.sidebar {
  width: 232px;
  flex-shrink: 0;
  background: var(--primary);
  color: var(--primary-contrast);
  display: flex;
  flex-direction: column;
  padding: 20px 14px;
}
.brand { display: flex; align-items: center; gap: 10px; padding: 4px 8px 22px; }
.brand-mark {
  width: 34px; height: 34px; border-radius: 9px;
  background: color-mix(in srgb, var(--primary-contrast) 16%, transparent);
  display: grid; place-items: center;
  font-family: 'Fraunces', serif; font-weight: 600; font-size: 16px;
}
.brand-name { font-family: 'Fraunces', serif; font-size: 17px; font-weight: 600; line-height: 1.15; }
.brand-clinic { font-size: 10.5px; opacity: .72; text-transform: uppercase; letter-spacing: .06em; }

.nav { display: flex; flex-direction: column; gap: 2px; flex: 1; }
.nav-item {
  display: flex; align-items: center; gap: 11px;
  padding: 10px 12px;
  border-radius: 9px;
  color: color-mix(in srgb, var(--primary-contrast) 78%, transparent);
  cursor: pointer;
  font-size: 13.5px;
  font-weight: 500;
  border: none;
  background: transparent;
  width: 100%;
  text-align: left;
}
.nav-item:hover { background: color-mix(in srgb, var(--primary-contrast) 10%, transparent); }
.nav-item.active {
  background: color-mix(in srgb, var(--primary-contrast) 16%, transparent);
  color: var(--primary-contrast);
  font-weight: 600;
}
.nav-item .icon { width: 17px; height: 17px; }

.sidebar-foot { border-top: 1px solid color-mix(in srgb, var(--primary-contrast) 18%, transparent); padding-top: 12px; margin-top: 8px; }
.user-row { display: flex; align-items: center; gap: 9px; padding: 6px 8px; border-radius: 9px; cursor: pointer; position: relative; }
.user-row:hover { background: color-mix(in srgb, var(--primary-contrast) 10%, transparent); }
.avatar { width: 28px; height: 28px; border-radius: 50%; background: var(--accent); color: var(--accent-contrast); display: grid; place-items: center; font-weight: 700; font-size: 12px; flex-shrink: 0; }
.user-name { font-size: 12.5px; font-weight: 600; }
.user-role { font-size: 10.5px; opacity: .7; }

.user-menu {
  position: absolute; bottom: 46px; left: 0; width: 100%;
  background: var(--surface); color: var(--text);
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  box-shadow: var(--shadow); padding: 6px; z-index: 40;
}
.user-menu button {
  display: flex; align-items: center; gap: 8px; width: 100%;
  padding: 8px 9px; border: none; background: none; color: var(--text);
  border-radius: 6px; cursor: pointer; font-size: 13px; text-align: left;
}
.user-menu button:hover { background: var(--surface-2); }

.main { flex: 1; display: flex; flex-direction: column; min-width: 0; overflow: hidden; }
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 18px 28px; border-bottom: 1px solid var(--border);
  background: var(--surface); flex-shrink: 0; gap: 16px;
}
.topbar h2 { font-size: 21px; font-weight: 600; }
.topbar-sub { font-size: 12.5px; color: var(--text-muted); margin-top: 2px; }
.topbar-actions { display: flex; align-items: center; gap: 10px; }

.content { flex: 1; overflow-y: auto; padding: 26px 28px 60px; }
.section { display: none; }
.section.active { display: block; }

/* ---------- Generic layout bits ---------- */
.grid { display: grid; gap: 16px; }
.cards-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 14px; margin-bottom: 20px; }
.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 18px;
}
.kpi-label { font-size: 11.5px; text-transform: uppercase; letter-spacing: .04em; color: var(--text-muted); font-weight: 600; }
.kpi-value { font-family: 'Fraunces', serif; font-size: 27px; font-weight: 600; margin-top: 6px; font-variant-numeric: tabular-nums; }
.kpi-sub { font-size: 12px; color: var(--text-muted); margin-top: 4px; }
.kpi-sub.up { color: var(--success); }
.kpi-sub.down { color: var(--danger); }

.panel { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px; margin-bottom: 18px; }
.panel-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; gap: 12px; flex-wrap: wrap; }
.panel-head h3 { font-size: 15.5px; font-weight: 600; font-family: 'Sora', sans-serif; }
.two-col { display: grid; grid-template-columns: 1.3fr 1fr; gap: 16px; }

table { width: 100%; border-collapse: collapse; font-size: 13px; }
th { text-align: left; font-size: 11px; text-transform: uppercase; letter-spacing: .04em; color: var(--text-muted); font-weight: 700; padding: 8px 10px; border-bottom: 1px solid var(--border); }
td { padding: 11px 10px; border-bottom: 1px solid var(--border); vertical-align: middle; }
tr:last-child td { border-bottom: none; }
.table-wrap { overflow-x: auto; }
.row-actions { display: flex; gap: 6px; justify-content: flex-end; }
.text-muted { color: var(--text-muted); }
.text-right { text-align: right; }
.mono-num { font-variant-numeric: tabular-nums; }
.empty-state { text-align: center; padding: 40px 20px; color: var(--text-muted); }
.empty-state .icon { width: 34px; height: 34px; margin-bottom: 10px; opacity: .5; }

.search-box { position: relative; max-width: 280px; }
.search-box input { padding-left: 34px; }
.search-box .icon { position: absolute; left: 10px; top: 50%; transform: translateY(-50%); width: 15px; height: 15px; color: var(--text-muted); }

/* ---------- Agenda ---------- */
.agenda-toolbar { display: flex; align-items: center; justify-content: space-between; margin-bottom: 18px; flex-wrap: wrap; gap: 12px; }
.date-nav { display: flex; align-items: center; gap: 8px; }
.date-nav .current-date { font-family: 'Fraunces', serif; font-size: 17px; font-weight: 600; min-width: 190px; text-align: center; text-transform: capitalize; }
.view-toggle { display: flex; background: var(--surface-2); border-radius: 8px; padding: 3px; gap: 2px; }
.view-toggle button { border: none; background: none; padding: 6px 14px; border-radius: 6px; font-size: 12.5px; font-weight: 600; color: var(--text-muted); cursor: pointer; }
.view-toggle button.active { background: var(--surface); color: var(--text); box-shadow: var(--shadow); }

.timeline { position: relative; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.timeline-hour { display: flex; height: 64px; border-bottom: 1px solid var(--border); }
.timeline-hour:last-child { border-bottom: none; }
.timeline-hour .hlabel { width: 64px; flex-shrink: 0; font-size: 11.5px; color: var(--text-muted); padding: 6px 10px; border-right: 1px solid var(--border); font-variant-numeric: tabular-nums; }
.timeline-slots { position: relative; flex: 1; }
.appt-block {
  position: absolute; left: 8px; right: 8px;
  border-radius: 8px; padding: 6px 10px; overflow: hidden;
  border-left: 3px solid var(--primary);
  background: color-mix(in srgb, var(--primary) 10%, var(--surface));
  cursor: pointer; font-size: 12px;
}
.appt-block:hover { filter: brightness(1.03); box-shadow: var(--shadow); }
.appt-block .t { font-weight: 700; font-size: 11.5px; }
.appt-block .c { font-weight: 600; font-size: 12.5px; margin: 1px 0; }
.appt-block .s { color: var(--text-muted); font-size: 11px; }
.appt-block.status-pendente { border-color: var(--warning); background: color-mix(in srgb, var(--warning) 12%, var(--surface)); }
.appt-block.status-concluido { border-color: var(--success); background: color-mix(in srgb, var(--success) 12%, var(--surface)); }
.appt-block.status-cancelado { border-color: var(--danger); background: color-mix(in srgb, var(--danger) 10%, var(--surface)); opacity: .7; }

.week-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 10px; }
.week-day { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 12px; cursor: pointer; min-height: 130px; }
.week-day:hover { border-color: var(--primary); }
.week-day.is-today { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); }
.week-day .wd-name { font-size: 11px; text-transform: uppercase; color: var(--text-muted); font-weight: 700; }
.week-day .wd-num { font-family: 'Fraunces', serif; font-size: 20px; font-weight: 600; margin: 2px 0 8px; }
.week-appt { font-size: 11px; padding: 4px 6px; border-radius: 6px; background: var(--surface-2); margin-bottom: 4px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.week-more { font-size: 11px; color: var(--text-muted); }

/* ---------- Services (menu) grid ---------- */
.service-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 14px; }
.service-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px; position: relative; }
.service-card h4 { font-family: 'Fraunces', serif; font-size: 17px; font-weight: 600; margin-bottom: 6px; }
.service-card p { color: var(--text-muted); font-size: 12.5px; margin: 0 0 14px; min-height: 34px; }
.service-meta { display: flex; align-items: center; justify-content: space-between; }
.service-price { font-family: 'Fraunces', serif; font-size: 19px; font-weight: 600; color: var(--accent); }
.service-dur { font-size: 11.5px; color: var(--text-muted); }
.service-actions { position: absolute; top: 14px; right: 14px; display: flex; gap: 4px; }

/* ---------- WhatsApp ---------- */
.wa-row { display: flex; align-items: center; gap: 12px; padding: 12px 6px; border-bottom: 1px solid var(--border); }
.wa-row:last-child { border-bottom: none; }
.wa-info { flex: 1; min-width: 0; }
.wa-info .n { font-weight: 600; font-size: 13.5px; }
.wa-info .d { font-size: 12px; color: var(--text-muted); }
.template-item { border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 12px; margin-bottom: 10px; }
.template-item h5 { font-size: 13px; margin-bottom: 8px; font-family: 'Sora', sans-serif; font-weight: 700; }
.placeholder-hint { font-size: 11px; color: var(--text-muted); margin-top: 6px; }
.wa-cta { background: #25D366; color: #06301A; }
.wa-cta:hover { filter: brightness(1.05); }

/* ---------- Charts ---------- */
.chart-box { position: relative; height: 240px; }
.chart-box.tall { height: 300px; }

/* ---------- Modal ---------- */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(10, 16, 13, 0.5);
  display: flex; align-items: flex-start; justify-content: center;
  padding: 40px 20px; overflow-y: auto; z-index: 100;
}
.modal {
  background: var(--surface); border-radius: var(--radius-lg);
  width: 100%; max-width: 480px; box-shadow: var(--shadow);
  padding: 24px 26px 26px;
}
.modal.modal-lg { max-width: 640px; }
.modal-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 18px; }
.modal-head h3 { font-size: 18px; font-weight: 600; font-family: 'Fraunces', serif; }
.modal-close { background: none; border: none; cursor: pointer; color: var(--text-muted); padding: 4px; border-radius: 6px; }
.modal-close:hover { background: var(--surface-2); }
.modal-foot { display: flex; justify-content: flex-end; gap: 10px; margin-top: 20px; }
.modal-foot .left { margin-right: auto; }

/* ---------- Toast ---------- */
#toastHost { position: fixed; bottom: 22px; right: 22px; display: flex; flex-direction: column; gap: 8px; z-index: 200; }
.toast {
  background: var(--text); color: var(--bg);
  padding: 11px 16px; border-radius: 9px; font-size: 13px;
  box-shadow: var(--shadow); animation: toastIn .18s ease;
}
.toast.error { background: var(--danger); color: #fff; }
.toast.success { background: var(--success); color: #fff; }
@keyframes toastIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 6px; }

@media (max-width: 980px) {
  .two-col { grid-template-columns: 1fr; }
  .week-grid { grid-template-columns: repeat(4, 1fr); }
}
@media (max-width: 760px) {
  .sidebar { width: 76px; }
  .brand-name, .brand-clinic, .nav-item span:not(.icon-wrap), .user-name, .user-role { display: none; }
  .nav-item { justify-content: center; }
  .brand { justify-content: center; }
  .user-row { justify-content: center; }
  .field-row { grid-template-columns: 1fr; }
  .week-grid { grid-template-columns: repeat(2, 1fr); }
  .content { padding: 18px; }
  .topbar { padding: 14px 18px; }
}
