/* =========================================================
   ODONTOGRAMA — Sonrisas Arte para tu Boca
   Paleta: Azul Marino #1B365D · Dorado #D4AF37
   ========================================================= */

/* ---------------------------------------------------------
   0. VARIABLES & RESET
   --------------------------------------------------------- */
*,*::before,*::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --navy:         #1B365D;
  --navy-dark:    #122543;
  --navy-mid:     #254880;
  --gold:         #D4AF37;
  --gold-light:   #E8CB5B;
  --gold-dim:     #A8892B;
  --white:        #FFFFFF;
  --surface:      #F8FAFC;
  --surface-2:    #EFF4F9;
  --border:       #DDE5EF;
  --text:         #334155;
  --text-light:   #64748B;
  --text-muted:   #94A3B8;
  --success:      #16A34A;
  --success-bg:   #F0FDF4;
  --error:        #DC2626;
  --font-display: 'Montserrat', system-ui, sans-serif;
  --font-body:    'Inter', system-ui, sans-serif;
  --radius-sm:    4px;
  --radius-md:    8px;
  --radius-lg:    12px;
  --shadow-sm:    0 1px 3px rgba(27,54,93,.08);
  --shadow-md:    0 4px 12px rgba(27,54,93,.10);
  --shadow-lg:    0 10px 30px rgba(27,54,93,.12);
}

html { font-size: 15px; }
body {
  font-family: var(--font-body);
  background: var(--surface);
  color: var(--text);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ---------------------------------------------------------
   1. NAVBAR
   --------------------------------------------------------- */
.odo-navbar {
  background: var(--navy);
  color: var(--white);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem 1.5rem;
  gap: 1rem;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: var(--shadow-md);
}

.odo-navbar__back {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  color: var(--gold);
  text-decoration: none;
  font-size: 0.85rem;
  font-family: var(--font-display);
  font-weight: 500;
  transition: opacity 0.2s;
}
.odo-navbar__back:hover { opacity: 0.8; }

.odo-navbar__brand {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  font-family: var(--font-display);
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--white);
}
.odo-navbar__brand img { border-radius: 4px; }

.odo-navbar__actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

/* ---------------------------------------------------------
   2. BOTONES
   --------------------------------------------------------- */
.odo-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.5rem 1rem;
  border-radius: var(--radius-md);
  font-family: var(--font-display);
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  border: none;
  transition: all 0.2s;
  white-space: nowrap;
}
.odo-btn--primary {
  background: var(--gold);
  color: var(--navy-dark);
}
.odo-btn--primary:hover {
  background: var(--gold-light);
  box-shadow: 0 4px 12px rgba(212,175,55,.35);
}
.odo-btn--ghost {
  background: transparent;
  color: var(--white);
  border: 1.5px solid rgba(255,255,255,0.25);
}
.odo-btn--ghost:hover {
  background: rgba(255,255,255,0.08);
}
.odo-btn--full { width: 100%; justify-content: center; }
.odo-btn--xs {
  padding: 0.3rem 0.65rem;
  font-size: 0.75rem;
}

/* Botones ghost dentro de cards (fondo blanco) */
.odo-card .odo-btn--ghost {
  color: var(--navy);
  border-color: var(--border);
}
.odo-card .odo-btn--ghost:hover { background: var(--surface-2); }

/* ---------------------------------------------------------
   3. LAYOUT PRINCIPAL
   --------------------------------------------------------- */
.odo-main {
  display: grid;
  grid-template-columns: 1fr 400px;
  gap: 1.25rem;
  padding: 1.25rem;
  flex: 1;
  max-width: 1400px;
  margin: 0 auto;
  width: 100%;
}

/* ---------------------------------------------------------
   4. PANEL & CARDS
   --------------------------------------------------------- */
.odo-panel {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.odo-card {
  background: var(--white);
  border-radius: var(--radius-lg);
  padding: 1.25rem;
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border);
}

.odo-card__title {
  font-family: var(--font-display);
  font-size: 0.92rem;
  font-weight: 700;
  color: var(--navy);
  margin-bottom: 1rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

/* ---------------------------------------------------------
   5. FORMULARIO PACIENTE
   --------------------------------------------------------- */
.odo-form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
}

.odo-field {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}
.odo-field label {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-light);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.odo-field input,
.odo-field select,
.odo-field textarea {
  padding: 0.55rem 0.75rem;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-md);
  font-family: var(--font-body);
  font-size: 0.88rem;
  color: var(--text);
  background: var(--surface);
  transition: border-color 0.2s;
  outline: none;
}
.odo-field input:focus,
.odo-field select:focus {
  border-color: var(--gold);
  background: var(--white);
}

