@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap');

/* ===== DESIGN TOKENS ===== */
:root {
  --bg0: #0d0f17;
  --bg1: #131520;
  --bg2: #1a1d2e;
  --bg3: #20243a;
  --brd: #252840;
  --brd2: #2e3248;
  --text: #dde1ee;
  --muted: #8890a8;
  --dim: #5a6278;
  --shadow: rgba(0,0,0,0.5);
  --overlay: rgba(0,0,0,0.65);
  --accent: #4f7ef8;
}

[data-theme="light"] {
  --bg0: #f0f2f8;
  --bg1: #ffffff;
  --bg2: #f7f8fc;
  --bg3: #eceef6;
  --brd: #e0e3ef;
  --brd2: #cdd1e4;
  --text: #1a1d2e;
  --muted: #6b7185;
  --dim: #9ba3b8;
  --shadow: rgba(0,0,0,0.12);
  --overlay: rgba(30,35,60,0.45);
  --accent: #4f7ef8;
}

/* ===== BOOTSTRAP COLLAPSE (sem depender do Bootstrap CSS) ===== */
.collapse { display: none; }
.collapse.show { display: block !important; }
.collapsing { height: 0; overflow: hidden; transition: height 0.3s ease; }

/* ===== RESET & BASE ===== */
*, *::before, *::after { box-sizing: border-box; }

body {
  font-family: 'Inter', sans-serif;
  background-color: var(--bg0);
  color: var(--text);
  font-size: 14px;
  min-height: 100vh;
  margin: 0;
}

a { color: inherit; }

/* ===== TOPBAR ===== */
.topbar {
  height: 56px;
  background: var(--bg1);
  border-bottom: 1px solid var(--brd);
  position: sticky;
  top: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  gap: 16px;
}

.topbar-left {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.topbar-logo { font-size: 20px; line-height: 1; flex-shrink: 0; }

.topbar-unit {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

/* Theme toggle */
.theme-toggle { position: relative; width: 34px; height: 20px; cursor: pointer; flex-shrink: 0; }
.theme-toggle input { opacity: 0; width: 0; height: 0; position: absolute; }
.theme-toggle-track {
  position: absolute;
  inset: 0;
  border-radius: 10px;
  background: #c8ccd8;
  transition: background 0.2s;
}
.theme-toggle input:checked + .theme-toggle-track { background: var(--accent); }
.theme-toggle-thumb {
  position: absolute;
  width: 14px;
  height: 14px;
  background: white;
  border-radius: 50%;
  top: 3px;
  left: 3px;
  transition: transform 0.2s;
  pointer-events: none;
}
.theme-toggle input:checked ~ .theme-toggle-thumb { transform: translateX(14px); }

/* Nav buttons */
.btn-nav {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 5px 11px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 500;
  font-family: 'Inter', sans-serif;
  text-decoration: none;
  cursor: pointer;
  border: 1px solid var(--brd);
  background: transparent;
  color: var(--muted);
  transition: all 0.15s;
  white-space: nowrap;
  line-height: 1.4;
}
.btn-nav:hover { color: var(--text); border-color: var(--brd2); background: var(--bg3); }
.btn-nav.active {
  background: rgba(79,126,248,0.13);
  border-color: rgba(79,126,248,0.33);
  color: var(--accent);
}
.btn-nav.danger {
  background: rgba(248,113,113,0.13);
  border-color: rgba(248,113,113,0.27);
  color: #f87171;
}
.btn-nav.danger:hover { background: rgba(248,113,113,0.22); }

.btn-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  border-radius: 6px;
  border: 1px solid var(--brd);
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  transition: all 0.15s;
  text-decoration: none;
  font-size: 14px;
  flex-shrink: 0;
}
.btn-icon:hover { color: var(--text); background: var(--bg3); }

/* ===== MAIN CONTENT ===== */
.main-content {
  padding: 24px;
  max-width: 1600px;
  margin: 0 auto;
}

/* ===== DATE BAR ===== */
.date-bar {
  background: var(--bg2);
  border-radius: 10px;
  padding: 12px 18px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
  border: 1px solid var(--brd);
  flex-wrap: wrap;
  gap: 12px;
}

/* ===== METRIC CARDS ===== */
.metrics-row {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}

.metric-card {
  flex: 1;
  min-width: 160px;
  background: var(--bg1);
  border-radius: 10px;
  padding: 16px 18px;
  border: 1px solid var(--brd);
  border-top: 3px solid var(--accent);
  transition: background 0.15s;
  cursor: default;
}
.metric-card:hover { background: var(--bg3); }
.metric-label {
  font-size: 11px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  margin-bottom: 6px;
}
.metric-value {
  font-size: 26px;
  font-weight: 700;
  color: var(--text);
  line-height: 1.1;
}
.metric-sub { font-size: 11px; color: var(--dim); margin-top: 4px; }

/* ===== SECTION TOGGLE ===== */
.section-toggle-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 14px;
  border-radius: 7px;
  border: 1px solid var(--brd);
  background: transparent;
  color: var(--muted);
  font-size: 12px;
  font-weight: 500;
  font-family: 'Inter', sans-serif;
  cursor: pointer;
  transition: all 0.15s;
  margin-bottom: 10px;
}
.section-toggle-btn:hover { color: var(--text); background: var(--bg3); }

