/* ===== ECDentify — Estilos del Sistema Dental ===== */

:root {
  --primary:      #1A4B6D;
  --primary-dark: #0F2D45;
  --primary-light:#2D6FA0;
  --accent:       #48B0A8;
  --accent-light: #7DCDC7;
  --success:      #27AE60;
  --warning:      #F39C12;
  --danger:       #E74C3C;
  --info:         #2980B9;
  --bg:           #F4F7FB;
  --sidebar-bg:   #1A4B6D;
  --card-bg:      #FFFFFF;
  --text:         #2C3E50;
  --text-muted:   #7F8C8D;
  --border:       #DDE3EC;
  --shadow:       0 2px 12px rgba(26, 75, 109, 0.10);
  --radius:       10px;
  --radius-sm:    6px;
  --transition:   0.2s ease;
}

* { box-sizing: border-box; }

body {
  font-family: 'Nunito', 'Segoe UI', system-ui, sans-serif;
  background-color: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.6;
  margin: 0;
}

/* ===== LAYOUT PRINCIPAL ===== */
.dental-wrapper { display: flex; min-height: 100vh; }

/* ===== SIDEBAR ===== */
.dental-sidebar {
  width: 260px;
  background: var(--sidebar-bg);
  color: #fff;
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: 1000;
  transition: transform var(--transition);
  overflow-y: auto;
}