/* ---------------------------------------------------------
   6. TOGGLE DENTICIÓN
   --------------------------------------------------------- */
.odo-denticion-toggle {
  display: flex;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
}
.odo-toggle-label {
  font-family: var(--font-display);
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--navy);
  white-space: nowrap;
}
.odo-toggle-group {
  display: flex;
  gap: 0.4rem;
  flex-wrap: wrap;
}
.odo-toggle-btn {
  padding: 0.4rem 0.85rem;
  border-radius: var(--radius-full, 9999px);
  border: 1.5px solid var(--border);
  background: var(--surface);
  font-size: 0.78rem;
  font-family: var(--font-display);
  font-weight: 600;
  color: var(--text-light);
  cursor: pointer;
  transition: all 0.2s;
}
.odo-toggle-btn.active {
  background: var(--navy);
  color: var(--gold);
  border-color: var(--navy);
}
.odo-toggle-btn:hover:not(.active) {
  border-color: var(--navy);
  color: var(--navy);
}

/* ---------------------------------------------------------
   7. ODONTOGRAMA SVG
   --------------------------------------------------------- */
.odo-card--odontograma { padding: 1.25rem 1rem; }

.odo-odontograma-wrap {
  width: 100%;
  overflow-x: auto;
}

.odo-cuadrante-labels {
  display: flex;
  justify-content: space-around;
  font-size: 0.72rem;
  color: var(--text-muted);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 0.25rem 1rem;
}

.odo-svg {
  width: 100%;
  min-width: 600px;
  height: auto;
  display: block;
  cursor: pointer;
}

/* Diente SVG groups */
.odo-diente {
  cursor: pointer;
  transition: transform 0.15s;
  transform-origin: center;
}
.odo-diente:hover { transform: scale(1.1); }
.odo-diente.seleccionado .diente-corona {
  fill: var(--gold) !important;
  stroke: var(--gold-dim) !important;
}
.odo-diente.con-proc .diente-corona {
  fill: var(--success) !important;
  stroke: #15803d !important;
}
.odo-diente-num {
  font-family: var(--font-display);
  font-size: 7px;
  font-weight: 700;
  fill: var(--text-light);
  text-anchor: middle;
  pointer-events: none;
}
.odo-diente.seleccionado .odo-diente-num,
.odo-diente.con-proc .odo-diente-num {
  fill: var(--white);
}

/* Leyenda */
.odo-leyenda {
  display: flex;
  gap: 1.25rem;
  justify-content: center;
  margin-top: 0.75rem;
  flex-wrap: wrap;
}
.odo-leyenda-item {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.75rem;
  color: var(--text-light);
}
.odo-leyenda-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  display: inline-block;
}

/* ---------------------------------------------------------
   8. PANEL PROCEDIMIENTO
   --------------------------------------------------------- */
.odo-diente-seleccionado {
  background: var(--surface-2);
  border-radius: var(--radius-md);
  padding: 1rem;
  text-align: center;
  color: var(--text-muted);
  font-size: 0.85rem;
  border: 1.5px dashed var(--border);
}

.odo-proc-form {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.odo-diente-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--navy);
  color: var(--gold);
  font-family: var(--font-display);
  font-size: 1.1rem;
  font-weight: 800;
  width: 52px;
  height: 52px;
  border-radius: 50%;
  margin-top: 0.25rem;
}

/* ---------------------------------------------------------
   9. PRESUPUESTO
   --------------------------------------------------------- */
.odo-presupuesto-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.odo-presupuesto-empty {
  text-align: center;
  color: var(--text-muted);
  font-size: 0.85rem;
  padding: 1.5rem 0;
  border: 1.5px dashed var(--border);
  border-radius: var(--radius-md);
  margin-top: 0.5rem;
}