/* ===== SUMMARY TABLE ===== */
.summary-table-wrap {
  background: var(--bg1);
  border-radius: 10px;
  border: 1px solid var(--brd);
  overflow: hidden;
  margin-bottom: 16px;
}
.summary-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
.summary-table th {
  background: var(--bg3);
  font-weight: 600;
  font-size: 11px;
  color: var(--muted);
  padding: 10px 12px;
  text-align: left;
  border-bottom: 1px solid var(--brd);
}
.summary-table tbody tr:nth-child(odd) { background: var(--bg1); }
.summary-table tbody tr:nth-child(even) { background: var(--bg2); }
.summary-table td {
  padding: 8px 12px;
  color: var(--text);
  border-bottom: 1px solid var(--brd);
  font-size: 13px;
}
.summary-table td:last-child { font-weight: 600; }

/* ===== RANKINGS ===== */
.rankings-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  margin-bottom: 16px;
}
@media (max-width: 900px) { .rankings-grid { grid-template-columns: 1fr; } }

.ranking-card {
  background: var(--bg1);
  border-radius: 9px;
  padding: 14px 16px;
  border: 1px solid var(--brd);
}
.ranking-card-title {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  margin-bottom: 12px;
}
.ranking-item { margin-bottom: 10px; }
.ranking-item-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 4px;
}
.ranking-item-name { font-size: 12px; font-weight: 500; color: var(--text); }
.ranking-item-rate { font-size: 11px; color: var(--muted); }
.ranking-bar-track {
  height: 5px;
  border-radius: 3px;
  background: var(--bg3);
  overflow: hidden;
}
.ranking-bar-fill { height: 100%; border-radius: 3px; transition: width 0.4s ease; }
.bar-green { background: #4ade80; }
.bar-yellow { background: #fbbf24; }
.bar-red { background: #f87171; }

/* ===== PROFESSIONALS SCROLL ===== */
.professionals-scroll {
  display: flex;
  gap: 12px;
  overflow-x: auto;
  padding-bottom: 16px;
  -webkit-overflow-scrolling: touch;
}
.professionals-scroll::-webkit-scrollbar { height: 6px; }
.professionals-scroll::-webkit-scrollbar-track { background: var(--bg2); border-radius: 3px; }
.professionals-scroll::-webkit-scrollbar-thumb { background: var(--brd2); border-radius: 3px; }

.prof-column {
  width: 210px;
  flex-shrink: 0;
  border-radius: 10px;
  border: 1px solid var(--brd);
  background: var(--bg1);
  overflow: hidden;
}
.prof-header {
  background: var(--bg2);
  border-top: 3px solid var(--accent);
  padding: 10px 12px;
  border-bottom: 1px solid var(--brd);
}
.prof-header a {
  font-size: 12px;
  font-weight: 600;
  color: var(--text);
  text-decoration: none;
  display: block;
}
.prof-header a:hover { color: var(--accent); }
.prof-sub { font-size: 10px; color: var(--dim); margin-top: 2px; }
.prof-body { padding: 8px; }

/* ===== SLOT CARDS ===== */
.slot-card {
  border-radius: 7px;
  padding: 8px 10px;
  margin-bottom: 5px;
  font-size: 12px;
  border-width: 1px;
  border-style: solid;
  border-color: transparent;
  transition: transform 0.15s, box-shadow 0.15s;
}
.slot-time { font-weight: 600; font-size: 12px; margin-bottom: 1px; }
.slot-status { font-size: 10px; opacity: 0.8; }
.slot-patient {
  font-size: 11px;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-top: 2px;
}
.slot-card.has-patient { cursor: pointer; }
.slot-card.has-patient:hover {
  transform: translateY(-1px);
  box-shadow: 0 3px 10px rgba(37,40,64,0.55);
}

/* Status — Dark */
.slot-confirmado     { background: #1a3a28; color: #4ade80; border-color: #2d5a3c; }
.slot-nao-confirmado { background: #352e0f; color: #fbbf24; border-color: #52460f; }
.slot-atendido       { background: #172438; color: #60a5fa; border-color: #1e3a56; }
.slot-nao-compareceu { background: #3a1a1a; color: #f87171; border-color: #5a2828; }
.slot-disponivel     { background: #1a1d2a; color: #64748b; border-color: #252838; }
.slot-bloqueado      { background: #141618; color: #3b4050; border-color: #1c1e24; }

/* Status — Light */
[data-theme="light"] .slot-confirmado     { background: #e8faf0; color: #16a34a; border-color: #bbf0d0; }
[data-theme="light"] .slot-nao-confirmado { background: #fefce8; color: #d97706; border-color: #fde68a; }
[data-theme="light"] .slot-atendido       { background: #eff6ff; color: #2563eb; border-color: #bfdbfe; }
[data-theme="light"] .slot-nao-compareceu { background: #fff1f2; color: #dc2626; border-color: #fecaca; }
[data-theme="light"] .slot-disponivel     { background: #f8f9fc; color: #94a3b8; border-color: #e2e8f0; }
[data-theme="light"] .slot-bloqueado      { background: #f3f4f6; color: #c4c9d4; border-color: #e5e7eb; }

/* ===== CUSTOM MODAL ===== */
.modal-overlay-custom {
  display: none;
  position: fixed;
  inset: 0;
  background: var(--overlay);
  backdrop-filter: blur(2px);
  z-index: 10000;
  justify-content: center;
  align-items: center;
  overflow-y: auto;
  padding: 24px;
}
.modal-overlay-custom.active { display: flex; }

.modal-box-custom {
  background: var(--bg1);
  border-radius: 16px;
  max-width: 620px;
  width: 100%;
  overflow: hidden;
  border: 1px solid var(--brd);
  animation: fadeInUp 0.2s ease;
  position: relative;
}
@keyframes fadeInUp {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: translateY(0); }
}

.modal-hdr {
  background: var(--bg2);
  padding: 16px 24px;
  border-bottom: 1px solid var(--brd);
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
}
.modal-status-pill {
  display: inline-block;
  border-radius: 20px;
  padding: 2px 10px;
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 6px;
}
.modal-patient-name { font-size: 20px; font-weight: 700; color: var(--text); }
.modal-meta { font-size: 12px; color: var(--muted); margin-top: 4px; }

.modal-close-btn {
  width: 32px;
  height: 32px;
  background: var(--bg3);
  border: none;
  border-radius: 8px;
  color: var(--muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  flex-shrink: 0;
  transition: color 0.15s, background 0.15s;
  line-height: 1;
}
.modal-close-btn:hover { color: var(--text); background: var(--brd); }

.modal-bdy {
  display: grid;
  grid-template-columns: 1fr 1fr;
}
@media (max-width: 540px) { .modal-bdy { grid-template-columns: 1fr; } }

.modal-col {
  padding: 20px 24px;
}
.modal-col:first-child { border-right: 1px solid var(--brd); }

.modal-section-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 10px;
  font-weight: 700;
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  margin-bottom: 14px;
}
.modal-section-title::after {
  content: '';
  width: 14px;
  height: 2px;
  background: var(--accent);
  border-radius: 2px;
}
.modal-field-label {
  font-size: 10px;
  font-weight: 600;
  color: var(--dim);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: 3px;
}
.modal-field-value {
  font-size: 13px;
  font-weight: 500;
  color: var(--text);
  margin-bottom: 16px;
}
.modal-ftr {
  background: var(--bg2);
  padding: 12px 24px;
  display: flex;
  justify-content: flex-end;
  border-top: 1px solid var(--brd);
}

.modal-loading {
  padding: 48px 24px;
  text-align: center;
  color: var(--muted);
  font-size: 13px;
}

/* ===== BUTTONS ===== */
.btn-accent {
  background: var(--accent);
  color: white;
  border: none;
  border-radius: 8px;
  padding: 10px 18px;
  font-size: 13px;
  font-weight: 700;
  font-family: 'Inter', sans-serif;
  cursor: pointer;
  transition: opacity 0.15s;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
  line-height: 1.4;
}
.btn-accent:hover { opacity: 0.88; color: white; }
.btn-accent:disabled { opacity: 0.6; cursor: not-allowed; }

.btn-sm-accent {
  background: var(--accent);
  color: white;
  border: none;
  border-radius: 6px;
  padding: 6px 12px;
  font-size: 12px;
  font-weight: 600;
  font-family: 'Inter', sans-serif;
  cursor: pointer;
  transition: opacity 0.15s;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  white-space: nowrap;
  line-height: 1.4;
}
.btn-sm-accent:hover { opacity: 0.88; color: white; }

.btn-warn {
  background: rgba(251,191,36,0.13);
  border: 1px solid rgba(251,191,36,0.35);
  color: #fbbf24;
  border-radius: 7px;
  padding: 8px 14px;
  font-size: 12px;
  font-weight: 600;
  font-family: 'Inter', sans-serif;
  cursor: pointer;
  transition: all 0.15s;
  white-space: nowrap;
  line-height: 1.4;
}
.btn-warn:hover { background: rgba(251,191,36,0.22); }
.btn-warn:disabled { opacity: 0.6; cursor: not-allowed; }

.btn-ghost {
  background: var(--bg3);
  border: 1px solid var(--brd);
  color: var(--muted);
  border-radius: 7px;
  padding: 8px 14px;
  font-size: 12px;
  font-weight: 500;
  font-family: 'Inter', sans-serif;
  cursor: pointer;
  transition: all 0.15s;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
  line-height: 1.4;
}
.btn-ghost:hover { color: var(--text); background: var(--brd); }

.btn-danger-soft {
  background: rgba(248,113,113,0.13);
  border: 1px solid rgba(248,113,113,0.27);
  color: #f87171;
  border-radius: 7px;
  padding: 6px 12px;
  font-size: 12px;
  font-weight: 600;
  font-family: 'Inter', sans-serif;
  cursor: pointer;
  transition: all 0.15s;
  text-decoration: none;
  white-space: nowrap;
  line-height: 1.4;
}
.btn-danger-soft:hover { background: rgba(248,113,113,0.22); color: #f87171; }

/* ===== FORM INPUTS ===== */
.input-custom {
  background: var(--bg2);
  border: 1px solid var(--brd);
  color: var(--text);
  border-radius: 7px;
  padding: 10px 12px;
  font-size: 13px;
  font-family: 'Inter', sans-serif;
  transition: border-color 0.15s, box-shadow 0.15s;
  width: 100%;
}
.input-custom:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(79,126,248,0.15);
  background: var(--bg2);
  color: var(--text);
}
.label-custom {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  margin-bottom: 6px;
  display: block;
}

/* ===== LOGIN PAGE ===== */
.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg0);
}
.login-card {
  width: 380px;
  background: var(--bg1);
  border: 1px solid var(--brd);
  border-radius: 16px;
  padding: 36px;
  box-shadow: 0 8px 40px var(--shadow);
}
.login-icon { font-size: 28px; text-align: center; margin-bottom: 6px; }
.login-title { font-size: 18px; font-weight: 700; color: var(--text); text-align: center; margin-bottom: 4px; }
.login-subtitle { font-size: 12px; color: var(--muted); text-align: center; margin-bottom: 28px; }
.alert-error-custom {
  background: rgba(248,113,113,0.13);
  border: 1px solid rgba(248,113,113,0.27);
  color: #f87171;
  border-radius: 7px;
  padding: 10px 14px;
  font-size: 13px;
  margin-bottom: 16px;
}

/* ===== PAGE CARDS (users, superadmin) ===== */
.page-card {
  background: var(--bg1);
  border-radius: 10px;
  border: 1px solid var(--brd);
  margin-bottom: 20px;
  overflow: hidden;
}
.page-card-header {
  background: var(--bg2);
  padding: 14px 20px;
  border-bottom: 1px solid var(--brd);
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
}
.page-card-body { padding: 20px; }

/* ===== DATA TABLE ===== */
.data-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.data-table th {
  background: var(--bg3);
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  padding: 10px 14px;
  text-align: left;
  border-bottom: 1px solid var(--brd);
  cursor: pointer;
  user-select: none;
}
.data-table th:hover { color: var(--text); }
.data-table th.sort-active { color: var(--accent); }
.data-table td {
  padding: 10px 14px;
  color: var(--text);
  border-bottom: 1px solid var(--brd);
  vertical-align: middle;
}
.data-table tbody tr:hover { background: var(--bg2); }

/* ===== PERFORMANCE BADGES ===== */
.perf-badge { display: inline-block; border-radius: 4px; padding: 3px 8px; font-size: 12px; font-weight: 600; }
.perf-green  { color: #4ade80; background: rgba(74,222,128,0.13); }
.perf-yellow { color: #fbbf24; background: rgba(251,191,36,0.13); }
.perf-red    { color: #f87171; background: rgba(248,113,113,0.13); }

/* ===== ROLE BADGES ===== */
.role-badge { display: inline-block; border-radius: 4px; padding: 2px 8px; font-size: 11px; font-weight: 600; }
.role-superadmin { color: #f87171; background: rgba(248,113,113,0.13); }
.role-admin      { color: #4ade80; background: rgba(74,222,128,0.13); }
.role-user       { color: #8890a8; background: rgba(136,144,168,0.13); }

/* ===== SECTION TITLE ===== */
.section-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 12px;
}

/* ===== EMPTY STATE ===== */
.empty-state {
  background: var(--bg1);
  border: 1px solid var(--brd);
  border-radius: 10px;
  padding: 32px;
  text-align: center;
  color: var(--muted);
  font-size: 13px;
}

/* ===== TOAST ===== */
.toast-custom-wrap {
  position: fixed;
  top: 16px;
  right: 16px;
  z-index: 11000;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}
.toast-custom {
  background: var(--bg2);
  border: 1px solid var(--brd);
  border-radius: 8px;
  padding: 12px 16px;
  font-size: 13px;
  color: var(--text);
  box-shadow: 0 4px 16px var(--shadow);
  min-width: 260px;
  animation: toastSlide 0.2s ease;
  pointer-events: all;
}
@keyframes toastSlide {
  from { opacity: 0; transform: translateX(20px); }
  to   { opacity: 1; transform: translateX(0); }
}

/* ===== BOOTSTRAP OVERRIDES ===== */
.form-control {
  background-color: var(--bg2) !important;
  border-color: var(--brd) !important;
  color: var(--text) !important;
  font-family: 'Inter', sans-serif !important;
  font-size: 13px !important;
  border-radius: 7px !important;
}
.form-control:focus {
  background-color: var(--bg2) !important;
  border-color: var(--accent) !important;
  color: var(--text) !important;
  box-shadow: 0 0 0 3px rgba(79,126,248,0.15) !important;
}
.form-select {
  background-color: var(--bg2) !important;
  border-color: var(--brd) !important;
  color: var(--text) !important;
  font-family: 'Inter', sans-serif !important;
  font-size: 13px !important;
  border-radius: 7px !important;
}
.form-select:focus {
  border-color: var(--accent) !important;
  box-shadow: 0 0 0 3px rgba(79,126,248,0.15) !important;
}
.form-check-input:checked {
  background-color: var(--accent) !important;
  border-color: var(--accent) !important;
}
.form-check-label { color: var(--text) !important; font-size: 13px !important; }
.form-label { color: var(--muted) !important; font-size: 12px !important; font-family: 'Inter', sans-serif !important; }

/* Bootstrap modal dark override */
.modal-content {
  background: var(--bg1) !important;
  border-color: var(--brd) !important;
  color: var(--text) !important;
  border-radius: 12px !important;
}
.modal-header {
  background: var(--bg2) !important;
  border-color: var(--brd) !important;
}
.modal-footer {
  background: var(--bg2) !important;
  border-color: var(--brd) !important;
}
.modal-title { color: var(--text) !important; font-size: 15px !important; font-weight: 600 !important; }
.btn-close { filter: invert(1) opacity(0.6); }
.btn-close:hover { filter: invert(1) opacity(1); }

/* Collapse */
.collapse-section { margin-bottom: 16px; }
