/* Panel de administración — estilos (extiende styles.css) */
.admin-body { background: hsl(var(--muted) / 0.4); }

/* Login */
.admin-login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 1.5rem; }
.admin-login-card { background: hsl(var(--card)); border: 1px solid hsl(var(--border)); border-radius: var(--radius); padding: 2.25rem; width: 100%; max-width: 400px; box-shadow: 0 20px 50px rgba(0,0,0,0.1); }
.admin-login-card .brand { justify-content: center; margin-bottom: 0.5rem; }
.admin-login-card h1 { font-size: 1.5rem; text-align: center; margin-bottom: 0.35rem; }
.admin-login-card p.sub { text-align: center; color: hsl(var(--muted-foreground)); font-size: 0.9rem; margin-bottom: 1.5rem; }
.field { margin-bottom: 1rem; }
.field label { display: block; font-size: 0.82rem; font-weight: 600; margin-bottom: 0.35rem; color: hsl(var(--foreground)); }
.field input, .field textarea, .field select { width: 100%; padding: 0.7rem 0.85rem; font-family: inherit; font-size: 0.95rem; border: 1px solid hsl(var(--border)); border-radius: 0.5rem; background: hsl(var(--background)); color: hsl(var(--foreground)); }
.field input:focus, .field textarea:focus { outline: none; border-color: hsl(var(--primary) / 0.5); box-shadow: 0 0 0 3px hsl(var(--primary) / 0.1); }
.err-msg { color: #dc2626; font-size: 0.85rem; margin-top: 0.5rem; min-height: 1rem; }
.hint { font-size: 0.78rem; color: hsl(var(--muted-foreground)); text-align: center; margin-top: 1rem; }

/* Shell */
.admin-shell { display: grid; grid-template-columns: 250px 1fr; min-height: 100vh; }
.admin-sidebar { background: hsl(var(--card)); border-right: 1px solid hsl(var(--border)); padding: 1.25rem; display: flex; flex-direction: column; gap: 0.25rem; position: sticky; top: 0; height: 100vh; overflow-y: auto; }
.admin-sidebar .brand { margin-bottom: 1.25rem; font-size: 1rem; }
.side-link { display: flex; align-items: center; gap: 0.7rem; padding: 0.65rem 0.8rem; border-radius: 0.5rem; font-size: 0.9rem; font-weight: 500; color: hsl(var(--muted-foreground)); cursor: pointer; border: none; background: none; font-family: inherit; text-align: left; width: 100%; transition: background-color 0.15s ease, color 0.15s ease; }
.side-link i { width: 20px; text-align: center; }
.side-link:hover { background: hsl(var(--accent)); color: hsl(var(--primary)); }
.side-link.active { background: hsl(var(--primary)); color: hsl(var(--primary-foreground)); }
.side-spacer { flex: 1; }
.side-group-label { font-size: 0.7rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.06em; color: hsl(var(--muted-foreground)); padding: 0.9rem 0.8rem 0.2rem; }

.admin-main { padding: 2rem 2.25rem; overflow-y: auto; }
.admin-topbar { display: flex; align-items: center; justify-content: space-between; margin-bottom: 1.75rem; }
.admin-topbar h1 { font-size: 1.7rem; }
.admin-topbar .who { font-size: 0.85rem; color: hsl(var(--muted-foreground)); }

/* Stat cards */
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 1rem; margin-bottom: 2rem; }
.stat-card { background: hsl(var(--card)); border: 1px solid hsl(var(--border)); border-radius: var(--radius); padding: 1.25rem; }
.stat-card .icon { width: 40px; height: 40px; border-radius: 10px; display: flex; align-items: center; justify-content: center; background: hsl(var(--accent)); color: hsl(var(--primary)); margin-bottom: 0.75rem; }
.stat-card .val { font-family: 'Playfair Display', serif; font-size: 2rem; color: hsl(var(--foreground)); line-height: 1; }
.stat-card .lbl { font-size: 0.82rem; color: hsl(var(--muted-foreground)); margin-top: 0.35rem; }