.odo-tabla-presupuesto {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.82rem;
  margin-top: 0.5rem;
}
.odo-tabla-presupuesto th {
  text-align: left;
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
  padding: 0.4rem 0.5rem;
  border-bottom: 1.5px solid var(--border);
}
.odo-tabla-presupuesto td {
  padding: 0.55rem 0.5rem;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
.odo-tabla-presupuesto tr:last-child td { border-bottom: none; }
.odo-tabla-presupuesto .diente-num-cell {
  background: var(--navy);
  color: var(--gold);
  font-weight: 800;
  font-family: var(--font-display);
  font-size: 0.82rem;
  border-radius: 50%;
  width: 28px;
  height: 28px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.odo-tabla-presupuesto .proc-name { font-weight: 600; color: var(--navy); }
.odo-tabla-presupuesto .proc-valor { font-weight: 700; color: var(--text); }
.odo-btn-eliminar {
  background: none;
  border: none;
  color: var(--error);
  cursor: pointer;
  padding: 0.2rem;
  border-radius: 4px;
  display: flex;
  align-items: center;
  transition: background 0.15s;
}
.odo-btn-eliminar:hover { background: #FEF2F2; }

/* Totales */
.odo-totales {
  margin-top: 1rem;
  border-top: 2px solid var(--border);
  padding-top: 0.75rem;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}
.odo-total-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.85rem;
  color: var(--text);
  padding: 0.3rem 0;
}
.odo-total-row--abonado { color: var(--success); font-weight: 600; }
.odo-total-row--saldo {
  font-family: var(--font-display);
  font-size: 1rem;
  font-weight: 800;
  color: var(--navy);
  border-top: 1.5px solid var(--border);
  padding-top: 0.5rem;
  margin-top: 0.25rem;
}

/* Abonos */
.odo-abonos-section {
  background: var(--surface-2);
  border-radius: var(--radius-md);
  padding: 0.6rem 0.75rem;
}
.odo-abonos-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-light);
  margin-bottom: 0.4rem;
}
.odo-abono-item {
  display: flex;
  justify-content: space-between;
  font-size: 0.8rem;
  padding: 0.25rem 0;
  color: var(--text);
  border-bottom: 1px dashed var(--border);
}
.odo-abono-form {
  display: flex;
  gap: 0.4rem;
  align-items: center;
  margin-top: 0.5rem;
  flex-wrap: wrap;
}
.odo-abono-form input {
  padding: 0.35rem 0.6rem;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 0.78rem;
  flex: 1;
  min-width: 90px;
  outline: none;
}
.odo-abono-form input:focus { border-color: var(--gold); }

/* Acciones */
.odo-acciones {
  display: flex;
  gap: 0.6rem;
  margin-top: 1rem;
  flex-wrap: wrap;
}
.odo-acciones .odo-btn { flex: 1; justify-content: center; }

/* ---------------------------------------------------------
   10. MODAL HISTORIAL
   --------------------------------------------------------- */
.odo-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(18, 37, 67, 0.6);
  backdrop-filter: blur(4px);
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}
.odo-modal {
  background: var(--white);
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 600px;
  max-height: 80vh;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-lg);
}
.odo-modal__header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid var(--border);
}
.odo-modal__header h2 {
  font-family: var(--font-display);
  font-size: 1rem;
  font-weight: 700;
  color: var(--navy);
}
.odo-modal__close {
  background: none;
  border: none;
  font-size: 1.5rem;
  color: var(--text-muted);
  cursor: pointer;
  line-height: 1;
  padding: 0.25rem;
  border-radius: 4px;
}
.odo-modal__close:hover { background: var(--surface-2); color: var(--navy); }
.odo-modal__search {
  padding: 0.75rem 1.5rem;
  border-bottom: 1px solid var(--border);
}
.odo-modal__search input {
  width: 100%;
  padding: 0.55rem 0.85rem;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-md);
  font-size: 0.88rem;
  outline: none;
}
.odo-modal__search input:focus { border-color: var(--gold); }
.odo-modal__body {
  flex: 1;
  overflow-y: auto;
  padding: 0.75rem 1.5rem;
}

/* Items del historial */
.odo-historial-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.85rem 0;
  border-bottom: 1px solid var(--border);
  gap: 1rem;
}
.odo-historial-item:last-child { border-bottom: none; }
.odo-historial-info h3 {
  font-family: var(--font-display);
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--navy);
  margin-bottom: 0.2rem;
}
.odo-historial-info p {
  font-size: 0.78rem;
  color: var(--text-muted);
}
.odo-historial-actions {
  display: flex;
  gap: 0.4rem;
}
.odo-historial-vacio {
  text-align: center;
  color: var(--text-muted);
  padding: 2rem 0;
  font-size: 0.88rem;
}

/* ---------------------------------------------------------
   11. IMPRESIÓN
   --------------------------------------------------------- */
.print-only { display: none; }

