/* ============================================================
   DENTION v3 — Design System
   Paleta corporativa: azul profundo + teal accent
   ============================================================ */

/* ── Variables ─────────────────────────────────────────────── */
:root {
  /* Colores primarios */
  --dt-primary:        #1A3C5E;   /* azul marino profundo */
  --dt-primary-hover:  #15314E;
  --dt-primary-light:  #EBF2FB;

  /* Accent */
  --dt-teal:           #17A89E;   /* teal médico */
  --dt-teal-hover:     #148F86;
  --dt-teal-light:     #E6F7F6;

  /* Neutrales */
  --dt-bg:             #F5F7FA;   /* fondo app */
  --dt-surface:        #FFFFFF;   /* tarjetas, sidebar */
  --dt-border:         #E2E8F0;
  --dt-text:           #1E293B;
  --dt-text-muted:     #64748B;
  --dt-text-light:     #94A3B8;

  /* Estado */
  --dt-success:        #16A34A;
  --dt-warning:        #D97706;
  --dt-danger:         #DC2626;
  --dt-info:           #0284C7;

  /* Layout */
  --dt-sidebar-width:  252px;
  --dt-topbar-height:  58px;
  --dt-radius:         14px;
  --dt-radius-sm:      8px;
  --dt-radius-xs:      6px;
  --dt-shadow-sm:      0 1px 4px rgba(0,0,0,.07), 0 2px 8px rgba(0,0,0,.05);
  --dt-shadow:         0 4px 16px rgba(0,0,0,.10), 0 1px 4px rgba(0,0,0,.06);

  /* Tipografía */
  --dt-font:           'Inter', 'Segoe UI', system-ui, sans-serif;
}

/* ── Reset global ───────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }

body {
  font-family: var(--dt-font);
  background-color: var(--dt-bg);
  color: var(--dt-text);
  font-size: 14px;
  line-height: 1.5;
  margin: 0;
}

/* ── Sobrescribir Bootstrap con paleta DENTION ──────────────── */

/* Botones — base */
.btn {
  border-radius: var(--dt-radius-sm);
  font-weight: 500;
  font-size: .82rem;
  letter-spacing: .01em;
  transition: all .15s;
}
.btn-sm { border-radius: var(--dt-radius-xs); font-size: .78rem; }