.sidebar-brand {
  padding: 24px 20px 16px;
  border-bottom: 1px solid rgba(255,255,255,0.1);
  display: flex;
  align-items: center;
  gap: 12px;
}
.sidebar-brand .brand-icon {
  width: 40px; height: 40px;
  /* background: var(--accent); */
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  font-size: 20px; color: white;
  flex-shrink: 0;
}
.sidebar-brand .brand-name { font-size: 18px; font-weight: 700; color: #fff; }
.sidebar-brand .brand-sub  { font-size: 11px; color: rgba(255,255,255,0.6); margin-top: 1px; }

.sidebar-clinic {
  padding: 12px 20px;
  background: rgba(0,0,0,0.15);
  font-size: 12px;
  color: rgba(255,255,255,0.8);
}
.sidebar-clinic strong { display: block; font-size: 13px; color: #fff; }

.sidebar-nav { padding: 12px 0; flex: 1; }
.sidebar-section { padding: 6px 20px 4px; font-size: 10px; text-transform: uppercase;
  letter-spacing: 0.8px; color: rgba(255,255,255,0.4); font-weight: 700; }

.sidebar-nav a {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 20px;
  color: rgba(255,255,255,0.80);
  text-decoration: none;
  font-size: 13.5px;
  border-radius: 0;
  transition: background var(--transition), color var(--transition);
  position: relative;
}
.sidebar-nav a:hover,
.sidebar-nav a.active {
  background: rgba(255,255,255,0.12);
  color: #fff;
}
.sidebar-nav a.active::before {
  content: '';
  position: absolute; left: 0; top: 0; bottom: 0;
  width: 3px;
  background: var(--accent);
  border-radius: 0 2px 2px 0;
}
.sidebar-nav a svg, .sidebar-nav a i { width: 18px; font-size: 16px; opacity: 0.85; }

.sidebar-footer {
  padding: 16px 20px;
  border-top: 1px solid rgba(255,255,255,0.1);
  font-size: 12px;
  color: rgba(255,255,255,0.55);
}
.sidebar-footer strong { color: #fff; display: block; margin-bottom: 2px; }

/* ===== MAIN CONTENT ===== */
.dental-main {
  margin-left: 260px;
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

/* ===== TOPBAR ===== */
.dental-topbar {
  background: #fff;
  border-bottom: 1px solid var(--border);
  padding: 0 28px;
  height: 60px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 500;
  box-shadow: 0 1px 4px rgba(0,0,0,0.06);
}
.topbar-title { font-size: 16px; font-weight: 700; color: var(--primary); }
.topbar-subtitle { font-size: 12px; color: var(--text-muted); }
.topbar-right { display: flex; align-items: center; gap: 16px; }

.user-badge {
  display: flex; align-items: center; gap: 8px;
  background: var(--bg);
  padding: 6px 14px;
  border-radius: 20px;
  font-size: 13px;
  color: var(--text);
}
.user-badge .avatar {
  width: 28px; height: 28px;
  background: var(--accent);
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 700; color: white;
}

/* ===== PAGE CONTENT ===== */
.dental-content { padding: 28px; flex: 1; }
.page-header { margin-bottom: 24px; }
.page-header h1 { font-size: 22px; font-weight: 700; color: var(--primary); margin: 0 0 4px; }
.page-header p  { color: var(--text-muted); margin: 0; font-size: 13px; }

/* ===== CARDS ===== */
.dental-card {
  background: var(--card-bg);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
  overflow: hidden;
}
.dental-card .card-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
  background: #FAFBFC;
}
.dental-card .card-header h5 {
  margin: 0;
  font-size: 14px;
  font-weight: 700;
  color: var(--primary);
  display: flex; align-items: center; gap: 8px;
}
.dental-card .card-body { padding: 20px; }

/* ===== STAT CARDS ===== */
.stat-card {
  background: var(--card-bg);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
  padding: 20px 24px;
  display: flex;
  align-items: center;
  gap: 16px;
}
.stat-card .stat-icon {
  width: 52px; height: 52px;
  border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
  font-size: 22px;
  flex-shrink: 0;
}
.stat-card .stat-value { font-size: 26px; font-weight: 800; color: var(--primary); line-height: 1.1; }
.stat-card .stat-label { font-size: 12px; color: var(--text-muted); margin-top: 2px; }

.stat-icon.blue    { background: #EFF6FF; color: var(--primary); }
.stat-icon.teal    { background: #F0FDFA; color: var(--accent); }
.stat-icon.green   { background: #F0FDF4; color: var(--success); }
.stat-icon.orange  { background: #FFF7ED; color: var(--warning); }
.stat-icon.red     { background: #FEF2F2; color: var(--danger); }

/* ===== TABLES ===== */
.dental-table { width: 100%; border-collapse: collapse; }
.dental-table thead th {
  background: #F8FAFC;
  padding: 10px 14px;
  text-align: left;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  font-weight: 700;
  color: var(--text-muted);
  border-bottom: 2px solid var(--border);
}
.dental-table tbody td {
  padding: 12px 14px;
  border-bottom: 1px solid #F1F5F9;
  font-size: 13.5px;
  vertical-align: middle;
}
.dental-table tbody tr:last-child td { border-bottom: none; }
.dental-table tbody tr:hover td { background: #F8FAFC; }

/* ===== FORMS ===== */
.dental-form .form-label {
  font-weight: 600;
  font-size: 12.5px;
  color: var(--primary);
  margin-bottom: 5px;
}
.dental-form .form-control,
.dental-form .form-select {
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 8px 12px;
  font-size: 13.5px;
  color: var(--text);
  transition: border-color var(--transition), box-shadow var(--transition);
}
.dental-form .form-control:focus,
.dental-form .form-select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(72, 176, 168, 0.18);
  outline: none;
}
.dental-form .form-section {
  background: #FAFBFC;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 20px;
  margin-bottom: 20px;
}
.dental-form .form-section-title {
  font-size: 13px;
  font-weight: 700;
  color: var(--primary);
  border-bottom: 2px solid var(--accent);
  padding-bottom: 8px;
  margin-bottom: 14px;
  display: flex; align-items: center; gap: 6px;
}

/* ===== BUTTONS ===== */
.btn-dental-primary {
  background: var(--primary);
  color: white;
  border: none;
  padding: 8px 18px;
  border-radius: var(--radius-sm);
  font-size: 13.5px;
  font-weight: 600;
  cursor: pointer;
  transition: background var(--transition);
  display: inline-flex; align-items: center; gap: 6px;
  text-decoration: none;
}
.btn-dental-primary:hover { background: var(--primary-dark); color: white; }

.btn-dental-accent {
  background: var(--accent);
  color: white;
  border: none;
  padding: 8px 18px;
  border-radius: var(--radius-sm);
  font-size: 13.5px;
  font-weight: 600;
  cursor: pointer;
  transition: background var(--transition);
  display: inline-flex; align-items: center; gap: 6px;
  text-decoration: none;
}
.btn-dental-accent:hover { background: #3A9C94; color: white; }

.btn-dental-outline {
  background: var(--bg);
  color: var(--primary);
  border: 1.5px solid var(--border);
  padding: 7px 17px;
  border-radius: var(--radius-sm);
  font-size: 13.5px;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition);
  display: inline-flex; align-items: center; gap: 6px;
  text-decoration: none;
  
}
.btn-dental-outline:hover { background: var(--bg); border-color: var(--primary); }

/* ===== BADGES ===== */
.badge-dental {
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 700;
  display: inline-block;
}
.badge-caries      { background: #FEE2E2; color: #B91C1C; }
.badge-sano        { background: #DCFCE7; color: #15803D; }
.badge-ausente     { background: #F3F4F6; color: #6B7280; }
.badge-endodoncia  { background: #FEF3C7; color: #92400E; }
.badge-corona      { background: #EDE9FE; color: #6D28D9; }
.badge-obturacion  { background: #DBEAFE; color: #1D4ED8; }
.badge-general     { background: #DBEAFE; color: #1D4ED8; }
.badge-pediatrico  { background: #FEF3C7; color: #92400E; }
.badge-quirurgico  { background: #FEE2E2; color: #B91C1C; }

/* ===== ALERTS ===== */
.alert-dental {
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  font-size: 13.5px;
  margin-bottom: 16px;
  display: flex; align-items: flex-start; gap: 10px;
}
.alert-dental-success { background: #F0FDF4; border: 1px solid #86EFAC; color: #166534; }
.alert-dental-error   { background: #FEF2F2; border: 1px solid #FCA5A5; color: #991B1B; }
.alert-dental-info    { background: #EFF6FF; border: 1px solid #93C5FD; color: #1D4ED8; }
.alert-dental-warning { background: #FFFBEB; border: 1px solid #FCD34D; color: #92400E; }

/* ===== PATIENT CARD ===== */
.patient-card {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  background: white;
  cursor: pointer;
  transition: all var(--transition);
  text-decoration: none;
  display: block;
  color: var(--text);
}
.patient-card:hover {
  border-color: var(--accent);
  box-shadow: 0 4px 16px rgba(72, 176, 168, 0.15);
  transform: translateY(-1px);
  color: var(--text);
  text-decoration: none;
}
.patient-card .patient-avatar {
  width: 44px; height: 44px;
  background: linear-gradient(135deg, var(--primary), var(--accent));
  border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
  font-size: 16px; font-weight: 700; color: white;
  flex-shrink: 0;
}
.patient-name  { font-weight: 700; font-size: 14px; color: var(--primary); }
.patient-info  { font-size: 12px; color: var(--text-muted); }

/* ===== ODONTOGRAM ===== */
.odontogram-grid {
  display: grid;
  grid-template-columns: repeat(16, 1fr);
  gap: 3px;
  margin: 12px 0;
}
.tooth-cell {
  aspect-ratio: 1;
  border-radius: 6px;
  border: 2px solid var(--border);
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  font-size: 10px; font-weight: 700;
  transition: all var(--transition);
  position: relative;
  background: white;
  color: var(--text-muted);
}
.tooth-cell:hover { border-color: var(--accent); transform: scale(1.05); z-index: 2; }
.tooth-cell[data-condition="Sano"]          { border-color: #86EFAC; background: #F0FDF4; color: #166534; }
.tooth-cell[data-condition="Caries"]        { border-color: #FCA5A5; background: #FEF2F2; color: #991B1B; }
.tooth-cell[data-condition="Ausente"]       { border-color: #D1D5DB; background: #F3F4F6; color: #6B7280; }
.tooth-cell[data-condition="Obturación"]    { border-color: #93C5FD; background: #DBEAFE; color: #1D4ED8; }
.tooth-cell[data-condition="Endodoncia"]    { border-color: #FCD34D; background: #FFFBEB; color: #92400E; }
.tooth-cell[data-condition="Corona"]        { border-color: #C4B5FD; background: #EDE9FE; color: #6D28D9; }
.tooth-cell[data-condition="Extracción indicada"] { border-color: #FCA5A5; background: #FFF1F2; color: #C0152E; }
.tooth-cell.tooth-separator { border: none; background: none; cursor: default; }

.tooth-label {
  font-size: 8px; color: var(--text-muted);
  text-align: center; margin-top: 2px;
}

/* ===== LOGIN ===== */
.login-page {
  min-height: 100vh;
  display: flex;
  background: linear-gradient(135deg, var(--primary-dark) 0%, var(--primary) 50%, var(--accent) 100%);
}
.login-left {
  flex: 1;
  display: flex; align-items: center; justify-content: center;
  padding: 40px;
  color: white;
}
.login-right {
  width: 440px;
  background: white;
  display: flex; align-items: center; justify-content: center;
  padding: 48px 40px;
}
.login-logo { font-size: 48px; margin-bottom: 16px; }
.login-brand-name { font-size: 40px; font-weight: 800; letter-spacing: -1px; }
.login-tagline { font-size: 16px; opacity: 0.85; margin-top: 8px; }
.login-features { margin-top: 40px; display: flex; flex-direction: column; gap: 14px; }
.login-feature { display: flex; align-items: center; gap: 12px; font-size: 14px; opacity: 0.9; }
.login-feature-icon {
  width: 36px; height: 36px;
  background: rgba(255,255,255,0.15);
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  font-size: 16px; flex-shrink: 0;
}
.login-form-title { font-size: 24px; font-weight: 800; color: var(--primary); margin-bottom: 6px; }
.login-form-sub   { font-size: 13px; color: var(--text-muted); margin-bottom: 28px; }

/* ===== CONSENT SIGNATURE ===== */
#signatureCanvas {
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  cursor: crosshair;
  background: #FAFBFC;
  touch-action: none;
}
#signatureCanvas:hover { border-color: var(--accent); }

/* ===== PROGRESS TABS ===== */
.patient-tabs .nav-link {
  color: var(--text-muted);
  font-weight: 600;
  font-size: 13px;
  border: none;
  padding: 10px 18px;
  border-bottom: 2px solid transparent;
}
.patient-tabs .nav-link.active {
  color: var(--primary);
  border-bottom-color: var(--accent);
  background: none;
}
.patient-tabs .nav-link:hover { color: var(--primary); background: var(--bg); }

/* ===== AGENDA — VISTA MES ===== */
/* .dental-card clips overflow by default (for rounded corners); the day popover needs to
   escape that clipping to not get cut off against the card/row boundary. */
.dental-card.agenda-month-card {
  overflow: visible;
}
.agenda-month-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 8px;
}
.agenda-month-weekday {
  text-align: center;
  font-size: 12px;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  padding-bottom: 4px;
}
.agenda-month-day {
  position: relative;
}
.agenda-month-day-card {
  display: block;
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px;
  min-height: 72px;
  text-align: left;
  text-decoration: none;
  color: var(--text);
  transition: box-shadow var(--transition), border-color var(--transition);
}
.agenda-month-day-card:hover {
  box-shadow: var(--shadow);
  border-color: var(--accent-light);
}
.agenda-month-day.has-appointments .agenda-month-day-card {
  border-color: var(--primary-light);
}
.agenda-month-day-number {
  font-weight: 700;
  font-size: 15px;
}
.agenda-month-day-count {
  display: inline-block;
  margin-top: 4px;
  background: var(--primary);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  border-radius: 999px;
  padding: 2px 8px;
}

/* Globo con el detalle de citas al pasar el mouse */
.agenda-month-day-popover {
  display: none;
  position: absolute;
  z-index: 20;
  top: 100%;
  left: 50%;
  transform: translateX(-50%);
  margin-top: 6px;
  min-width: 220px;
  max-width: 280px;
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  box-shadow: 0 6px 24px rgba(26, 75, 109, 0.18);
  padding: 10px 12px;
}
.agenda-month-day.has-appointments:hover .agenda-month-day-popover { display: block; }
.agenda-month-day-popover::before {
  content: "";
  position: absolute;
  bottom: 100%;
  left: 50%;
  transform: translateX(-50%);
  border: 7px solid transparent;
  border-bottom-color: var(--border);
}
.agenda-month-day-popover-title {
  font-size: 12px;
  font-weight: 700;
  color: var(--primary);
  margin-bottom: 6px;
}
.agenda-month-day-popover-item {
  font-size: 12px;
  padding: 4px 0;
  border-top: 1px solid var(--border);
}
.agenda-month-day-popover-item:first-of-type { border-top: none; }
.agenda-month-day-popover-time { font-weight: 700; color: var(--primary); }

/* ===== RESPONSIVE ===== */
@media (max-width: 1024px) {
  .dental-sidebar { transform: translateX(-260px); }
  .dental-sidebar.open { transform: translateX(0); }
  .dental-main { margin-left: 0; }
}
@media (max-width: 640px) {
  .login-left { display: none; }
  .login-right { width: 100%; }
  .dental-content { padding: 16px; }
}
