/* ============================================================
   Portal Legislativo — Admin Panel Styles
   ============================================================ */

:root {
  --adm-navy:     #2E1B16;
  --adm-red:      #610200;
  --adm-sidebar:  #1e0f0b;
  --adm-sidebar-h:#120806;
  --adm-white:    #ffffff;
  --adm-gray-100: #f0f2f5;
  --adm-gray-200: #e2e8f0;
  --adm-gray-500: #8898aa;
  --adm-gray-700: #525f7f;
  --adm-gray-900: #1a202c;
  --adm-border:   #dee2e6;
  --adm-success:  #28a745;
  --adm-danger:   #dc3545;
  --adm-warning:  #ffc107;
  --adm-info:     #17a2b8;
  --adm-sidebar-w: 240px;
  --adm-header-h:  60px;
  --font: 'Segoe UI', system-ui, sans-serif;
  --radius: 6px;
  --shadow: 0 2px 8px rgba(0,0,0,.12);
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 15px; }
body {
  font-family: var(--font);
  background: var(--adm-gray-100);
  color: var(--adm-gray-900);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--adm-navy); text-decoration: none; }
a:hover { color: var(--adm-red); }
img { max-width: 100%; }

/* ── LAYOUT ────────────────────────────────────────────────── */
.adm-layout { display: flex; min-height: 100vh; }

/* ── SIDEBAR ────────────────────────────────────────────────── */
.adm-sidebar {
  width: var(--adm-sidebar-w);
  background: var(--adm-sidebar);
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  overflow-y: hidden;
  z-index: 100;
  transition: transform .3s ease;
}
.adm-sidebar__brand {
  padding: 20px 16px;
  border-bottom: 1px solid rgba(255,255,255,.07);
  display: flex;
  align-items: center;
  gap: 10px;
}
.adm-sidebar__emblem {
  width: 36px; height: 36px;
  border-radius: 50%;
  background: rgba(255,255,255,.1);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.2rem;
  flex-shrink: 0;
}
.adm-sidebar__title {
  font-size: .82rem;
  font-weight: 700;
  color: var(--adm-white);
  text-transform: uppercase;
  letter-spacing: .04em;
  line-height: 1.2;
}
.adm-sidebar__sub { font-size: .65rem; color: rgba(255,255,255,.4); }

.adm-sidebar__nav { flex: 1; padding: 6px 0; overflow-y: auto; scrollbar-width: none; }
.adm-sidebar__nav::-webkit-scrollbar { display: none; }
.adm-nav-section { margin-bottom: 0; }
.adm-nav-section__label {
  font-size: .6rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .12em;
  color: rgba(255,255,255,.3);
  padding: 7px 16px 3px;
}
.adm-nav-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 16px;
  color: rgba(255,255,255,.7);
  font-size: .82rem;
  font-weight: 500;
  border-left: 3px solid transparent;
  transition: all .15s ease;
}
.adm-nav-link:hover,
.adm-nav-link--active {
  background: rgba(255,255,255,.07);
  color: var(--adm-white);
  border-left-color: var(--adm-red);
}
.adm-nav-link--disabled {
  color: rgba(255,255,255,.35);
  cursor: not-allowed;
  border-left-color: transparent;
  background: transparent;
  pointer-events: none;
}
.adm-nav-link__icon { width: 18px; text-align: center; font-size: 1rem; }
.adm-nav-link__badge {
  margin-left: auto;
  background: var(--adm-red);
  color: var(--adm-white);
  font-size: .64rem;
  font-weight: 700;
  padding: 1px 6px;
  border-radius: 10px;
}

.adm-sidebar__footer {
  padding: 8px 16px;
  border-top: 1px solid rgba(255,255,255,.07);
  font-size: .75rem;
  color: rgba(255,255,255,.45);
}
.adm-sidebar__footer a { color: rgba(255,255,255,.6); }
.adm-sidebar__footer a:hover { color: var(--adm-white); }

