/* ==========================================================================
   DENTIK — Design System
   Construido a partir del Manual de Identidad de Marca y UI/UX v1.0
   ========================================================================== */

:root {
  /* Paleta corporativa */
  --dentik-primary-dark: #0A2540;
  --dentik-primary: #0080FF;
  --dentik-accent-orange: #FF7A00;
  --dentik-mint: #00D4B2;
  --dentik-bg-light: #F4F6F8;
  --dentik-text-dark: #1E293B;
  --dentik-border: #E2E8F0;

  /* Derivados de apoyo */
  --dentik-primary-soft: rgba(0, 128, 255, 0.10);
  --dentik-mint-soft: rgba(0, 212, 178, 0.12);
  --dentik-orange-soft: rgba(255, 122, 0, 0.12);
  --dentik-danger: #E11D48;
  --dentik-danger-soft: rgba(225, 29, 72, 0.10);
  --dentik-text-muted: #64748B;
  --dentik-white: #FFFFFF;

  /* Forma y elevación */
  --radius: 8px;
  --radius-sm: 6px;
  --shadow-sm: 0 1px 2px rgba(10, 37, 64, 0.06);
  --shadow-md: 0 4px 12px rgba(10, 37, 64, 0.08);
  --shadow-lg: 0 12px 32px rgba(10, 37, 64, 0.12);

  --sidebar-w: 248px;
  --topbar-h: 64px;
}

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

html, body {
  margin: 0;
  padding: 0;
}

body {
  font-family: 'Inter', 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  font-size: 14px;
  line-height: 1.5;
  color: var(--dentik-text-dark);
  background: var(--dentik-bg-light);
  -webkit-font-smoothing: antialiased;
}

/* ---------- Escala tipográfica del manual ---------- */
h1, .h1 { font-size: 28px; line-height: 1.2;  font-weight: 700; margin: 0 0 4px; color: var(--dentik-primary-dark); letter-spacing: -0.02em; }
h2, .h2 { font-size: 20px; line-height: 1.3;  font-weight: 600; margin: 0 0 4px; color: var(--dentik-primary-dark); }
h3, .h3 { font-size: 16px; line-height: 1.4;  font-weight: 500; margin: 0 0 4px; color: var(--dentik-primary-dark); }
p       { margin: 0 0 12px; }
small, .small { font-size: 12px; line-height: 1.4; font-weight: 500; }

a { color: var(--dentik-primary); text-decoration: none; }
a:hover { text-decoration: underline; }

.text-muted { color: var(--dentik-text-muted); }

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

/* ---------- Sidebar ---------- */
.sidebar {
  width: var(--sidebar-w);
  flex-shrink: 0;
  background: var(--dentik-primary-dark);
  color: rgba(255, 255, 255, 0.72);
  display: flex;
  flex-direction: column;
  position: fixed;
  inset: 0 auto 0 0;
  z-index: 40;
  transition: transform .22s ease;
}

.sidebar__brand {
  height: var(--topbar-h);
  display: flex;
  align-items: center;
  padding: 0 20px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}
.sidebar__brand a { display: flex; align-items: center; }
.sidebar__brand img {
  height: 40px;
  width: auto;
  display: block;
}

.sidebar__nav { padding: 16px 12px; overflow-y: auto; flex: 1; }

.sidebar__label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: rgba(255, 255, 255, 0.38);
  padding: 16px 12px 6px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 9px 12px;
  border-radius: var(--radius-sm);
  color: rgba(255, 255, 255, 0.72);
  font-size: 14px;
  font-weight: 500;
  margin-bottom: 2px;
  transition: background .15s ease, color .15s ease;
}
.nav-item:hover {
  background: rgba(255, 255, 255, 0.07);
  color: #fff;
  text-decoration: none;
}
.nav-item.is-active {
  background: var(--dentik-primary);
  color: #fff;
  box-shadow: 0 2px 8px rgba(0, 128, 255, 0.35);
}
.nav-item svg { width: 18px; height: 18px; stroke-width: 1.75; flex-shrink: 0; }
.nav-item__badge {
  margin-left: auto;
  background: var(--dentik-accent-orange);
  color: #fff;
  font-size: 11px;
  font-weight: 600;
  border-radius: 20px;
  padding: 1px 7px;
}

