/* =============================================
   ODONTOHUB — Estilos globales
   odontohub.com.mx
   ============================================= */

:root {
  --green: #1D9E75;
  --green-dark: #085041;
  --green-light: #E1F5EE;
  --green-mid: #9FE1CB;
  --gray: #a6a6a6;
  --text: #1a1a1a;
  --text-muted: #6b7280;
  --text-light: #9ca3af;
  --border: #e5e7eb;
  --border-light: #f3f4f6;
  --bg: #f9fafb;
  --white: #ffffff;
  --danger: #ef4444;
  --warning: #f59e0b;
  --blue: #3b82f6;
  --sans: 'DM Sans', system-ui, sans-serif;
  --nav-height: 64px;
  --bottom-nav-height: 64px;
}

body.dark {
  --green: #2EBE8F;
  --green-dark: #1D9E75;
  --green-light: #143830;
  --green-mid: #1c4a3e;
  --gray: #6b6b6b;
  --text: #f1f1f1;
  --text-muted: #a1a1a1;
  --text-light: #7a7a7a;
  --border: #2e2e2e;
  --border-light: #232323;
  --bg: #0e0e0e;
  --white: #1a1a1a;
  --danger: #f87171;
  --warning: #fbbf24;
  --blue: #60a5fa;
}

body.dark .empty-icon,
body.dark img.topbar-logo {
  filter: brightness(0.95);
}

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

html { scroll-behavior: smooth; -webkit-text-size-adjust: 100%; }