/* ── MAIN ──────────────────────────────────────────────────── */
.adm-main {
  flex: 1;
  margin-left: var(--adm-sidebar-w);
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

/* ── TOP BAR ───────────────────────────────────────────────── */
.adm-topbar {
  height: var(--adm-header-h);
  background: var(--adm-white);
  border-bottom: 1px solid var(--adm-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  position: sticky;
  top: 0;
  z-index: 50;
  box-shadow: var(--shadow);
}
.adm-topbar__title {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--adm-gray-900);
}
/* Oculto por defecto; el JS y el CSS móvil lo muestran */
#sidebarToggle { display: none; }
.adm-topbar__right { display: flex; align-items: center; gap: 16px; }
.adm-topbar__user {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: .84rem;
  font-weight: 600;
  color: var(--adm-gray-700);
}
.adm-topbar__avatar {
  width: 32px; height: 32px;
  border-radius: 50%;
  background: var(--adm-navy);
  color: var(--adm-white);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: .8rem;
}
.adm-topbar__link {
  font-size: .82rem;
  color: var(--adm-gray-500);
}
.adm-topbar__link:hover { color: var(--adm-navy); }
.adm-topbar__link--accent {
  color: var(--adm-red);
  font-weight: 700;
}
.adm-topbar__link--accent:hover {
  color: var(--adm-navy);
}

/* ── CONTENT ───────────────────────────────────────────────── */
.adm-content { flex: 1; padding: 28px; }

/* ── DASHBOARD STATS ────────────────────────────────────────── */
.stat-cards { display: grid; grid-template-columns: repeat(4, 1fr); gap: 20px; margin-bottom: 28px; }
.stat-card {
  background: var(--adm-white);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
  display: flex;
  align-items: center;
  gap: 16px;
  border-left: 4px solid var(--adm-navy);
}
.stat-card--red    { border-left-color: var(--adm-red); }
.stat-card--green  { border-left-color: var(--adm-success); }
.stat-card--orange { border-left-color: var(--adm-warning); }
.stat-card--teal   { border-left-color: var(--adm-info); }

.stat-card__icon {
  width: 52px; height: 52px;
  border-radius: 12px;
  background: var(--adm-navy);
  color: var(--adm-white);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  box-shadow: 0 4px 10px rgba(0,0,0,.18);
}
.stat-card--red .stat-card__icon    { background: var(--adm-red); }
.stat-card--green .stat-card__icon  { background: var(--adm-success); }
.stat-card--orange .stat-card__icon { background: var(--adm-warning); color: #333; }
.stat-card--teal .stat-card__icon   { background: var(--adm-info); }

.stat-card__number { font-size: 1.8rem; font-weight: 700; color: var(--adm-gray-900); line-height: 1; }
.stat-card__label  { font-size: .78rem; color: var(--adm-gray-500); margin-top: 4px; text-transform: uppercase; letter-spacing: .06em; }

/* ── PANEL / CARD ───────────────────────────────────────────── */
.panel {
  background: var(--adm-white);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
  margin-bottom: 24px;
}
.panel__header {
  padding: 14px 20px;
  border-bottom: 1px solid var(--adm-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  background: var(--adm-white);
}
.panel__title {
  font-size: .92rem;
  font-weight: 700;
  color: var(--adm-gray-900);
  display: flex;
  align-items: center;
  gap: 8px;
}
.panel__body { padding: 20px; }
.panel__footer {
  padding: 12px 20px;
  border-top: 1px solid var(--adm-border);
  background: var(--adm-gray-100);
  font-size: .82rem;
  color: var(--adm-gray-500);
}

/* ── TABLE ──────────────────────────────────────────────────── */
.adm-table { width: 100%; border-collapse: collapse; font-size: .85rem; }
.adm-table th, .adm-table td { padding: 10px 14px; text-align: left; vertical-align: middle; }
.adm-table th {
  background: var(--adm-gray-100);
  font-weight: 700;
  font-size: .75rem;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--adm-gray-700);
  border-bottom: 2px solid var(--adm-border);
}
.adm-table td { border-bottom: 1px solid var(--adm-gray-200); }
.adm-table tbody tr:hover { background: #f8f9fc; }
.adm-table .img-thumb {
  width: 48px; height: 64px;
  object-fit: contain;
  object-position: center;
  border-radius: 8px;
  background: var(--adm-white);
  display: block;
}
.thumb-wrap {
  width: 48px; height: 64px;
  border-radius: 8px;
  overflow: hidden;
  background: var(--adm-white);
  flex-shrink: 0;
}
.thumb-wrap img {
  width: 100%; height: 100%;
  object-fit: contain;
  object-position: center;
  display: block;
}
.adm-table .actions { display: flex; gap: 6px; align-items: center; }
.adm-table .actions-cell-news { white-space: nowrap; }
.adm-table .actions--news { flex-wrap: nowrap; white-space: nowrap; }
.adm-table .actions--news form { margin: 0; display: inline-flex; }
.adm-table .actions-cell-banner { white-space: nowrap; }
.adm-table .actions--banner { flex-wrap: nowrap; white-space: nowrap; }
.adm-table .actions--banner form { margin: 0; display: inline-flex; }
.adm-table .actions-cell-assistant { white-space: nowrap; }
.adm-table .actions--assistant { flex-wrap: nowrap; white-space: nowrap; }
.adm-table .actions--assistant form { margin: 0; display: inline-flex; }
.adm-table .actions-cell-senator { white-space: nowrap; }
.adm-table .actions--senator { flex-wrap: nowrap; white-space: nowrap; }
.adm-table .actions--senator form { margin: 0; display: inline-flex; }
.adm-table .actions-cell-party { white-space: nowrap; }
.adm-table .actions--party { flex-wrap: nowrap; white-space: nowrap; }
.adm-table .actions--party form { margin: 0; display: inline-flex; }

/* ── SORTABLE ────────────────────────────────────────────────── */
.sort-handle {
  color: #ccc;
  font-size: 1.1rem;
  text-align: center;
  cursor: grab;
  user-select: none;
}
.sort-handle:active { cursor: grabbing; }
.sortable-ghost td { background: #edf2ff; opacity: .5; }

/* ── BADGES ─────────────────────────────────────────────────── */
.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 12px;
  font-size: .7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .04em;
}
.badge--success { background: #d4edda; color: #155724; }
.badge--danger  { background: #f8d7da; color: #721c24; }
.badge--warning { background: #fff3cd; color: #856404; }
.badge--info    { background: #d1ecf1; color: #0c5460; }
.badge--primary { background: #cce5ff; color: #004085; }
.badge--dark    { background: #d6d8d9; color: #1b1e21; }

/* ── FORMS ──────────────────────────────────────────────────── */
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.form-grid--3 { grid-template-columns: 1fr 1fr 1fr; }
.form-full { grid-column: 1 / -1; }

.form-group { display: flex; flex-direction: column; gap: 5px; margin-bottom: 16px; }
.form-group label {
  font-size: .78rem;
  font-weight: 700;
  color: var(--adm-gray-700);
  text-transform: uppercase;
  letter-spacing: .05em;
}
.form-group .req { color: var(--adm-red); }

.form-control {
  padding: 9px 12px;
  border: 1px solid var(--adm-border);
  border-radius: var(--radius);
  font-size: .88rem;
  color: var(--adm-gray-900);
  background: var(--adm-white);
  font-family: var(--font);
  transition: border-color .15s, box-shadow .15s;
  width: 100%;
  outline: none;
}
.form-control:focus {
  border-color: var(--adm-navy);
  box-shadow: 0 0 0 3px rgba(27,58,107,.12);
}
.form-control--error { border-color: var(--adm-danger); }
textarea.form-control { resize: vertical; min-height: 120px; }
select.form-control { cursor: pointer; }

.form-hint { font-size: .75rem; color: var(--adm-gray-500); margin-top: 3px; }
.form-error { font-size: .75rem; color: var(--adm-danger); margin-top: 3px; }

/* Image preview */
.img-preview-wrap { margin-top: 8px; }
.img-preview {
  width: 160px;
  max-width: 100%;
  height: 220px;
  max-height: 60vh;
  border-radius: 4px;
  border: 2px solid var(--adm-border);
  background: var(--adm-white);
  object-fit: contain;
}

/* Checkbox / Radio */
.form-check {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: .88rem;
  cursor: pointer;
}
.form-check input { width: 16px; height: 16px; cursor: pointer; }

/* ── BUTTONS ─────────────────────────────────────────────────── */
.btn { display: inline-flex; align-items: center; gap: 6px; padding: 8px 18px;
  border-radius: var(--radius); font-size: .85rem; font-weight: 600; cursor: pointer;
  border: 1px solid transparent; transition: all .15s; text-decoration: none; }
.btn--primary { background: var(--adm-navy); color: #fff; border-color: var(--adm-navy); }
.btn--primary:hover { background: #122850; color: #fff; }
.btn--danger  { background: var(--adm-danger); color: #fff; border-color: var(--adm-danger); }
.btn--danger:hover { background: #c82333; color: #fff; }
.btn--success { background: var(--adm-success); color: #fff; border-color: var(--adm-success); }
.btn--success:hover { background: #218838; color: #fff; }
.btn--light   { background: var(--adm-gray-100); color: var(--adm-gray-700); border-color: var(--adm-border); }
.btn--light:hover { background: var(--adm-gray-200); }
.btn--warning { background: var(--adm-warning); color: #333; border-color: var(--adm-warning); }
.btn--sm { padding: 5px 12px; font-size: .78rem; }
.btn--icon { padding: 6px 10px; }

/* ── ALERT ──────────────────────────────────────────────────── */
.alert { display: flex; align-items: center; gap: 10px; padding: 12px 16px;
  border-radius: var(--radius); margin-bottom: 16px; font-size: .88rem; }
.alert--success { background: #d4edda; color: #155724; border: 1px solid #c3e6cb; }
.alert--error   { background: #f8d7da; color: #721c24; border: 1px solid #f5c6cb; }
.alert--warning { background: #fff3cd; color: #856404; border: 1px solid #ffeeba; }
.alert--info    { background: #d1ecf1; color: #0c5460; border: 1px solid #bee5eb; }

/* ── SEARCH / FILTER BAR ────────────────────────────────────── */
.table-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}
.table-search {
  display: flex;
  border: 1px solid var(--adm-border);
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--adm-white);
}
.table-search input {
  padding: 7px 12px;
  border: none;
  font-size: .85rem;
  outline: none;
  width: 240px;
}
.table-search button {
  background: var(--adm-navy);
  color: #fff;
  border: none;
  padding: 0 14px;
  cursor: pointer;
  font-size: .85rem;
}
/* Botón dentro de form con layout libre (multiples filtros) */
.table-search--free {
  border: none;
  background: none;
  overflow: visible;
}
.table-search--free input {
  width: auto;
  border: 1px solid var(--adm-border);
  border-radius: var(--radius);
  background: var(--adm-white);
}
.table-search--free button {
  background: var(--adm-gray-100);
  color: var(--adm-gray-700);
  border: 1px solid var(--adm-border);
  border-radius: var(--radius);
  padding: 5px 12px;
  font-size: .78rem;
  cursor: pointer;
  font-weight: 500;
}
.table-search--free button:hover { background: var(--adm-gray-200); }

/* ── PAGINATION ─────────────────────────────────────────────── */
.pagination { display: flex; gap: 4px; align-items: center; }
.pagination a, .pagination span {
  display: flex; align-items: center; justify-content: center;
  min-width: 32px; height: 32px; padding: 0 8px;
  border: 1px solid var(--adm-border); border-radius: var(--radius);
  font-size: .82rem; color: var(--adm-navy); background: var(--adm-white);
  transition: all .15s;
}
.pagination a:hover, .pagination .active {
  background: var(--adm-navy); color: #fff; border-color: var(--adm-navy);
}
.pagination .dots { border: none; background: none; color: var(--adm-gray-500); }

/* ── EDITOR ──────────────────────────────────────────────────── */
.rich-toolbar {
  display: flex; flex-wrap: wrap; gap: 4px;
  padding: 8px; border: 1px solid var(--adm-border);
  border-bottom: none; border-radius: var(--radius) var(--radius) 0 0;
  background: var(--adm-gray-100);
}
.rich-toolbar button {
  padding: 4px 10px; border: 1px solid var(--adm-border);
  border-radius: 3px; background: var(--adm-white); cursor: pointer;
  font-size: .8rem; font-weight: 700; color: var(--adm-gray-700);
  transition: background .1s;
}
.rich-toolbar button:hover { background: var(--adm-navy); color: #fff; border-color: var(--adm-navy); }
.rich-editor {
  border: 1px solid var(--adm-border);
  border-radius: 0 0 var(--radius) var(--radius);
  min-height: 280px; padding: 16px;
  outline: none; font-size: .9rem; line-height: 1.6;
  background: var(--adm-white);
}
.rich-editor:focus { border-color: var(--adm-navy); }
.rich-editor img {
  max-width: 100%; height: auto; display: block;
  margin: 12px 0; border-radius: 4px;
  cursor: pointer; outline: 2px solid transparent;
}
.rich-editor img:hover { outline-color: var(--adm-navy); }
.rich-editor iframe { max-width: 100%; }

/* ── RESPONSIVE ADMIN ────────────────────────────────────────── */
@media (max-width: 1024px) {
  .stat-cards { grid-template-columns: repeat(2, 1fr); }
  .form-grid { grid-template-columns: 1fr; }
  .form-grid--3 { grid-template-columns: 1fr 1fr; }
  /* Formularios admin con sidebar fijo: colapsar a 1 columna */
  .adm-content [style*="grid-template-columns:1fr 3"] { grid-template-columns: 1fr !important; }
}
@media (max-width: 768px) {
  .adm-sidebar { transform: translateX(calc(-1 * var(--adm-sidebar-w))); }
  .adm-sidebar--open { transform: translateX(0); }
  .adm-main { margin-left: 0; }
  .stat-cards { grid-template-columns: 1fr 1fr; }
  .adm-content { padding: 16px; }

  /* Mostrar botón hamburguesa */
  #sidebarToggle { display: inline-flex !important; align-items: center; justify-content: center; color: var(--adm-gray-700); }

  /* Colapsar todos los grids de formulario con columna fija */
  .adm-content [style*="grid-template-columns"] { grid-template-columns: 1fr !important; }

  /* Tablas: scroll horizontal en lugar de desbordarse */
  .panel__body { overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .adm-table { min-width: 540px; }

  /* Topbar: evitar desbordamiento del título */
  .adm-topbar { padding: 0 14px; gap: 10px; }
  .adm-topbar__title { font-size: .88rem; max-width: 40vw; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .adm-topbar__user span { display: none; }
}
@media (max-width: 480px) {
  .stat-cards { grid-template-columns: 1fr; }
  .adm-topbar__link { display: none; }
}

/* ── FAB FLOTANTES ───────────────────────────────────────────── */
#adm-fabs {
  position: fixed;
  bottom: 24px;
  right: 20px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  z-index: 200;
}
.adm-fab {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 14px rgba(0,0,0,.30);
  transition: transform .2s ease, box-shadow .2s ease, opacity .2s ease, background .2s ease;
  background: var(--adm-red);
  color: #fff;
}
.adm-fab:hover {
  transform: translateY(-3px);
  box-shadow: 0 8px 20px rgba(0,0,0,.35);
}
.adm-fab svg {
  width: 22px;
  height: 22px;
}
/* Subir al inicio: oculto hasta hacer scroll */
#adm-fab-top {
  opacity: 0;
  pointer-events: none;
  transform: translateY(10px);
}
#adm-fab-top.visible {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0);
}
/* Menú flotante: solo en mobile */
#adm-fab-menu { display: none; }
#adm-fab-menu.adm-fab--menu-open { background: #4a0000; }
@media (max-width: 768px) {
  #adm-fab-menu { display: flex; }
}