@media print {
  .odo-navbar, .odo-main, .odo-modal-overlay { display: none !important; }
  .print-only { display: block !important; }

  #areaImpresion {
    font-family: 'Montserrat', sans-serif;
    padding: 2rem;
    max-width: 210mm;
    margin: 0 auto;
    color: #1B365D;
  }

  .print-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 2px solid #D4AF37;
    padding-bottom: 1rem;
    margin-bottom: 1.5rem;
  }
  .print-logo { font-size: 1.2rem; font-weight: 800; color: #1B365D; }
  .print-logo span { color: #D4AF37; }
  .print-fecha { font-size: 0.8rem; color: #64748B; text-align: right; }

  .print-paciente {
    background: #EFF4F9;
    border-radius: 8px;
    padding: 1rem 1.25rem;
    margin-bottom: 1.5rem;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.5rem;
  }
  .print-paciente h2 { font-size: 1.1rem; grid-column: 1/-1; margin-bottom: 0.25rem; }
  .print-paciente p { font-size: 0.82rem; color: #334155; }
  .print-paciente strong { color: #1B365D; }

  .print-tabla { width: 100%; border-collapse: collapse; margin-bottom: 1.5rem; }
  .print-tabla th {
    background: #1B365D;
    color: #D4AF37;
    padding: 0.5rem 0.75rem;
    font-size: 0.78rem;
    text-align: left;
    text-transform: uppercase;
  }
  .print-tabla td {
    padding: 0.55rem 0.75rem;
    border-bottom: 1px solid #DDE5EF;
    font-size: 0.85rem;
  }
  .print-tabla tr:last-child td { border-bottom: 2px solid #D4AF37; }

  .print-totales { margin-left: auto; width: 280px; }
  .print-total-row {
    display: flex;
    justify-content: space-between;
    padding: 0.35rem 0;
    font-size: 0.88rem;
    border-bottom: 1px solid #DDE5EF;
  }
  .print-total-row--saldo {
    font-size: 1rem;
    font-weight: 800;
    border-bottom: none;
    border-top: 2px solid #D4AF37;
    padding-top: 0.5rem;
    margin-top: 0.25rem;
    color: #1B365D;
  }

  .print-footer {
    margin-top: 2rem;
    border-top: 1px solid #DDE5EF;
    padding-top: 0.75rem;
    font-size: 0.72rem;
    color: #94A3B8;
    text-align: center;
  }
}

/* ---------------------------------------------------------
   12. LOGIN
   --------------------------------------------------------- */
.odo-login-overlay {
  position: fixed;
  inset: 0;
  background: linear-gradient(135deg, #122543 0%, #1B365D 50%, #254880 100%);
  z-index: 500;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}

.odo-login-card {
  background: var(--white);
  border-radius: 20px;
  padding: 2.5rem 2rem;
  width: 100%;
  max-width: 420px;
  box-shadow: 0 24px 60px rgba(0,0,0,0.3);
  display: flex;
  flex-direction: column;
  gap: 1.1rem;
}

.odo-login-brand {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--border);
}
.odo-login-brand img {
  border-radius: 10px;
  background: var(--surface-2);
  padding: 4px;
}
.odo-login-brand__name {
  font-family: var(--font-display);
  font-size: 0.88rem;
  font-weight: 700;
  color: var(--navy);
}
.odo-login-brand__sub {
  font-size: 0.72rem;
  color: var(--text-muted);
  margin-top: 0.15rem;
}

.odo-login-title {
  font-family: var(--font-display);
  font-size: 1.3rem;
  font-weight: 800;
  color: var(--navy);
}

.odo-login-error {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  background: #FEF2F2;
  color: var(--error);
  border: 1px solid #FECACA;
  border-radius: var(--radius-md);
  padding: 0.6rem 0.85rem;
  font-size: 0.82rem;
  font-weight: 500;
  animation: shake 0.3s ease;
}

@keyframes shake {
  0%,100% { transform: translateX(0); }
  25% { transform: translateX(-6px); }
  75% { transform: translateX(6px); }
}

.odo-login-pass-wrap {
  position: relative;
}
.odo-login-pass-wrap input {
  width: 100%;
  padding-right: 2.5rem;
}
.odo-login-eye {
  position: absolute;
  right: 0.6rem;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text-muted);
  padding: 0.2rem;
  display: flex;
  align-items: center;
  transition: color 0.2s;
}
.odo-login-eye:hover { color: var(--navy); }

.odo-login-footer {
  text-align: center;
  font-size: 0.72rem;
  color: var(--text-muted);
  line-height: 1.5;
  margin-top: 0.25rem;
}

/* Botón salir en navbar */
.odo-btn--logout {
  border-color: rgba(255,255,255,0.15) !important;
  color: rgba(255,255,255,0.6) !important;
  font-size: 0.78rem !important;
}
.odo-btn--logout:hover {
  color: #fff !important;
  border-color: rgba(255,255,255,0.35) !important;
}

/* ---------------------------------------------------------
   13. RESPONSIVE
   --------------------------------------------------------- */
@media (max-width: 1024px) {
  .odo-main {
    grid-template-columns: 1fr;
  }
  .odo-panel--right { order: -1; }
}

@media (max-width: 640px) {
  .odo-navbar {
    flex-wrap: wrap;
    gap: 0.5rem;
  }
  .odo-navbar__brand span { display: none; }
  .odo-form-grid { grid-template-columns: 1fr; }
  .odo-main { padding: 0.75rem; }
}