.chart { display: flex; align-items: flex-end; gap: 0.5rem; height: 160px; padding: 1rem; background: hsl(var(--card)); border: 1px solid hsl(var(--border)); border-radius: var(--radius); }
.chart .bar { flex: 1; background: hsl(var(--primary) / 0.75); border-radius: 4px 4px 0 0; min-height: 4px; position: relative; display: flex; align-items: flex-end; justify-content: center; transition: background-color 0.2s; }
.chart .bar:hover { background: hsl(var(--primary)); }
.chart .bar span { position: absolute; bottom: -1.4rem; font-size: 0.65rem; color: hsl(var(--muted-foreground)); white-space: nowrap; }
.chart .bar b { position: absolute; top: -1.2rem; font-size: 0.7rem; color: hsl(var(--foreground)); }

/* Panel card + table */
.panel { background: hsl(var(--card)); border: 1px solid hsl(var(--border)); border-radius: var(--radius); padding: 1.5rem; margin-bottom: 1.5rem; }
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 1rem; margin-bottom: 1.25rem; flex-wrap: wrap; }
.panel-head h2 { font-size: 1.2rem; }
table.data { width: 100%; border-collapse: collapse; font-size: 0.88rem; }
table.data th { text-align: left; padding: 0.6rem 0.75rem; color: hsl(var(--muted-foreground)); font-weight: 600; font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.05em; border-bottom: 1px solid hsl(var(--border)); }
table.data td { padding: 0.65rem 0.75rem; border-bottom: 1px solid hsl(var(--border)); vertical-align: middle; }
table.data tr:hover td { background: hsl(var(--accent) / 0.5); }
table.data select.feat-plan { padding: 0.35rem 0.5rem; font-family: inherit; font-size: 0.85rem; border: 1px solid hsl(var(--border)); border-radius: 0.4rem; background: hsl(var(--background)); color: hsl(var(--foreground)); max-width: 220px; }
table.data select.pill-select { padding: 0.25rem 0.55rem; font-family: inherit; font-size: 0.78rem; font-weight: 600; border-radius: 999px; border: none; cursor: pointer; }
table.data select.pill-select.pending { background: #fef3c7; color: #92400e; }
table.data select.pill-select.contacted { background: #dbeafe; color: #1e40af; }
table.data select.pill-select.resolved { background: #dcfce7; color: #166534; }
.pill { display: inline-block; padding: 0.15rem 0.6rem; border-radius: 999px; font-size: 0.72rem; font-weight: 600; }
.pill.active { background: #dcfce7; color: #166534; }
.pill.blocked { background: #fee2e2; color: #991b1b; }
.pill.role { background: hsl(var(--accent)); color: hsl(var(--primary)); }
.pill.sent { background: #dcfce7; color: #166534; }
.pill.draft { background: #fef3c7; color: #92400e; }

.mono { font-family: ui-monospace, "SF Mono", Menlo, monospace; font-size: 0.82rem; }
.btn-sm { padding: 0.4rem 0.75rem; font-size: 0.8rem; border-radius: 0.4rem; }
.btn-danger { background: #dc2626; color: #fff; }
.btn-danger:hover { background: #b91c1c; }
.row-actions { display: flex; gap: 0.4rem; flex-wrap: wrap; }
.empty { text-align: center; color: hsl(var(--muted-foreground)); padding: 2rem; }

/* toggle in admin */
.mini-switch { position: relative; display: inline-block; width: 38px; height: 22px; }
.mini-switch input { opacity: 0; width: 0; height: 0; }
.mini-slider { position: absolute; inset: 0; background: hsl(var(--border)); border-radius: 999px; transition: 0.2s; cursor: pointer; }
.mini-slider::before { content: ''; position: absolute; height: 16px; width: 16px; left: 3px; top: 3px; background: #fff; border-radius: 50%; transition: 0.2s; }
.mini-switch input:checked + .mini-slider { background: hsl(var(--primary)); }
.mini-switch input:checked + .mini-slider::before { transform: translateX(16px); }

.inline-form { display: flex; gap: 0.5rem; flex-wrap: wrap; align-items: flex-end; }
.inline-form .field { margin-bottom: 0; }

/* Calendario: modal de evento aislado del layout del panel */
.admin-calendar-modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 10000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  background: rgba(15, 23, 42, 0.62);
  overflow-y: auto;
}
.admin-calendar-modal {
  width: min(760px, 100%);
  max-height: min(900px, calc(100vh - 2rem));
  overflow-y: auto;
  background: hsl(var(--card));
  color: hsl(var(--foreground));
  border: 1px solid hsl(var(--border));
  border-radius: 1rem;
  padding: 1.25rem;
  box-shadow: 0 24px 70px rgba(0,0,0,.28);
}
.admin-calendar-modal .panel-head {
  position: sticky;
  top: -1.25rem;
  z-index: 2;
  margin: -1.25rem -1.25rem 1.25rem;
  padding: 1.25rem;
  background: hsl(var(--card));
  border-bottom: 1px solid hsl(var(--border));
}
.admin-calendar-modal .form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0 1rem;
}
.admin-calendar-modal .field { min-width: 0; }
.admin-calendar-modal textarea { resize: vertical; }
.admin-calendar-modal input[type="checkbox"] { width: 20px; height: 20px; accent-color: hsl(var(--primary)); }
@media (max-width: 700px) {
  .admin-calendar-modal-overlay { padding: .5rem; align-items: flex-start; }
  .admin-calendar-modal { max-height: calc(100vh - 1rem); border-radius: .8rem; padding: 1rem; }
  .admin-calendar-modal .panel-head { top: -1rem; margin: -1rem -1rem 1rem; padding: 1rem; }
  .admin-calendar-modal .form-grid { grid-template-columns: 1fr; gap: 0; }
  .admin-calendar-modal .field[style*="grid-column"] { grid-column: auto !important; }
  .admin-calendar-modal .panel-head h2 { font-size: 1rem; }
}

@media (max-width: 800px) {
  .admin-shell { grid-template-columns: 1fr; }
  .admin-sidebar { position: relative; height: auto; flex-direction: row; flex-wrap: wrap; }
  .side-spacer { display: none; }
  .admin-main { padding: 1.25rem; }
}

/* AdSense safety: never allow ads to escape existing containers. */
.ad-slot,.ad-box{min-width:0;max-width:100%;overflow:hidden}.ad-box>ins.adsbygoogle{box-sizing:border-box;max-width:100%!important;width:100%!important}.ad-box iframe{max-width:100%!important}

/* Ocultar de verdad los módulos para los que la cuenta delegada no tiene permiso. */
.side-link[hidden], .side-group-label[hidden] { display: none !important; }


/* Rediseño visual del panel — continuidad con el sitio público */
.admin-body { background: hsl(var(--background)); }
.admin-login-wrap { padding: clamp(1rem, 3vw, 2rem); background: radial-gradient(ellipse at top, hsl(var(--accent) / .8), transparent 55%); }
.admin-login-card { max-width: 440px; padding: clamp(1.4rem, 4vw, 2.4rem); border-radius: 22px; border-color: hsl(var(--border)); box-shadow: 0 24px 72px rgba(21, 42, 34, .12); }
.admin-login-card .brand { display: flex; align-items: center; gap: .6rem; color: hsl(var(--foreground)); font-size: 1.05rem; }
.admin-login-card .brand i { display: grid; place-items: center; width: 38px; height: 38px; border-radius: 12px; background: hsl(var(--primary)); color: hsl(var(--primary-foreground)); }
.admin-login-card h1 { line-height: 1.2; letter-spacing: -.025em; }
.admin-shell { grid-template-columns: 258px minmax(0,1fr); background: hsl(var(--background)); }
.admin-sidebar { background: hsl(var(--card)); border-right-color: hsl(var(--border)); padding: 1.15rem .9rem; gap: .3rem; }
.admin-sidebar .brand { padding: .55rem .65rem 1rem; border-bottom: 1px solid hsl(var(--border)); margin-bottom: .55rem; }
.side-group-label { margin: .9rem .65rem .35rem; color: hsl(var(--muted-foreground)); letter-spacing: .09em; font-size: .68rem; }
.side-link { min-height: 43px; padding: .65rem .75rem; border-radius: 12px; gap: .65rem; color: hsl(var(--muted-foreground)); transition: background .16s ease,color .16s ease,transform .16s ease; }
.side-link:hover { background: hsl(var(--accent)); color: hsl(var(--primary)); }
.side-link.active { color: hsl(var(--primary-foreground)); background: hsl(var(--primary)); box-shadow: 0 4px 12px hsl(var(--primary) / .12); }
.side-link i { width: 19px; text-align: center; }
.admin-main { min-width: 0; padding: clamp(1rem, 2.8vw, 2.25rem); }
.admin-topbar { min-height: 62px; background: hsl(var(--background) / .88); border-bottom-color: hsl(var(--border)); margin-bottom: 1.35rem; }
.admin-topbar h1 { font-size: clamp(1.45rem, 2.5vw, 2.1rem); letter-spacing: -.035em; }
.stat-grid { gap: 1rem; }
.stat-card, .panel, .chart { border: 1px solid hsl(var(--border)); border-radius: 18px; background: hsl(var(--card)); box-shadow: var(--shadow-soft, 0 8px 28px rgba(27,40,36,.07)); }
.stat-card { padding: 1.2rem; }
.stat-card .icon { border-radius: 12px; background: hsl(var(--accent)); color: hsl(var(--primary)); }
.stat-card .val { letter-spacing: -.035em; }
.panel { overflow: hidden; margin-bottom: 1.2rem; }
.panel-head { padding: 1.05rem 1.25rem; border-bottom: 1px solid hsl(var(--border)); }
.panel-head h2 { font-size: 1.13rem; letter-spacing: -.02em; }
table.data th { background: hsl(var(--muted) / .8); color: hsl(var(--muted-foreground)); font-size: .75rem; letter-spacing: .045em; text-transform: uppercase; }
table.data th, table.data td { padding: .85rem .95rem; border-color: hsl(var(--border)); }
table.data tr:hover td { background: hsl(var(--accent) / .4); }
.admin-body .field input, .admin-body .field textarea, .admin-body .field select { border-radius: 11px; min-height: 44px; }
.admin-calendar-modal { border-radius: 20px; }
@media (max-width: 800px) {
  .admin-shell { grid-template-columns: minmax(0,1fr); }
  .admin-sidebar { position: sticky; z-index: 35; top: 0; flex-direction: row; flex-wrap: nowrap; overflow-x: auto; padding: .5rem; border-right: 0; border-bottom: 1px solid hsl(var(--border)); }
  .admin-sidebar .brand, .side-spacer, .side-group-label { display: none; }
  .side-link { flex: 0 0 auto; white-space: nowrap; min-height: 42px; padding: .6rem .75rem; }
  .admin-main { padding: 1rem .75rem 2rem; }
  .panel { overflow-x: auto; }
  table.data { min-width: 650px; }
}
@media (prefers-reduced-motion: reduce) {
  .side-link, .admin-calendar-modal-overlay, .admin-calendar-modal { transition: none !important; }
}


/* Navegación del panel agrupada por categorías */
.admin-sidebar { min-width: 0; }
.admin-nav-groups { display: flex; flex-direction: column; gap: .45rem; min-width: 0; }
.admin-nav-group { min-width: 0; border: 1px solid hsl(var(--border)); border-radius: 13px; overflow: hidden; background: hsl(var(--background) / .45); }
.admin-nav-group[hidden] { display: none !important; }
.admin-nav-group-toggle { display: flex; align-items: center; gap: .65rem; width: 100%; min-height: 42px; padding: .7rem .75rem; border: 0; background: transparent; color: hsl(var(--foreground)); font: inherit; font-size: .79rem; font-weight: 750; text-align: left; cursor: pointer; }
.admin-nav-group-toggle > i:first-child { width: 18px; text-align: center; color: hsl(var(--primary)); }
.admin-nav-group-toggle span { flex: 1; }
.admin-nav-group-toggle:hover { background: hsl(var(--accent) / .6); }
.admin-nav-group-toggle .group-chevron { font-size: .68rem; color: hsl(var(--muted-foreground)); transition: transform .18s ease; }
.admin-nav-group.is-collapsed .group-chevron { transform: rotate(-90deg); }
.admin-nav-group-items { display: flex; flex-direction: column; gap: .15rem; padding: 0 .35rem .4rem; }
.admin-nav-group-items[hidden] { display: none !important; }
.admin-nav-group-items .side-link { width: 100%; min-width: 0; justify-content: flex-start; padding: .58rem .65rem; font-size: .82rem; }
.admin-nav-group-items .side-link span { overflow: hidden; text-overflow: ellipsis; }
.admin-sidebar-footer { display: flex; flex-direction: column; gap: .25rem; margin-top: auto; padding-top: .7rem; border-top: 1px solid hsl(var(--border)); }
.admin-sidebar-footer .side-link { width: 100%; }
.admin-sidebar-footer .side-link span { flex: 1; }
.admin-nav-group-toggle:focus-visible, .admin-nav-group-items .side-link:focus-visible, .admin-sidebar-footer .side-link:focus-visible { outline: 2px solid hsl(var(--primary)); outline-offset: 2px; }
@media (max-width: 800px) {
  .admin-sidebar { align-items: stretch; flex-direction: column; flex-wrap: nowrap; max-height: 48vh; overflow-y: auto; }
  .admin-sidebar .brand { display: flex; }
  .admin-nav-groups { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 230px), 1fr)); gap: .5rem; }
  .admin-sidebar-footer { flex-direction: row; margin-top: .5rem; }
}


/* LVH Admin Refresh — capa editorial responsive, compatible con los componentes existentes */
.admin-body {
  background:
    radial-gradient(ellipse at 12% 0%, rgba(40, 89, 132, .075), transparent 34rem),
    hsl(var(--muted) / .36);
}
.admin-body button, .admin-body input, .admin-body select, .admin-body textarea {
  transition: border-color .16s ease, box-shadow .16s ease, background-color .16s ease, transform .16s ease;
}
.admin-body :is(button, a, input, select, textarea):focus-visible {
  outline: 3px solid rgba(45, 105, 156, .38);
  outline-offset: 2px;
}
.admin-sidebar, .admin-side, .sidebar {
  border-right-color: rgba(27, 51, 76, .10);
}
.admin-nav-group {
  margin-block: .45rem;
}
.admin-nav-group .side-link {
  border-radius: 10px;
  margin: 2px 0;
  min-height: 40px;
  font-weight: 550;
}
.admin-nav-group .side-link:hover {
  background: rgba(31, 79, 119, .075);
  transform: translateX(2px);
}
.admin-nav-group .side-link.active,
.admin-nav-group .side-link[aria-current="page"] {
  background: linear-gradient(105deg, rgba(31, 79, 119, .14), rgba(31, 79, 119, .045));
  box-shadow: inset 3px 0 #24577e;
  color: var(--primary, #214f73);
  font-weight: 750;
}
#section-title {
  letter-spacing: -.035em;
  line-height: 1.16;
}
#section-content {
  min-width: 0;
}
#section-content :is(.card, .admin-card, .stat-card, .panel-card) {
  border-color: rgba(35, 58, 78, .12);
  border-radius: 15px;
  box-shadow: 0 5px 20px rgba(18, 38, 56, .035);
}
#section-content :is(button, .btn) {
  border-radius: 9px;
  font-weight: 650;
}
#section-content :is(input, select, textarea) {
  border-radius: 9px;
  min-height: 40px;
}
#section-content :is(table) {
  border-collapse: separate;
  border-spacing: 0;
  overflow: hidden;
  border-radius: 12px;
}
#section-content th {
  background: rgba(34, 66, 92, .055);
  color: hsl(var(--muted-foreground));
  font-size: .76rem;
  letter-spacing: .035em;
  text-transform: uppercase;
}
#section-content :is(td, th) {
  padding: .8rem .9rem;
  vertical-align: top;
}
#section-content tbody tr:hover {
  background: rgba(35, 82, 120, .035);
}
#section-content :is(.badge, .status, .pill) {
  border-radius: 999px;
}
.admin-login-card {
  border-radius: 20px;
  box-shadow: 0 24px 70px rgba(14, 37, 58, .13);
}
@media (max-width: 760px) {
  #section-content { overflow-wrap: anywhere; }
  #section-content :is(.card, .admin-card, .stat-card, .panel-card) { border-radius: 12px; }
  #section-content :is(table) { display: block; max-width: 100%; overflow-x: auto; }
  #section-content :is(button, .btn) { min-height: 40px; }
}
@media (prefers-reduced-motion: reduce) {
  .admin-body *, .admin-body *::before, .admin-body *::after {
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    scroll-behavior: auto !important;
    transition-duration: .01ms !important;
  }
}