.sidebar__footer {
  padding: 12px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  font-size: 12px;
  color: rgba(255, 255, 255, 0.45);
}

/* ---------- Área principal ---------- */
.main {
  flex: 1;
  margin-left: var(--sidebar-w);
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.topbar {
  height: var(--topbar-h);
  background: var(--dentik-white);
  border-bottom: 1px solid var(--dentik-border);
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 0 24px;
  position: sticky;
  top: 0;
  z-index: 30;
}

.topbar__title { font-size: 16px; font-weight: 600; color: var(--dentik-primary-dark); }
.topbar__spacer { margin-left: auto; }

.topbar__user {
  display: flex;
  align-items: center;
  gap: 10px;
  padding-left: 16px;
  border-left: 1px solid var(--dentik-border);
}
.avatar {
  width: 34px; height: 34px;
  border-radius: 50%;
  background: var(--dentik-primary-soft);
  color: var(--dentik-primary);
  display: grid;
  place-items: center;
  font-weight: 600;
  font-size: 13px;
  flex-shrink: 0;
}
.topbar__user-name { font-size: 13px; font-weight: 600; line-height: 1.2; }
.topbar__user-role { font-size: 12px; color: var(--dentik-text-muted); line-height: 1.2; }

.content { padding: 24px; flex: 1; }
.page-head {
  display: flex;
  align-items: flex-start;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 20px;
}
.page-head__actions { margin-left: auto; display: flex; gap: 8px; }

/* Botón hamburguesa (solo móvil) */
.btn-menu {
  display: none;
  background: none;
  border: none;
  cursor: pointer;
  color: var(--dentik-primary-dark);
  padding: 6px;
}

/* ==========================================================================
   COMPONENTES
   ========================================================================== */

/* ---------- Tarjetas ---------- */
.card {
  background: var(--dentik-white);
  border: 1px solid var(--dentik-border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
}
.card__head {
  padding: 16px 20px;
  border-bottom: 1px solid var(--dentik-border);
  display: flex;
  align-items: center;
  gap: 12px;
}
.card__head h3 { margin: 0; }
.card__body { padding: 20px; }
.card__foot {
  padding: 12px 20px;
  border-top: 1px solid var(--dentik-border);
  background: var(--dentik-bg-light);
  border-radius: 0 0 var(--radius) var(--radius);
}

/* ---------- Grid ---------- */
.grid { display: grid; gap: 16px; }
.grid--4 { grid-template-columns: repeat(4, 1fr); }
.grid--3 { grid-template-columns: repeat(3, 1fr); }
.grid--2 { grid-template-columns: repeat(2, 1fr); }
.grid--2-1 { grid-template-columns: 2fr 1fr; }

/* ---------- KPI ---------- */
.kpi {
  background: var(--dentik-white);
  border: 1px solid var(--dentik-border);
  border-radius: var(--radius);
  padding: 18px 20px;
  box-shadow: var(--shadow-sm);
  display: flex;
  align-items: center;
  gap: 16px;
}
.kpi__icon {
  width: 44px; height: 44px;
  border-radius: var(--radius);
  display: grid;
  place-items: center;
  flex-shrink: 0;
}
.kpi__icon svg { width: 21px; height: 21px; stroke-width: 1.75; }
.kpi__icon--blue   { background: var(--dentik-primary-soft); color: var(--dentik-primary); }
.kpi__icon--mint   { background: var(--dentik-mint-soft);    color: #00A891; }
.kpi__icon--orange { background: var(--dentik-orange-soft);  color: var(--dentik-accent-orange); }
.kpi__icon--dark   { background: rgba(10, 37, 64, .08);      color: var(--dentik-primary-dark); }
.kpi__value { font-size: 26px; font-weight: 700; line-height: 1.1; color: var(--dentik-primary-dark); }
.kpi__label { font-size: 12px; font-weight: 500; color: var(--dentik-text-muted); }

/* ---------- Botones ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  height: 38px;
  padding: 0 16px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  font-family: inherit;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: background .15s ease, border-color .15s ease, box-shadow .15s ease;
  white-space: nowrap;
}
.btn:hover { text-decoration: none; }
.btn svg { width: 17px; height: 17px; stroke-width: 1.75; }

.btn--primary { background: var(--dentik-primary); color: #fff; }
.btn--primary:hover { background: #006BD6; box-shadow: 0 2px 8px rgba(0,128,255,.3); }

.btn--dark { background: var(--dentik-primary-dark); color: #fff; }
.btn--dark:hover { background: #143454; }

.btn--accent { background: var(--dentik-accent-orange); color: #fff; }
.btn--accent:hover { background: #E56D00; }

.btn--ghost { background: var(--dentik-white); color: var(--dentik-text-dark); border-color: var(--dentik-border); }
.btn--ghost:hover { background: var(--dentik-bg-light); border-color: #CBD5E1; }

.btn--sm { height: 32px; padding: 0 12px; font-size: 13px; }
.btn--block { width: 100%; }

/* ---------- Formularios ---------- */
.form-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 16px; }
.form-grid--3 { grid-template-columns: repeat(3, 1fr); }
.field--full { grid-column: 1 / -1; }

.field { display: flex; flex-direction: column; gap: 6px; }
.field label {
  font-size: 13px;
  font-weight: 500;
  color: var(--dentik-text-dark);
}
.field label .req { color: var(--dentik-danger); }

.input, .select, .textarea {
  width: 100%;
  height: 40px;
  padding: 0 12px;
  border: 1px solid var(--dentik-border);
  border-radius: var(--radius-sm);
  background: var(--dentik-white);
  font-family: inherit;
  font-size: 14px;
  color: var(--dentik-text-dark);
  transition: border-color .15s ease, box-shadow .15s ease;
}
.textarea { height: auto; min-height: 84px; padding: 10px 12px; resize: vertical; }
.select { appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='none' stroke='%2364748B' stroke-width='2' stroke-linecap='round'%3E%3Cpath d='M4 6l4 4 4-4'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 12px center; padding-right: 34px; }

.input:focus, .select:focus, .textarea:focus {
  outline: none;
  border-color: var(--dentik-primary);
  box-shadow: 0 0 0 3px var(--dentik-primary-soft);
}
.input.is-error, .select.is-error, .textarea.is-error { border-color: var(--dentik-danger); }
.field__error { font-size: 12px; color: var(--dentik-danger); }
.field__hint  { font-size: 12px; color: var(--dentik-text-muted); }

.check { display: flex; align-items: center; gap: 8px; font-size: 14px; cursor: pointer; }
.check input { width: 16px; height: 16px; accent-color: var(--dentik-primary); cursor: pointer; }

.fieldset {
  border: 1px solid var(--dentik-border);
  border-radius: var(--radius);
  padding: 18px 20px;
  margin-bottom: 16px;
}
.fieldset > legend {
  font-size: 13px;
  font-weight: 600;
  color: var(--dentik-primary-dark);
  text-transform: uppercase;
  letter-spacing: .05em;
  padding: 0 8px;
}

/* ---------- Buscador ---------- */
.search { position: relative; }
.search svg {
  position: absolute;
  left: 12px; top: 50%;
  transform: translateY(-50%);
  width: 17px; height: 17px;
  color: var(--dentik-text-muted);
  stroke-width: 1.75;
  pointer-events: none;
}
.search .input { padding-left: 36px; }

/* ---------- Tablas (encabezado #0A2540 sobre #F4F6F8 según manual) ---------- */
.table-wrap { overflow-x: auto; border-radius: var(--radius); }
.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table thead th {
  background: var(--dentik-bg-light);
  color: var(--dentik-primary-dark);
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .04em;
  text-align: left;
  padding: 11px 16px;
  border-bottom: 1px solid var(--dentik-border);
  white-space: nowrap;
}
.table tbody td {
  padding: 12px 16px;
  border-bottom: 1px solid var(--dentik-border);
  vertical-align: middle;
}
.table tbody tr:last-child td { border-bottom: none; }
.table tbody tr:hover { background: #FAFBFC; }
.table__actions { display: flex; gap: 6px; justify-content: flex-end; }

/* ---------- Badges y semáforo ---------- */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 12px;
  font-weight: 500;
  padding: 3px 9px;
  border-radius: 20px;
  white-space: nowrap;
}
.badge--blue   { background: var(--dentik-primary-soft); color: #0064C8; }
.badge--mint   { background: var(--dentik-mint-soft);    color: #008E7A; }
.badge--orange { background: var(--dentik-orange-soft);  color: #C25E00; }
.badge--red    { background: var(--dentik-danger-soft);  color: var(--dentik-danger); }
.badge--gray   { background: #EEF2F6; color: var(--dentik-text-muted); }

.dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; flex-shrink: 0; }
.dot--verde    { background: var(--dentik-mint); }
.dot--amarillo { background: var(--dentik-accent-orange); }
.dot--rojo,
.dot--vencido  { background: var(--dentik-danger); }
.dot--sin_datos{ background: #CBD5E1; }

/* ---------- Alertas ---------- */
.alert {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  margin-bottom: 16px;
  border: 1px solid transparent;
}
.alert svg { width: 18px; height: 18px; stroke-width: 1.75; flex-shrink: 0; margin-top: 1px; }
.alert--exito { background: var(--dentik-mint-soft);   border-color: rgba(0,212,178,.35);  color: #00705F; }
.alert--error { background: var(--dentik-danger-soft); border-color: rgba(225,29,72,.25);  color: #A5133B; }
.alert--info  { background: var(--dentik-primary-soft);border-color: rgba(0,128,255,.25);  color: #0057AD; }
.alert--warning { background: #fff4e5; border-color: rgba(255,152,0,.4); color: #8a4b00; }

/* ---------- Estado vacío ---------- */
.empty { text-align: center; padding: 48px 24px; color: var(--dentik-text-muted); }
.empty svg { width: 40px; height: 40px; stroke-width: 1.5; color: #CBD5E1; margin-bottom: 12px; }
.empty h3 { color: var(--dentik-text-dark); margin-bottom: 4px; }

/* ---------- Lista de agenda ---------- */
.agenda-item {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 12px 0;
  border-bottom: 1px solid var(--dentik-border);
}
.agenda-item:last-child { border-bottom: none; }
.agenda-item__time {
  font-size: 13px;
  font-weight: 600;
  color: var(--dentik-primary-dark);
  min-width: 52px;
}
.agenda-item__bar { width: 3px; align-self: stretch; border-radius: 2px; background: var(--dentik-primary); }
.agenda-item__body { min-width: 0; flex: 1; }
.agenda-item__name { font-weight: 500; }

/* ---------- Paginación ---------- */
.pagination { display: flex; gap: 4px; list-style: none; padding: 0; margin: 16px 0 0; }
.pagination a, .pagination span {
  display: grid;
  place-items: center;
  min-width: 34px; height: 34px;
  padding: 0 10px;
  border: 1px solid var(--dentik-border);
  border-radius: var(--radius-sm);
  background: var(--dentik-white);
  font-size: 13px;
  color: var(--dentik-text-dark);
}
.pagination a:hover { background: var(--dentik-bg-light); text-decoration: none; }
.pagination .active span { background: var(--dentik-primary); border-color: var(--dentik-primary); color: #fff; }
.pagination .disabled span { color: #CBD5E1; }

/* ==========================================================================
   LOGIN
   ========================================================================== */
.login {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 1fr 1fr;
}

.login__aside {
  background: linear-gradient(150deg, var(--dentik-primary-dark) 0%, #0d3a63 55%, #0b4e86 100%);
  color: #fff;
  padding: 56px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  position: relative;
  overflow: hidden;
}
/* Acento de marca: halo naranja/mint muy sutil */
.login__aside::after {
  content: '';
  position: absolute;
  width: 420px; height: 420px;
  right: -140px; bottom: -160px;
  background: radial-gradient(circle, rgba(255,122,0,.28) 0%, rgba(255,122,0,0) 70%);
  pointer-events: none;
}
.login__aside::before {
  content: '';
  position: absolute;
  width: 320px; height: 320px;
  left: -120px; top: -100px;
  background: radial-gradient(circle, rgba(0,212,178,.22) 0%, rgba(0,212,178,0) 70%);
  pointer-events: none;
}
.login__aside > * { position: relative; z-index: 1; }
.login__logo img { height: 64px; width: auto; display: block; }
.login__claim h2 { color: #fff; font-size: 30px; line-height: 1.25; margin-bottom: 12px; max-width: 15ch; }
.login__claim p { color: rgba(255,255,255,.72); max-width: 42ch; }
.login__points { list-style: none; padding: 0; margin: 28px 0 0; display: grid; gap: 12px; }
.login__points li { display: flex; align-items: center; gap: 10px; color: rgba(255,255,255,.85); font-size: 14px; }
.login__points svg { width: 18px; height: 18px; stroke-width: 2; color: var(--dentik-mint); }
.login__legal { font-size: 12px; color: rgba(255,255,255,.45); }

.login__main {
  display: grid;
  place-items: center;
  padding: 40px 24px;
  background: var(--dentik-white);
}
.login__box { width: 100%; max-width: 380px; }
.login__box h1 { margin-bottom: 6px; }
.login__box > p { color: var(--dentik-text-muted); margin-bottom: 28px; }
.login__mobile-logo { display: none; margin-bottom: 24px; }
.login__mobile-logo img { height: 52px; width: auto; }

/* ==========================================================================
   UTILIDADES
   ========================================================================== */
.mb-0 { margin-bottom: 0; }
.mb-8 { margin-bottom: 8px; }
.mb-16 { margin-bottom: 16px; }
.mb-24 { margin-bottom: 24px; }
.mt-16 { margin-top: 16px; }
.flex { display: flex; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-8 { gap: 8px; }
.gap-12 { gap: 12px; }
.text-right { text-align: right; }
.w-full { width: 100%; }

/* ==========================================================================
   RESPONSIVE
   ========================================================================== */
@media (max-width: 1100px) {
  .grid--4 { grid-template-columns: repeat(2, 1fr); }
  .grid--2-1 { grid-template-columns: 1fr; }
}

@media (max-width: 900px) {
  .login { grid-template-columns: 1fr; }
  .login__aside { display: none; }
  .login__mobile-logo { display: block; }
}

@media (max-width: 820px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.is-open { transform: translateX(0); box-shadow: var(--shadow-lg); }
  .main { margin-left: 0; }
  .btn-menu { display: grid; place-items: center; }
  .grid--4, .grid--3, .grid--2 { grid-template-columns: 1fr; }
  .form-grid, .form-grid--3 { grid-template-columns: 1fr; }
  .content { padding: 16px; }
  .topbar { padding: 0 16px; }
  .topbar__user-name, .topbar__user-role { display: none; }
}

/* Accesibilidad: foco visible y respeto a reduced-motion */
:focus-visible {
  outline: 2px solid var(--dentik-primary);
  outline-offset: 2px;
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .01ms !important;
    transition-duration: .01ms !important;
  }
}

/* Alinear celdas del pie de tabla (subtotales/total) con el cuerpo */
.table tfoot td { padding: 12px 16px; }