.btn-primary {
  background: linear-gradient(135deg, #1a4fa0, #2563eb);
  border-color: #2563eb;
  color: #fff;
  box-shadow: 0 2px 6px rgba(37,99,235,.25);
}
.btn-primary:hover, .btn-primary:focus {
  background: linear-gradient(135deg, #1a4fa0, #1d4ed8);
  border-color: #1d4ed8;
  box-shadow: 0 4px 10px rgba(37,99,235,.35);
  color: #fff;
}

.btn-success {
  background: linear-gradient(135deg, #065f46, #10b981);
  border-color: #10b981;
  color: #fff;
  box-shadow: 0 2px 6px rgba(16,185,129,.25);
}
.btn-success:hover {
  background: linear-gradient(135deg, #065f46, #059669);
  border-color: #059669;
  color: #fff;
}

.btn-danger {
  background: linear-gradient(135deg, #7f1d1d, #ef4444);
  border-color: #ef4444;
  color: #fff;
  box-shadow: 0 2px 6px rgba(239,68,68,.25);
}
.btn-danger:hover {
  background: linear-gradient(135deg, #7f1d1d, #dc2626);
  border-color: #dc2626;
  color: #fff;
}

.btn-warning {
  background: linear-gradient(135deg, #92400e, #f59e0b);
  border-color: #f59e0b;
  color: #fff;
  box-shadow: 0 2px 6px rgba(245,158,11,.25);
}
.btn-warning:hover {
  background: linear-gradient(135deg, #78350f, #d97706);
  border-color: #d97706;
  color: #fff;
}

.btn-secondary {
  background: #f1f5f9;
  border-color: #e2e8f0;
  color: #475569;
}
.btn-secondary:hover {
  background: #e2e8f0;
  border-color: #cbd5e1;
  color: #334155;
}

.btn-outline-primary {
  border-color: #2563eb;
  color: #2563eb;
  border-radius: var(--dt-radius-sm);
}
.btn-outline-primary:hover {
  background: linear-gradient(135deg, #1a4fa0, #2563eb);
  border-color: #2563eb;
  color: #fff;
  box-shadow: 0 2px 6px rgba(37,99,235,.25);
}

.btn-outline-secondary {
  border-color: #cbd5e1;
  color: #64748b;
  border-radius: var(--dt-radius-sm);
}
.btn-outline-secondary:hover {
  background: #f1f5f9;
  border-color: #94a3b8;
  color: #334155;
}

.btn-outline-danger {
  border-color: #ef4444;
  color: #ef4444;
  border-radius: var(--dt-radius-sm);
}
.btn-outline-danger:hover {
  background: linear-gradient(135deg, #7f1d1d, #ef4444);
  border-color: #ef4444;
  color: #fff;
}

.btn-outline-success {
  border-color: #10b981;
  color: #10b981;
  border-radius: var(--dt-radius-sm);
}
.btn-outline-success:hover {
  background: linear-gradient(135deg, #065f46, #10b981);
  border-color: #10b981;
  color: #fff;
}

.btn-teal {
  background: linear-gradient(135deg, #148f86, #17a89e);
  border-color: #17a89e;
  color: #fff;
  box-shadow: 0 2px 6px rgba(23,168,158,.25);
}
.btn-teal:hover {
  background: linear-gradient(135deg, #0f7a72, #148f86);
  border-color: #148f86;
  color: #fff;
}

a { color: #2563eb; }
a:hover { color: #1d4ed8; }

/* ── Layout — Auth (centrado) ──────────────────────────────── */
.auth-page {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  background: linear-gradient(135deg, var(--dt-primary) 0%, #1D5280 60%, var(--dt-teal) 100%);
  padding: 24px 16px 0;
}
.auth-page-body {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  padding: 24px 0;
}
.auth-card {
  background: var(--dt-surface);
  border-radius: var(--dt-radius);
  box-shadow: var(--dt-shadow);
  padding: 40px 36px;
  width: 100%;
  max-width: 420px;
}
.auth-logo {
  display: block;
  text-align: center;
  margin-bottom: 24px;
  padding-bottom: 20px;
  border-bottom: 1px solid var(--dt-border);
}

.auth-logo-frame {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 10px 14px;
  border: 1px solid var(--dt-border);
  border-radius: 12px;
  background: #fff;
}

.auth-logo-img {
  display: block;
  height: 110px;
  max-width: 340px;
  width: auto;
  object-fit: contain;
}
.auth-card--wide { max-width: 500px; }
.auth-divider {
  border: none;
  border-top: 1px solid var(--dt-border);
  margin: 20px 0;
}

/* ── Layout — App Shell ─────────────────────────────────────── */
.app-shell {
  display: flex;
  min-height: 100vh;
}

/* Sidebar */
.app-sidebar {
  width: var(--dt-sidebar-width);
  min-height: 100vh;
  background: #0d1629;
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  z-index: 100;
  overflow-y: auto;
  padding: 0 0 12px;
}
.sidebar-brand {
  padding: 16px 14px 14px;
  border-bottom: 1px solid rgba(255,255,255,.07);
  text-decoration: none;
  display: block;
}
.brand-logo-row {
  display: flex;
  align-items: center;
  gap: 10px;
}
.brand-logo-img {
  width: 40px;
  height: 40px;
  object-fit: contain;
  border-radius: 10px;
  background: #fff;
  padding: 4px;
  flex-shrink: 0;
  box-shadow: 0 2px 8px rgba(0,0,0,.3);
}
.brand-name {
  display: block;
  font-size: 1.15rem;
  font-weight: 800;
  color: #fff;
  letter-spacing: .5px;
  line-height: 1.1;
}
.brand-reg {
  font-size: .55rem;
  vertical-align: super;
  font-weight: 400;
  color: rgba(255,255,255,.5);
  letter-spacing: 0;
}
.brand-sub {
  display: block;
  font-size: .6rem;
  color: rgba(255,255,255,.38);
  letter-spacing: .7px;
  text-transform: uppercase;
  margin-top: 2px;
}
.sidebar-clinic-badge {
  margin: 10px 10px 0;
  background: rgba(255,255,255,.06);
  border: 1px solid rgba(255,255,255,.08);
  border-radius: 12px;
  padding: 10px 12px;
  font-size: .75rem;
  color: rgba(255,255,255,.6);
}
.sidebar-center-badge {
  margin: 6px 10px 6px;
  padding: 8px 12px;
  border-radius: 12px;
  background: rgba(255,255,255,.04);
  border: 1px solid rgba(255,255,255,.08);
}
.sidebar-center-toggle {
  display: block;
  color: rgba(255,255,255,.85);
  text-decoration: none;
  font-size: .85rem;
}
.sidebar-center-toggle:hover { color: #fff; }
.sidebar-clinic-badge strong {
  display: block;
  color: #fff;
  font-size: .82rem;
  margin-bottom: 4px;
}
.plan-badge {
  display: inline-block;
  background: var(--dt-teal);
  color: #fff;
  font-size: .6rem;
  font-weight: 700;
  letter-spacing: .5px;
  padding: 2px 7px;
  border-radius: 20px;
  text-transform: uppercase;
}

/* Nav groups */
.sidebar-nav {
  flex: 1;
  padding: 10px 10px 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.sidebar-group-label {
  padding: 10px 6px 4px;
  font-size: .6rem;
  font-weight: 700;
  color: rgba(255,255,255,.3);
  text-transform: uppercase;
  letter-spacing: 1.2px;
}
.sidebar-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  color: rgba(255,255,255,.82);
  text-decoration: none;
  font-size: .92rem;
  font-weight: 500;
  border-radius: 12px;
  border: 1px solid rgba(255,255,255,.05);
  background: rgba(255,255,255,.03);
  transition: background .15s, border-color .15s, color .15s;
  position: relative;
}
.sidebar-item::after {
  content: '›';
  position: absolute;
  right: 14px;
  font-size: 1.1rem;
  color: rgba(255,255,255,.25);
  font-weight: 400;
  transition: color .15s;
}
.sidebar-item:hover {
  background: rgba(255,255,255,.08);
  border-color: rgba(255,255,255,.12);
  color: #fff;
  text-decoration: none;
}
.sidebar-item:hover::after { color: rgba(255,255,255,.6); }
.sidebar-item.active {
  background: rgba(26,110,245,.18);
  border-color: rgba(26,110,245,.35);
  color: #fff;
}
.sidebar-item.active::after { color: rgba(26,110,245,.8); }
.nav-icon {
  width: 34px;
  height: 34px;
  border-radius: 9px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
  flex-shrink: 0;
  background: rgba(255,255,255,.08);
}
/* Colores de icono por módulo */
.sidebar-item[href*="/patients"] .nav-icon,
.sidebar-item[href*="patients"] .nav-icon  { background: linear-gradient(135deg,#5b2d8e,#7c3fbd); }
.sidebar-item[href*="/agenda"] .nav-icon,
.sidebar-item[href*="agenda"] .nav-icon    { background: linear-gradient(135deg,#1a4fa0,#2563eb); }
.sidebar-item[href*="sala-espera"] .nav-icon { background: linear-gradient(135deg,#92400e,#d97706); }
.sidebar-item[href*="billing"] .nav-icon   { background: linear-gradient(135deg,#065f46,#10b981); }
.sidebar-item[href*="recalls"] .nav-icon   { background: linear-gradient(135deg,#164e63,#0891b2); }
.sidebar-item[href*="config"] .nav-icon    { background: linear-gradient(135deg,#1e3a5f,#3b82f6); }
.sidebar-item[href*="clinics"] .nav-icon   { background: linear-gradient(135deg,#1e3a5f,#2563eb); }
.sidebar-item[href*="plans"] .nav-icon     { background: linear-gradient(135deg,#7c1d6f,#ec4899); }
.sidebar-item[href*="superadmin"] .nav-icon,
.sidebar-item[href*="security"] .nav-icon  { background: linear-gradient(135deg,#7f1d1d,#ef4444); }

/* Sidebar footer (usuario) */
.sidebar-footer {
  border-top: 1px solid rgba(255,255,255,.1);
  padding: 12px;
}
.sidebar-user {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px;
  border-radius: var(--dt-radius-sm);
  color: rgba(255,255,255,.8);
  text-decoration: none;
  font-size: .8rem;
}
.sidebar-user:hover {
  background: rgba(255,255,255,.08);
  color: #fff;
  text-decoration: none;
}
.sidebar-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--dt-teal);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: .75rem;
  font-weight: 700;
  color: #fff;
  flex-shrink: 0;
}
.sidebar-user-info {
  min-width: 0;
}
.sidebar-user-name {
  display: block;
  font-weight: 600;
  color: #fff;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.sidebar-user-role {
  display: block;
  font-size: .7rem;
  color: rgba(255,255,255,.5);
}

/* Main content */
.app-main {
  margin-left: var(--dt-sidebar-width);
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}
.app-topbar {
  height: var(--dt-topbar-height);
  background: #fff;
  border-bottom: 1px solid #edf0f7;
  display: flex;
  align-items: center;
  padding: 0 24px;
  position: sticky;
  top: 0;
  z-index: 50;
  gap: 12px;
  box-shadow: 0 1px 0 #edf0f7;
}
.app-topbar .page-title {
  font-size: .95rem;
  font-weight: 700;
  color: var(--dt-text);
  margin: 0;
  letter-spacing: -.01em;
}
.app-topbar .topbar-right {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 8px;
}
.app-content {
  flex: 1;
  padding: 24px 28px;
  background: #f0f2f7;
}

/* ── Componentes de contenido ──────────────────────────────── */
.dt-card, .card, .card-soft {
  background: #fff;
  border: 1px solid #e8ecf4;
  border-radius: var(--dt-radius) !important;
  box-shadow: 0 1px 4px rgba(0,0,0,.06), 0 2px 10px rgba(0,0,0,.04);
}
.dt-card-header, .card-header {
  padding: 14px 20px;
  border-bottom: 1px solid #f0f2f7;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  background: transparent;
  border-radius: var(--dt-radius) var(--dt-radius) 0 0 !important;
}
.dt-card-header h5, .card-header h5 {
  margin: 0;
  font-size: .88rem;
  font-weight: 700;
  letter-spacing: -.01em;
}
.dt-card-body, .card-body { padding: 20px; }

/* Tabla polished */
.table {
  font-size: .82rem;
  border-collapse: separate;
  border-spacing: 0;
}
.table thead th {
  background: #f8fafc;
  color: #64748b;
  font-size: .7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .06em;
  border-bottom: 1px solid #e8ecf4;
  padding: 10px 14px;
  white-space: nowrap;
}
.table tbody td {
  padding: 10px 14px;
  border-bottom: 1px solid #f1f4f9;
  vertical-align: middle;
  color: #334155;
}
.table tbody tr:last-child td { border-bottom: none; }
.table tbody tr:hover td { background: #f8faff; }
.table-responsive { border-radius: var(--dt-radius); }

/* Stat cards */
.stat-card {
  background: #fff;
  border: 1px solid #e8ecf4;
  border-radius: var(--dt-radius);
  padding: 20px;
  display: flex;
  align-items: center;
  gap: 16px;
  box-shadow: 0 1px 4px rgba(0,0,0,.06);
  transition: box-shadow .15s;
}
.stat-card:hover {
  box-shadow: 0 4px 16px rgba(0,0,0,.10);
}
.stat-icon {
  width: 46px;
  height: 46px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.25rem;
  flex-shrink: 0;
}
.stat-icon.teal   { background: linear-gradient(135deg,#148f86,#17a89e); color:#fff; }
.stat-icon.blue   { background: linear-gradient(135deg,#1a4fa0,#2563eb); color:#fff; }
.stat-icon.green  { background: linear-gradient(135deg,#065f46,#10b981); color:#fff; }
.stat-icon.orange { background: linear-gradient(135deg,#92400e,#f59e0b); color:#fff; }

.stat-value {
  font-size: 1.5rem;
  font-weight: 700;
  line-height: 1.2;
  color: #0f172a;
  letter-spacing: -.02em;
}
.stat-label {
  font-size: .73rem;
  color: #94a3b8;
  margin-top: 3px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: .04em;
}

/* Flash messages */
.alert {
  border-radius: var(--dt-radius-sm);
  border: none;
  border-left: 4px solid;
  font-size: .85rem;
  padding: 12px 16px;
}
.alert-danger  { background: #fef2f2; color: #b91c1c; border-left-color: #ef4444; }
.alert-success { background: #f0fdf4; color: #15803d; border-left-color: #22c55e; }
.alert-warning { background: #fffbeb; color: #b45309; border-left-color: #f59e0b; }
.alert-info    { background: #eff6ff; color: #1d4ed8; border-left-color: #3b82f6; }

/* Form controls */
.form-control, .form-select {
  border-color: #dde3ee;
  border-radius: var(--dt-radius-sm);
  font-size: .85rem;
  color: #1e293b;
  background: #fff;
  transition: border-color .15s, box-shadow .15s;
}
.form-control:focus, .form-select:focus {
  border-color: #2563eb;
  box-shadow: 0 0 0 3px rgba(37,99,235,.12);
  outline: none;
}
.form-control::placeholder { color: #a0aec0; }
.form-label {
  font-weight: 600;
  font-size: .78rem;
  color: #475569;
  text-transform: uppercase;
  letter-spacing: .04em;
  margin-bottom: .35rem;
}
.form-text {
  font-size: .76rem;
  color: #94a3b8;
}

/* Input groups */
.input-group .form-control:focus { z-index: 3; }

/* Badges */
.badge {
  border-radius: var(--dt-radius-xs);
  font-weight: 600;
  font-size: .7rem;
  letter-spacing: .02em;
  padding: .3em .65em;
}

/* Badge de plan */
.plan-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: var(--dt-teal-light);
  color: var(--dt-teal);
  font-size: .7rem;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 99px;
  text-transform: uppercase;
  letter-spacing: .5px;
}

/* btn-xs — tamaño extra small para botones de duración */
.btn-xs {
  font-size: .72rem;
  padding: .15rem .5rem;
  line-height: 1.4;
  border-radius: var(--dt-radius-xs);
}

/* Modales */
.modal-content {
  border-radius: var(--dt-radius) !important;
  border: none;
  box-shadow: 0 20px 60px rgba(0,0,0,.18);
}
.modal-header {
  border-bottom: 1px solid #f0f2f7;
  padding: 16px 20px;
  border-radius: var(--dt-radius) var(--dt-radius) 0 0 !important;
}
.modal-footer {
  border-top: 1px solid #f0f2f7;
  padding: 12px 20px;
  border-radius: 0 0 var(--dt-radius) var(--dt-radius) !important;
}
.modal-title { font-weight: 700; font-size: .95rem; }

/* Dropdowns */
.dropdown-menu {
  border-radius: var(--dt-radius-sm) !important;
  border-color: #e8ecf4;
  box-shadow: 0 8px 24px rgba(0,0,0,.12);
  font-size: .83rem;
  padding: 6px;
}
.dropdown-item {
  border-radius: var(--dt-radius-xs);
  padding: 7px 12px;
  color: #334155;
}
.dropdown-item:hover { background: #f0f4ff; color: #1d4ed8; }
.dropdown-divider { margin: 4px 0; border-color: #f0f2f7; }

/* Variante dark (sidebar, menú usuario) */
.dropdown-menu-dark {
  background-color: #1e2a3a !important;
  border-color: rgba(255,255,255,.1) !important;
}
.dropdown-menu-dark .dropdown-item {
  color: rgba(255,255,255,.85) !important;
}
.dropdown-menu-dark .dropdown-item:hover,
.dropdown-menu-dark .dropdown-item:focus {
  background: rgba(255,255,255,.1) !important;
  color: #fff !important;
}
.dropdown-menu-dark .dropdown-item.active,
.dropdown-menu-dark .dropdown-item:active {
  background: rgba(37,99,235,.5) !important;
  color: #fff !important;
}
.dropdown-menu-dark .dropdown-divider {
  border-color: rgba(255,255,255,.12) !important;
}
.dropdown-menu-dark .text-danger {
  color: #f87171 !important;
}
.dropdown-menu-dark .text-danger:hover {
  color: #fca5a5 !important;
}

/* Paginación */
.page-link {
  border-radius: var(--dt-radius-xs) !important;
  font-size: .8rem;
  color: #2563eb;
  border-color: #e2e8f0;
}
.page-item.active .page-link {
  background: linear-gradient(135deg,#1a4fa0,#2563eb);
  border-color: #2563eb;
}

/* ── Footer legal ─────────────────────────────────────────────────────────── */
.dt-footer {
  background: #f8fafc;
  border-top: 1px solid #e8ecf4;
  padding: 14px 28px;
  flex-shrink: 0;
}
.dt-footer-inner {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px 12px;
  font-size: .72rem;
  color: #94a3b8;
}
.dt-footer-brand {
  font-weight: 700;
  color: #64748b;
  white-space: nowrap;
}
.dt-footer-brand sup { font-size: .55em; vertical-align: super; }
.dt-footer-sep { color: #cbd5e1; }
.dt-footer-legal-note { color: #94a3b8; }
.dt-footer-links {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
}
.dt-footer-links a {
  color: #94a3b8;
  text-decoration: none;
  font-size: .72rem;
  transition: color .15s;
}
.dt-footer-links a:hover { color: #2563eb; }

/* Footer en layout auth (centrado) */
.auth-page .dt-footer {
  background: rgba(255,255,255,.07);
  border-top: 1px solid rgba(255,255,255,.12);
  padding: 12px 28px;
  width: 100%;
  flex-shrink: 0;
}
.auth-page .dt-footer-inner {
  justify-content: center;
  flex-wrap: wrap;
  gap: 4px 16px;
}
.auth-page .dt-footer-brand { color: rgba(255,255,255,.7); }
.auth-page .dt-footer-sep { color: rgba(255,255,255,.3); }
.auth-page .dt-footer-legal-note { color: rgba(255,255,255,.45); }
.auth-page .dt-footer-links { margin-left: 0; justify-content: center; }
.auth-page .dt-footer-links a { color: rgba(255,255,255,.55); }
.auth-page .dt-footer-links a:hover { color: #fff; }