body {
  font-family: var(--sans);
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

/* ---- TIPOGRAFÍA ---- */
h1 { font-size: 22px; font-weight: 600; }
h2 { font-size: 18px; font-weight: 600; }
h3 { font-size: 16px; font-weight: 500; }
p  { font-size: 14px; line-height: 1.6; }

/* ---- TOPBAR ---- */
.topbar {
  position: fixed; top: 0; left: 0; right: 0;
  height: var(--nav-height);
  background: var(--white);
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center;
  justify-content: space-between;
  padding: 0 20px; z-index: 100;
}
.topbar-logo { height: 48px; width: auto; }
.topbar-title {
  font-size: 16px; font-weight: 600; color: var(--text);
}
.topbar-icon {
  width: 46px; height: 46px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  background: var(--bg); border: 1px solid var(--border);
  cursor: pointer; font-size: 24px; font-weight: 600;
  text-decoration: none; color: var(--text);
}
.topbar-green {
  background: var(--green);
  border-bottom-color: var(--green-dark);
}
.topbar-green .topbar-title { color: #fff; }

/* ---- CONTENIDO PRINCIPAL ---- */
.main {
  padding-top: calc(var(--nav-height) + 16px);
  padding-bottom: calc(var(--bottom-nav-height) + 16px);
  padding-left: 16px; padding-right: 16px;
  max-width: 600px; margin: 0 auto;
}

/* ---- BOTTOM NAV ---- */
.bottom-nav {
  position: fixed; bottom: 0; left: 0; right: 0;
  height: var(--bottom-nav-height);
  background: var(--white);
  border-top: 1px solid var(--border);
  display: flex; align-items: center;
  justify-content: space-around;
  z-index: 100;
}
.nav-item {
  display: flex; flex-direction: column;
  align-items: center; gap: 3px;
  cursor: pointer; text-decoration: none;
  padding: 8px 16px; border-radius: 12px;
  transition: background 0.15s;
}
.nav-item:hover { background: var(--bg); }
.nav-icon { font-size: 22px; color: var(--text-muted); }
.nav-label { font-size: 10px; color: var(--text-muted); font-weight: 400; }
.nav-item.active .nav-icon { color: var(--green); }
.nav-item.active .nav-label { color: var(--green); font-weight: 500; }

/* ---- CARDS ---- */
.card {
  background: var(--white);
  border-radius: 16px;
  padding: 16px;
  border: 1px solid var(--border);
  margin-bottom: 12px;
}
.card-sm { padding: 12px; border-radius: 12px; }

/* ---- STAT CARDS ---- */
.stats-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px; margin-bottom: 16px;
}
.stat-card {
  background: var(--white);
  border-radius: 14px;
  padding: 14px;
  border: 1px solid var(--border);
}
.stat-num {
  font-size: 26px; font-weight: 600;
  color: var(--green); line-height: 1;
  margin-bottom: 4px;
}
.stat-label { font-size: 12px; color: var(--text-muted); }

/* ---- LISTA DE PACIENTES ---- */
.patient-row {
  display: flex; align-items: center;
  gap: 12px; padding: 12px 0;
  border-bottom: 1px solid var(--border-light);
  text-decoration: none; color: inherit;
}
.patient-row:last-child { border-bottom: none; }
.avatar {
  width: 40px; height: 40px; border-radius: 50%;
  background: var(--green-mid);
  display: flex; align-items: center; justify-content: center;
  font-size: 13px; font-weight: 600;
  color: var(--green-dark); flex-shrink: 0;
}
.patient-info { flex: 1; min-width: 0; }
.patient-name { font-size: 14px; font-weight: 500; color: var(--text); }
.patient-time { font-size: 12px; color: var(--text-muted); margin-top: 1px; }

/* ---- BADGES ---- */
.badge {
  font-size: 11px; font-weight: 500;
  padding: 3px 10px; border-radius: 20px;
  white-space: nowrap;
}
.badge-green { background: #E1F5EE; color: var(--green-dark); }
.badge-gray  { background: #f3f4f6; color: var(--text-muted); }
.badge-amber { background: #fef3c7; color: #92400e; }
.badge-red   { background: #fee2e2; color: #991b1b; }
.badge-blue  { background: #dbeafe; color: #1e40af; }

/* ---- BOTONES ---- */
.btn {
  display: flex; align-items: center; justify-content: center;
  gap: 8px; height: 50px; border-radius: 50px;
  font-size: 15px; font-weight: 500;
  font-family: var(--sans); cursor: pointer;
  border: none; transition: all 0.2s; width: 100%;
  text-decoration: none;
}
.btn-primary { background: var(--green); color: #fff; }
.btn-primary:hover { background: var(--green-dark); }
.btn-primary:active { transform: scale(0.98); }
.btn-outline {
  background: transparent; color: var(--green);
  border: 1.5px solid var(--green);
}
.btn-sm { height: 38px; font-size: 13px; border-radius: 20px; }
.btn-icon {
  width: 46px; height: 46px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  background: var(--green-light); color: var(--green);
  font-size: 18px; cursor: pointer; border: none;
  text-decoration: none;
}

/* ---- FORMULARIOS ---- */
.field { margin-bottom: 16px; }
.field label {
  display: block; font-size: 13px;
  font-weight: 500; color: var(--text); margin-bottom: 6px;
}
.field input, .field select, .field textarea {
  width: 100%; height: 46px;
  border-radius: 10px;
  border: 1.5px solid var(--border);
  padding: 0 14px; font-size: 15px;
  font-family: var(--sans);
  background: var(--white); color: var(--text);
  outline: none; transition: border-color 0.2s;
}
.field textarea { height: auto; padding: 12px 14px; resize: vertical; }
.field input:focus,
.field select:focus,
.field textarea:focus { border-color: var(--green); }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

/* ---- TABS ---- */
.tabs {
  display: flex; gap: 6px;
  margin-bottom: 16px; overflow-x: auto;
  scrollbar-width: none; -webkit-overflow-scrolling: touch;
}
.tabs::-webkit-scrollbar { display: none; }
.tab {
  padding: 7px 16px; border-radius: 20px;
  font-size: 13px; font-weight: 400;
  color: var(--text-muted); cursor: pointer;
  white-space: nowrap;
  border: 1px solid var(--border);
  background: var(--white);
  transition: all 0.15s;
}
.tab.active {
  background: var(--green); color: #fff;
  border-color: var(--green); font-weight: 500;
}

/* ---- TIMELINE ---- */
.timeline { padding: 4px 0; }
.tl-item { display: flex; gap: 12px; margin-bottom: 12px; }
.tl-left { display: flex; flex-direction: column; align-items: center; }
.tl-dot {
  width: 10px; height: 10px; border-radius: 50%;
  background: var(--green); flex-shrink: 0; margin-top: 3px;
}
.tl-line { width: 2px; flex: 1; background: var(--border); margin-top: 4px; min-height: 24px; }
.tl-date { font-size: 11px; color: var(--text-muted); margin-bottom: 2px; }
.tl-title { font-size: 14px; font-weight: 500; color: var(--text); }
.tl-note { font-size: 12px; color: var(--text-muted); margin-top: 2px; }

/* ---- CHAT ---- */
.chat-body {
  display: flex; flex-direction: column;
  gap: 10px; padding-bottom: 8px;
}
.msg { max-width: 80%; }
.msg-out {
  align-self: flex-end;
  background: var(--green); color: #fff;
  border-radius: 18px 18px 4px 18px;
  padding: 10px 14px; font-size: 14px; line-height: 1.5;
}
.msg-in {
  align-self: flex-start;
  background: var(--white); color: var(--text);
  border-radius: 18px 18px 18px 4px;
  padding: 10px 14px; font-size: 14px; line-height: 1.5;
  border: 1px solid var(--border);
}
.msg-time { font-size: 10px; color: var(--text-light); margin-top: 3px; text-align: right; }
.chat-input-wrap {
  display: flex; gap: 10px; align-items: center;
  padding: 12px 16px;
  background: var(--white);
  border-top: 1px solid var(--border);
  position: fixed; bottom: var(--bottom-nav-height);
  left: 0; right: 0;
}
.chat-input {
  flex: 1; height: 42px; border-radius: 21px;
  border: 1.5px solid var(--border);
  padding: 0 16px; font-size: 14px;
  font-family: var(--sans); outline: none;
  background: var(--bg);
}
.chat-input:focus { border-color: var(--green); }
.chat-send {
  width: 42px; height: 42px; border-radius: 50%;
  background: var(--green); color: #fff;
  border: none; font-size: 18px; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
}

/* ---- PROGRESS BAR ---- */
.progress-wrap { margin: 12px 0; }
.progress-label {
  display: flex; justify-content: space-between;
  font-size: 12px; color: var(--text-muted); margin-bottom: 6px;
}
.progress-bar {
  height: 8px; border-radius: 4px;
  background: var(--border);
}
.progress-fill {
  height: 100%; border-radius: 4px;
  background: var(--green); transition: width 0.3s;
}

/* ---- SECTION TITLE ---- */
.section-header {
  display: flex; align-items: center;
  justify-content: space-between; margin-bottom: 12px;
}
.section-title { font-size: 15px; font-weight: 600; color: var(--text); }
.section-link { font-size: 13px; color: var(--green); text-decoration: none; }

/* ---- EMPTY STATE ---- */
.empty-state {
  text-align: center; padding: 40px 20px;
  color: var(--text-muted);
}
.empty-icon { font-size: 48px; margin-bottom: 12px; }
.empty-text { font-size: 15px; font-weight: 500; margin-bottom: 6px; color: var(--text); }
.empty-sub { font-size: 13px; }

/* ---- ALERT BOX ---- */
.alert {
  border-radius: 12px; padding: 14px 16px;
  display: flex; align-items: flex-start; gap: 10px;
  margin-bottom: 12px;
}
.alert-green { background: #E1F5EE; }
.alert-amber { background: #fef3c7; }
.alert-red   { background: #fee2e2; }
.alert-icon { font-size: 20px; flex-shrink: 0; margin-top: 1px; }
.alert-title { font-size: 14px; font-weight: 500; color: #085041; }
.alert-sub { font-size: 12px; color: var(--text-muted); margin-top: 2px; }

/* Iconos nativos de date/time en modo oscuro */
body.dark input[type="date"]::-webkit-calendar-picker-indicator,
body.dark input[type="time"]::-webkit-calendar-picker-indicator {
    filter: invert(1);
}

body.dark .alert-green              { background: #143830; }
body.dark .alert-green .alert-title { color: #ffffff; }
body.dark .alert-green .alert-sub   { color: #a7f3d0; }
body.dark .alert-green .alert-icon  { filter: brightness(1.4); }

/* ---- UTILS ---- */
.mt-4  { margin-top: 4px; }
.mt-8  { margin-top: 8px; }
.mt-12 { margin-top: 12px; }
.mt-16 { margin-top: 16px; }
.mt-24 { margin-top: 24px; }
.mb-4  { margin-bottom: 4px; }
.mb-8  { margin-bottom: 8px; }
.mb-12 { margin-bottom: 12px; }
.mb-16 { margin-bottom: 16px; }
.flex  { display: flex; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-8  { gap: 8px; }
.gap-12 { gap: 12px; }
.text-green { color: var(--green); }
.text-muted { color: var(--text-muted); }
.text-sm  { font-size: 13px; }
.text-xs  { font-size: 11px; }
.font-500 { font-weight: 500; }
.font-600 { font-weight: 600; }
.w-full   { width: 100%; }

/* =============================================
   ODONTOHUB — Modo oscuro: toggle flotante
   ============================================= */

body, .topbar, .card, .bottom-nav, .patient-row, input, select, textarea {
  transition: background-color 0.2s ease, color 0.2s ease, border-color 0.2s ease;
}

.theme-toggle {
  width: 38px; height: 38px; border-radius: 50%;
  background: var(--bg); border: 1px solid var(--border);
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; font-size: 18px;
}

/* =============================================
   ODONTOHUB — Asistente de voz
   ============================================= */

.voz-btn {
  position: fixed; bottom: 80px; right: 20px;
  width: 56px; height: 56px; border-radius: 50%;
  background: var(--green); color: #fff;
  border: none; font-size: 24px; cursor: pointer;
  box-shadow: 0 4px 16px rgba(29,158,117,0.4);
  display: flex; align-items: center; justify-content: center;
  z-index: 60; transition: transform 0.2s;
}
.voz-btn.escuchando {
  background: #ef4444;
  animation: pulso-voz 1s infinite;
}
@keyframes pulso-voz {
  0% { box-shadow: 0 0 0 0 rgba(239,68,68,0.5); }
  70% { box-shadow: 0 0 0 14px rgba(239,68,68,0); }
  100% { box-shadow: 0 0 0 0 rgba(239,68,68,0); }
}
.voz-status {
  display: none;
  position: fixed; bottom: 145px; right: 20px; left: 20px;
  max-width: 360px; margin: 0 auto;
  background: var(--white); border: 1px solid var(--border);
  border-radius: 14px; padding: 12px 16px;
  font-size: 13px; color: var(--text); text-align: center;
  box-shadow: 0 4px 16px rgba(0,0,0,0.15);
  z-index: 60;
}
