/* Admin panel styles */
:root {
  --ink: #0f172a;
  --muted: #475569;
  --bg: #f4f6fb;
  --card: #ffffff;
  --primary: #4f46e5;
  --primary-strong: #4338ca;
  --primary-soft: rgba(79, 70, 229, 0.12);
  --border: rgba(15, 23, 42, 0.08);
  --shadow: 0 16px 36px rgba(15, 23, 42, 0.08);
  --radius: 16px;
  --sidebar-width: 280px;
}

body.admin * {
  box-sizing: border-box;
}

body.admin {
  margin: 0;
  font-family: "Inter", "Segoe UI", system-ui, sans-serif;
  background: var(--bg);
  color: var(--ink);
  overflow-x: hidden;
  min-height: 100vh;
}

body.admin a {
  color: var(--primary);
  text-decoration: none;
}

.admin-shell {
  min-height: 100vh;
  display: flex;
  overflow-x: hidden;
}

/* ========== SIDEBAR ========== */
.admin-sidebar {
  width: var(--sidebar-width);
  background: #fff;
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  z-index: 1000;
  box-shadow: 2px 0 12px rgba(15, 23, 42, 0.05);
  transition: width 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.admin-sidebar.collapsed {
  width: 70px;
}

.sidebar-header {
  padding: 24px 20px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: relative;
}

.sidebar-logo {
  display: flex;
  align-items: center;
  gap: 12px;
  transition: gap 0.3s;
}

.admin-sidebar.collapsed .sidebar-logo {
  gap: 0;
}

.logo-icon {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  background: linear-gradient(135deg, #4f46e5, #38bdf8);
  display: grid;
  place-items: center;
  color: #fff;
  font-weight: 700;
  font-size: 20px;
  flex-shrink: 0;
}

.logo-text {
  transition: opacity 0.3s, width 0.3s;
  overflow: hidden;
}

.admin-sidebar.collapsed .logo-text {
  opacity: 0;
  width: 0;
}

.logo-text h1 {
  font-size: 18px;
  margin: 0;
  color: var(--ink);
  font-weight: 700;
  white-space: nowrap;
}

.logo-text p {
  font-size: 12px;
  margin: 2px 0 0;
  color: var(--muted);
  font-weight: 500;
  white-space: nowrap;
}

.sidebar-toggle {
  display: none;
  background: none;
  border: none;
  color: var(--muted);
  font-size: 20px;
  cursor: pointer;
  padding: 8px;
  border-radius: 8px;
  transition: all 0.2s;
}

.sidebar-toggle:hover {
  background: var(--primary-soft);
  color: var(--primary);
}

.sidebar-collapse-toggle {
  background: none;
  border: none;
  color: var(--muted);
  font-size: 16px;
  cursor: pointer;
  padding: 8px;
  border-radius: 8px;
  transition: all 0.3s;
  display: flex;
  align-items: center;
  justify-content: center;
}

.sidebar-collapse-toggle:hover {
  background: var(--primary-soft);
  color: var(--primary);
}

.sidebar-collapse-toggle i {
  transition: transform 0.3s;
}

.admin-sidebar.collapsed .sidebar-collapse-toggle i {
  transform: rotate(180deg);
}

.sidebar-nav {
  flex: 1;
  overflow-y: auto;
  padding: 12px 12px 24px;
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}

.sidebar-nav::-webkit-scrollbar {
  width: 6px;
}

.sidebar-nav::-webkit-scrollbar-track {
  background: transparent;
}

.sidebar-nav::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 3px;
}

.sidebar-nav::-webkit-scrollbar-thumb:hover {
  background: var(--muted);
}

.sidebar-link {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  color: var(--muted);
  font-weight: 500;
  font-size: 15px;
  border-radius: 10px;
  margin-bottom: 4px;
  transition: all 0.2s;
  position: relative;
}

.sidebar-link i {
  width: 20px;
  text-align: center;
  font-size: 16px;
  flex-shrink: 0;
}

.sidebar-link span {
  transition: opacity 0.3s;
  white-space: nowrap;
  overflow: hidden;
}

.admin-sidebar.collapsed .sidebar-link {
  justify-content: center;
  padding: 12px;
}

.admin-sidebar.collapsed .sidebar-link span {
  opacity: 0;
  width: 0;
}

.admin-sidebar.collapsed .sidebar-link {
  position: relative;
}

.admin-sidebar.collapsed .sidebar-link::after {
  content: attr(data-tooltip);
  position: absolute;
  left: 100%;
  top: 50%;
  transform: translateY(-50%);
  background: var(--ink);
  color: white;
  padding: 6px 12px;
  border-radius: 6px;
  font-size: 13px;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s;
  margin-left: 8px;
  z-index: 1001;
}

.admin-sidebar.collapsed .sidebar-link:hover::after {
  opacity: 1;
}


/* Forms full width (como Suscriptores) */
body.admin .admin-form-full{
  width: 100%;
  max-width: 100%;
  margin: 0 auto;
}

/* Modal ancho */
body.admin .modal-container.modal-lg{
  width: min(1100px, 92vw);
  max-width: 92vw;
}
.sidebar-link:hover {
  background: var(--primary-soft);
  color: var(--primary);
}

.sidebar-link.active {
  background: var(--primary);
  color: #fff;
  font-weight: 600;
  box-shadow: 0 4px 12px rgba(79, 70, 229, 0.25);
}

.sidebar-footer {
  border-top: 1px solid var(--border);
  padding: 16px;
}

.sidebar-user {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px;
  background: var(--bg);
  border-radius: 10px;
  margin-bottom: 12px;
  transition: all 0.3s;
}

.admin-sidebar.collapsed .sidebar-user {
  flex-direction: column;
  gap: 4px;
  padding: 8px;
}

.user-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: linear-gradient(135deg, #4f46e5, #38bdf8);
  color: #fff;
  display: grid;
  place-items: center;
  font-weight: 700;
  font-size: 16px;
  flex-shrink: 0;
}

.user-info {
  flex: 1;
  min-width: 0;
  transition: opacity 0.3s, width 0.3s;
}

.admin-sidebar.collapsed .user-info {
  opacity: 0;
  width: 0;
  overflow: hidden;
}

.user-name {
  font-size: 14px;
  font-weight: 600;
  color: var(--ink);
  margin-bottom: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.user-role {
  font-size: 12px;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sidebar-actions {
  display: flex;
  gap: 8px;
  transition: all 0.3s;
}

.admin-sidebar.collapsed .sidebar-actions {
  flex-direction: column;
  gap: 4px;
}

.sidebar-action {
  flex: 1;
  display: grid;
  place-items: center;
  padding: 10px;
  background: var(--bg);
  color: var(--muted);
  border-radius: 8px;
  font-size: 16px;
  transition: all 0.2s;
}

.admin-sidebar.collapsed .sidebar-action {
  padding: 8px;
  font-size: 14px;
}

.sidebar-action:hover {
  background: var(--primary-soft);
  color: var(--primary);
}

.sidebar-overlay {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 999;
  opacity: 0;
  transition: opacity 0.3s;
}

.sidebar-overlay.visible {
  display: block;
  opacity: 1;
}

/* Overlay para mobile */
.sidebar-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.5);
  z-index: 999;
  display: none;
}

/* Topbar mobile (solo visible en mobile) */
.admin-topbar-mobile {
  display: none;
}

/* ========== CONTENT AREA ========== */
.admin-content {
  margin-left: var(--sidebar-width);
  flex: 1;
  padding: 32px;
  max-width: calc(1400px + var(--sidebar-width));
  transition: margin-left 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.admin-sidebar.collapsed ~ .admin-content {
  margin-left: 70px;
  max-width: calc(1400px + 70px);
}

.admin-content > * {
  max-width: 1400px;
}


.admin-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

body.admin .btn {
  border: 1px solid transparent;
  padding: 10px 16px;
  border-radius: 999px;
  font-weight: 600;
  background: var(--primary);
  color: #fff;
  cursor: pointer;
  transition: transform 0.2s ease, box-shadow 0.2s ease, background 0.2s ease;
}

body.admin .btn:hover {
  background: var(--primary-strong);
  box-shadow: 0 12px 24px rgba(79, 70, 229, 0.2);
}

body.admin .btn.secondary {
  background: #fff;
  border-color: var(--border);
  color: var(--ink);
}

body.admin .btn.secondary:hover {
  background: #f8fafc;
  box-shadow: none;
}

body.admin .btn-refresh {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

body.admin .btn.link {
  background: transparent;
  border-color: transparent;
  color: var(--primary);
  padding: 8px 10px;
}


/* ========== RESPONSIVE: MOBILE ========== */
@media (max-width: 768px) {
  html, body {
    overflow-x: hidden;
    max-width: 100vw;
  }

  .admin-shell {
    overflow-x: hidden;
    max-width: 100vw;
    display: block !important;
  }

  /* Sidebar mobile: drawer oculto por defecto */
  .admin-sidebar {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    bottom: 0 !important;
    height: 100vh !important;
    transform: translateX(-100%) !important;
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1) !important;
    width: 280px !important;
    max-width: 85vw !important;
    z-index: 9999 !important;
    box-shadow: 4px 0 24px rgba(15, 23, 42, 0.15) !important;
  }

  .admin-sidebar.open {
    transform: translateX(0) !important;
  }

  .admin-sidebar.collapsed {
    transform: translateX(-100%) !important;
    width: 280px !important;
  }

  /* Overlay oscuro cuando el sidebar está abierto */
  .sidebar-overlay {
    display: block !important;
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.6);
    backdrop-filter: blur(2px);
    z-index: 9998;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
  }

  .sidebar-overlay.visible {
    opacity: 1;
    pointer-events: all;
  }

  /* Botón de cerrar en sidebar */
  .sidebar-toggle {
    display: flex !important;
    align-items: center;
    justify-content: center;
    background: none;
    border: none;
    color: var(--muted);
    font-size: 20px;
    cursor: pointer;
    padding: 8px;
    border-radius: 8px;
    transition: all 0.2s;
  }

  .sidebar-toggle:hover {
    background: var(--primary-soft);
    color: var(--primary);
  }

  /* Ocultar botón de colapsar en mobile */
  .sidebar-collapse-toggle {
    display: none !important;
  }

  /* Topbar mobile */
  .admin-topbar-mobile {
    display: flex !important;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    background: #fff;
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 999;
    box-shadow: 0 2px 8px rgba(15, 23, 42, 0.04);
  }

  .mobile-menu-toggle {
    background: none;
    border: none;
    color: var(--ink);
    font-size: 22px;
    cursor: pointer;
    padding: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-left: -8px;
    border-radius: 8px;
    transition: all 0.2s;
  }

  .mobile-menu-toggle:active {
    background: var(--primary-soft);
    color: var(--primary);
  }

  .mobile-title h1 {
    font-size: 16px;
    margin: 0;
    color: var(--ink);
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: calc(100vw - 120px);
  }

  .mobile-actions {
    display: flex;
    gap: 8px;
  }

  .mobile-logout {
    color: var(--muted);
    font-size: 20px;
    padding: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
    transition: all 0.2s;
  }

  .mobile-logout:active {
    background: var(--primary-soft);
    color: var(--primary);
  }

  /* Contenido principal en mobile */
  .admin-content {
    margin-left: 0 !important;
    padding: 16px !important;
    max-width: 100vw !important;
    width: 100% !important;
    overflow-x: hidden;
  }

  .admin-content > * {
    max-width: 100% !important;
  }

  /* Cards */
  .card {
    padding: 16px;
    border-radius: 12px;
    margin-bottom: 16px;
  }

  .card h2 {
    font-size: 18px;
    margin-bottom: 12px;
  }

  /* Admin toolbar responsive */
  body.admin .admin-toolbar {
    grid-template-columns: 1fr;
    gap: 12px;
    margin: 0 0 16px 0;
  }

  body.admin .admin-toolbar .btn {
    width: 100%;
    justify-content: center;
  }

  /* Tablas responsive con scroll horizontal */
  body.admin .table-responsive {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    margin: 0 -16px;
    padding: 0 16px;
    border-radius: 0;
  }

  body.admin table {
    font-size: 12px;
    min-width: 700px;
  }

  body.admin table th,
  body.admin table td {
    padding: 10px 8px;
    white-space: nowrap;
  }

  body.admin table th {
    font-size: 10px;
  }

  /* Botones de acción más pequeños en mobile */
  body.admin .action-btn-circle {
    width: 32px;
    height: 32px;
    font-size: 13px;
  }

  body.admin .action-buttons-horizontal {
    gap: 4px;
  }

  /* Formularios */
  body.admin .user-form-grid {
    grid-template-columns: 1fr;
    gap: 14px;
  }

  body.admin .form-group {
    margin-bottom: 14px;
  }

  body.admin .form-group label {
    font-size: 13px;
    margin-bottom: 6px;
  }

  body.admin .form-control {
    font-size: 15px;
    padding: 10px 12px;
  }

  /* Botones */
  body.admin .admin-actions {
    flex-direction: column;
    gap: 10px;
  }

  body.admin .admin-actions .btn {
    width: 100%;
    justify-content: center;
  }

  body.admin .btn {
    padding: 11px 16px;
    font-size: 14px;
  }

  /* Badges y estados */
  .badge {
    font-size: 11px;
    padding: 4px 8px;
  }

  /* Panel dashboard */
  .panel {
    padding: 16px;
    margin-bottom: 12px;
  }

  .panel h3 {
    font-size: 24px;
  }

  .panel .label {
    font-size: 12px;
  }

  /* Grid de panels */
  .panels {
    grid-template-columns: 1fr;
    gap: 12px;
  }

  /* Modales en mobile */
  .modal-content,
  .modal-container {
    width: calc(100vw - 24px);
    max-width: calc(100vw - 24px);
    margin: 12px;
    max-height: calc(100vh - 24px);
    border-radius: 12px;
  }

  .modal-header {
    padding: 16px;
  }

  .modal-header h3 {
    font-size: 18px;
  }

  .modal-body,
  .modal-container > form,
  .modal-container > div:not(.modal-header):not(.modal-footer) {
    padding: 16px;
    max-height: calc(100vh - 180px);
  }

  .modal-footer {
    padding: 12px 16px;
    flex-direction: column-reverse;
    gap: 8px;
  }

  .modal-footer .btn {
    width: 100%;
  }

  /* Filtros y búsqueda */
  body.admin .filters-panel {
    padding: 14px;
  }

  body.admin .search-box input {
    font-size: 15px;
  }

  /* Stats cards */
  body.admin .stats-grid {
    grid-template-columns: 1fr;
    gap: 12px;
  }

  /* Sidebar en estado abierto debe cubrir toda la pantalla */
  body.admin.sidebar-open {
    overflow: hidden;
  }

  /* Ajustes para página de inversores */
  body.admin .section-tabs {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    margin: 0 -16px 16px -16px;
    padding: 0 16px;
  }

  body.admin .section-tabs .tab-btn {
    font-size: 13px;
    padding: 10px 16px;
    white-space: nowrap;
  }

  /* Ajustes para filtros de consultas */
  body.admin .view-buttons {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
  }

  body.admin .view-btn {
    font-size: 13px;
    padding: 10px 12px;
    justify-content: center;
  }

  /* Resumen rápido en dashboard */
  body.admin .quick-summary {
    margin-bottom: 20px;
  }

  body.admin .quick-summary .card {
    padding: 14px;
  }

  /* Títulos de sección */
  body.admin h1 {
    font-size: 22px;
    margin-bottom: 16px;
  }

  body.admin h2 {
    font-size: 18px;
  }

  /* Alerts y mensajes */
  body.admin .alert {
    padding: 12px 14px;
    font-size: 14px;
    margin-bottom: 14px;
    border-radius: 8px;
  }

  /* Touch targets más grandes */
  body.admin button,
  body.admin a.btn,
  body.admin .action-btn-circle {
    min-height: 44px;
    min-width: 44px;
  }

  /* Mejor espaciado en listas */
  body.admin .user-list,
  body.admin .contact-list {
    margin: 0 -16px;
  }

  /* Scroll suave en tablas */
  body.admin .table-responsive::-webkit-scrollbar {
    height: 6px;
  }

  body.admin .table-responsive::-webkit-scrollbar-track {
    background: #f1f5f9;
    border-radius: 3px;
  }

  body.admin .table-responsive::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 3px;
  }

  /* Optimización de inputs en mobile */
  body.admin input[type="text"],
  body.admin input[type="email"],
  body.admin input[type="password"],
  body.admin input[type="tel"],
  body.admin textarea,
  body.admin select {
    font-size: 16px !important; /* Evita zoom en iOS */
  }

  /* Mejor usabilidad de checkboxes y radios en mobile */
  body.admin input[type="checkbox"],
  body.admin input[type="radio"] {
    min-width: 20px;
    min-height: 20px;
  }
}

@media (min-width: 769px) {
  .admin-topbar-mobile {
    display: none;
  }

  .sidebar-overlay {
    display: none;
  }

  .sidebar-toggle {
    display: none;
  }
}


.card {
  background: var(--card);
  border-radius: var(--radius);
  padding: 22px;
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
}

.card h2 {
  margin: 0 0 6px;
  font-size: 20px;
}

.muted {
  color: var(--muted);
  font-size: 14px;
  margin: 6px 0 0;
}

.grid {
  display: grid;
  gap: 16px;
}

.grid.two {
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
}

.grid.three {
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
}

.panel-link {
  text-decoration: none;
  display: block;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.panel-link:hover {
  transform: translateY(-4px);
}

.panel-link:hover .panel {
  box-shadow: 0 8px 20px rgba(79, 70, 229, 0.15);
  border-color: var(--primary);
  background: #fafbff;
}

.panel {
  padding: 16px;
  border-radius: 12px;
  border: 1px dashed var(--border);
  background: #f8fafc;
  transition: all 0.2s ease;
}

.panel .badge {
  display: inline-block;
  padding: 4px 10px;
  background: var(--primary-soft);
  color: var(--primary);
  font-size: 11px;
  font-weight: 600;
  border-radius: 6px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.panel h3 {
  font-size: 32px;
  font-weight: 700;
  color: var(--ink);
  margin: 12px 0 4px;
}

.panel .muted {
  font-size: 13px;
}

body.admin label {
  display: block;
  font-size: 13px;
  color: var(--muted);
  margin-top: 10px;
  margin-bottom: 6px;
}

body.admin input,
body.admin textarea,
body.admin select {
  width: 100%;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid #cbd5f5;
  background: #fff;
  font-size: 14px;
}

body.admin textarea {
  resize: vertical;
  min-height: 90px;
}

body.admin table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

body.admin th,
body.admin td {
  padding: 10px;
  border-bottom: 1px solid var(--border);
  text-align: left;
}

body.admin th {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
}

body.admin .user-dot {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 999px;
  margin-right: 8px;
  vertical-align: middle;
}

body.admin .user-dot.role-admin {
  background: #3b82f6;
}

body.admin .user-dot.role-user {
  background: #10b981;
}

body.admin .user-dot.role-editor {
  background: #f59e0b;
}

body.admin .user-table select,
body.admin .user-table input[type="password"] {
  min-width: 160px;
}

body.admin .inline-form {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

body.admin .btn.small {
  padding: 6px 12px;
  font-size: 12px;
}

body.admin .btn.info {
  background: #2563eb;
}

body.admin .btn.warning {
  background: #f59e0b;
  color: #111827;
}

body.admin .btn.danger {
  background: #ef4444;
}

body.admin .badge.status {
  background: #e2e8f0;
  color: #1f2937;
}

body.admin .badge.status.active {
  background: #dcfce7;
  color: #047857;
}

body.admin .badge.status.blocked {
  background: #fee2e2;
  color: #b91c1c;
}

/* ========================================
   GRILLA DE USUARIOS - ESTILO MODERNO CON CIRCULOS
   ======================================== */

/* Contenedor responsivo de la tabla */
body.admin .table-responsive {
  width: 100%;
  background: #fff;
  border-radius: 12px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
  border: 1px solid #e2e8f0;
}

/* Tabla principal de usuarios */
body.admin .users-grid-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 13px;
  table-layout: fixed;
}

/* Encabezado de la tabla */
body.admin .users-grid-table thead {
  background: #1e3a5f;
  background: linear-gradient(180deg, #2d5179 0%, #1e3a5f 100%);
  position: sticky;
  top: 0;
  z-index: 10;
}

body.admin .users-grid-table thead th {
  color: #ffffff;
  font-weight: 700;
  padding: 14px 16px;
  text-transform: uppercase;
  font-size: 11px;
  letter-spacing: 0.08em;
  border: none;
  text-align: left;
  white-space: nowrap;
  border-right: 1px solid rgba(255, 255, 255, 0.1);
}

body.admin .users-grid-table thead th:last-child {
  border-right: none;
}

body.admin .users-grid-table thead th.th-actions {
  width: 140px;
  text-align: left;
  padding-left: 12px;
}

body.admin .users-grid-table thead th.th-id {
  width: 50px;
}

body.admin .users-grid-table thead th.th-name {
  width: 140px;
}

body.admin .users-grid-table thead th.th-email {
  width: 180px;
}

body.admin .users-grid-table thead th.th-username {
  width: 100px;
}

body.admin .users-grid-table thead th.th-role {
  width: 100px;
}

body.admin .users-grid-table thead th.th-verification {
  width: 140px;
}

body.admin .users-grid-table thead th.th-status {
  width: 100px;
}

body.admin .users-grid-table thead th.th-last-login {
  width: 120px;
}

body.admin .users-grid-table thead th.th-created {
  width: 120px;
}

/* Tabla de consultas (contacts) - configuración base */
body.admin .contacts-grid-table {
  min-width: 0 !important;
  table-layout: fixed;
  width: 100%;
}

/* Tabla de consultas (contacts) - anchos específicos optimizados */
body.admin .contacts-grid-table thead th.th-actions {
  width: 125px;
  min-width: 125px;
  max-width: 125px;
  text-align: left;
  padding-left: 8px;
  padding-right: 4px;
}

body.admin .contacts-grid-table tbody td.td-actions {
  padding-left: 8px;
  padding-right: 4px;
}

body.admin .contacts-grid-table thead th.th-id {
  width: 40px;
  min-width: 40px;
}

body.admin .contacts-grid-table thead th.th-status {
  width: 95px;
  min-width: 95px;
}

body.admin .contacts-grid-table thead th.th-created {
  width: 105px;
  min-width: 105px;
}

body.admin .contacts-grid-table thead th:nth-child(3) { /* NOMBRE */
  width: 150px;
  max-width: 150px;
  min-width: 120px;
}

body.admin .contacts-grid-table thead th:nth-child(4) { /* EMAIL */
  width: 220px;
  max-width: 220px;
  min-width: 180px;
}

body.admin .contacts-grid-table thead th:nth-child(5) { /* EMPRESA */
  width: 130px;
  max-width: 130px;
  min-width: 100px;
}

body.admin .contacts-grid-table thead th:nth-child(6) { /* TELÉFONO */
  width: 115px;
  min-width: 110px;
}

body.admin .contacts-grid-table thead th:nth-child(7) { /* ORIGEN */
  width: 85px;
  min-width: 85px;
}

body.admin .contacts-grid-table thead th:nth-child(9) { /* IP */
  width: 95px;
  min-width: 95px;
}

body.admin .contacts-grid-table tbody td:nth-child(3),
body.admin .contacts-grid-table tbody td:nth-child(4),
body.admin .contacts-grid-table tbody td:nth-child(5) {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 0;
}

body.admin .users-grid-table tbody td {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

body.admin .users-grid-table tbody td.td-actions,
body.admin .users-grid-table tbody td.td-verification {
  overflow: visible;
  white-space: normal;
}

/* Filas del cuerpo de la tabla */
body.admin .users-grid-table tbody tr.user-row {
  transition: all 0.2s ease;
  border-bottom: 1px solid #e2e8f0;
}

body.admin .users-grid-table tbody tr.user-row:hover {
  background-color: #f7fafc;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
}

body.admin .users-grid-table tbody tr.user-row:last-child {
  border-bottom: none;
}

body.admin .users-grid-table tbody td {
  padding: 10px 16px;
  vertical-align: middle;
  border: none;
}

/* Columna de acciones con círculos de colores */
body.admin .users-grid-table .td-actions {
  padding: 8px 12px;
  text-align: left;
}

body.admin .action-circles {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 4px;
  flex-wrap: nowrap;
}

body.admin .inline-form-circle {
  margin: 0;
  padding: 0;
  display: inline-flex;
}

/* Botones circulares de colores */
body.admin .circle-btn {
  width: 18px;
  height: 18px;
  min-width: 18px;
  border-radius: 50%;
  border: none;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
  padding: 0;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
}

body.admin .circle-btn:hover {
  transform: scale(1.2);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.4);
}

body.admin .circle-btn:active {
  transform: scale(0.9);
}

/* Colores de los círculos */
body.admin .circle-orange {
  background: #ff6b35;
}

body.admin .circle-yellow {
  background: #ffc107;
}

body.admin .circle-green {
  background: #4caf50;
}

body.admin .circle-blue {
  background: #2196f3;
}

body.admin .circle-lightblue {
  background: #03a9f4;
}

body.admin .circle-purple {
  background: #9c27b0;
}

body.admin .circle-teal {
  background: #009688;
}

body.admin .circle-red {
  background: #f44336;
}

/* Columna ID */
body.admin .users-grid-table .td-id {
  font-weight: 600;
  color: #4a5568;
  font-size: 14px;
}

/* Columna Usuario */
body.admin .users-grid-table .td-username {
  font-size: 14px;
}

body.admin .users-grid-table .td-username strong {
  color: #1a202c;
  font-weight: 600;
}

/* Badges de Rol */
body.admin .role-badge {
  display: inline-block;
  padding: 6px 12px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  white-space: nowrap;
}

body.admin .role-badge.role-admin {
  background: #dbeafe;
  color: #1e40af;
}

body.admin .role-badge.role-user {
  background: #d1fae5;
  color: #065f46;
}

body.admin .role-badge.role-editor {
  background: #fef3c7;
  color: #92400e;
}

/* Badges de Estado */
body.admin .status-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  padding: 5px 10px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  white-space: nowrap;
  min-width: 105px;
}

body.admin .status-badge i {
  font-size: 11px;
}

body.admin .status-badge.status-active {
  background: #d1fae5;
  color: #065f46;
}

body.admin .status-badge.status-blocked {
  background: #fee2e2;
  color: #991b1b;
}

body.admin .status-badge.status-pending {
  min-width: auto;
}

/* Columna Fecha */
body.admin .users-grid-table .td-created {
  color: #718096;
  font-size: 12px;
  white-space: nowrap;
}

/* Mantener compatibilidad con estilos antiguos */
body.admin .action-stack {
  display: flex;
  align-items: center;
  gap: 8px;
}

body.admin .icon-btn {
  width: 34px;
  height: 34px;
  border-radius: 999px;
  border: 1px solid transparent;
  font-weight: 700;
  font-size: 12px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

body.admin .icon-btn.icon-edit {
  background: #dcfce7;
  color: #047857;
}

body.admin .icon-btn.icon-key {
  background: #dbeafe;
  color: #1d4ed8;
}

body.admin .icon-btn.icon-block {
  background: #fef3c7;
  color: #92400e;
}

body.admin .icon-btn.icon-delete {
  background: #fee2e2;
  color: #b91c1c;
}

body.admin .icon-btn:hover {
  filter: brightness(0.95);
}

/* Visualización de permisos en roles */
body.admin .permissions-summary {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 11px;
  line-height: 1.3;
  max-width: 100%;
}

/* Centrar contenido en tabla de roles */
body.admin .users-grid-table tbody td {
  vertical-align: middle;
}

body.admin .users-grid-table tbody td.td-actions {
  text-align: center;
}

body.admin .permission-item {
  display: block;
  white-space: normal;
  word-wrap: break-word;
}

body.admin .permission-item strong {
  color: #1e3a5f;
  font-weight: 600;
  font-size: 11px;
}

body.admin .permission-item span {
  color: #64748b;
  font-size: 11px;
}

body.admin .permission-item em {
  color: #065f46;
  font-style: normal;
  font-weight: 500;
  font-size: 11px;
}

body.admin .admin-toolbar {
  display: grid;
  grid-template-columns: 120px 1fr;
  align-items: center;
  gap: 12px;
  margin: 18px 0;
}

body.admin .admin-toolbar.admin-toolbar-sticky {
  position: relative;
  background: #f8fafc;
}

body.admin .admin-toolbar label {
  margin: 0;
}

body.admin .user-table {
  width: 100%;
}

body.admin .user-table th,
body.admin .user-table td {
  vertical-align: middle;
}

@media (max-width: 900px) {
  body.admin .admin-toolbar {
    grid-template-columns: 1fr;
  }

  body.admin .user-table {
    display: block;
    overflow-x: auto;
    white-space: nowrap;
  }
}

@media (max-width: 600px) {
  .admin-content {
    padding: 12px 10px;
  }

  .card {
    padding: 12px;
  }

  .card h2 {
    font-size: 16px;
  }
  
  /* Formularios SMTP y otros responsive */
  form[action*="test_smtp"] > div[style*="display: flex"],
  form[method="post"] > div[style*="display: flex"] {
    flex-direction: column !important;
    align-items: stretch !important;
    gap: 8px !important;
  }

  body.admin table {
    font-size: 12px;
  }

  body.admin table th,
  body.admin table td {
    padding: 8px 6px;
  }

  .panel h3 {
    font-size: 24px;
  }

  .mobile-title h1 {
    font-size: 14px;
  }
  
  form[action*="test_smtp"] button,
  form[method="post"] button.secondary {
    width: 100%;
    margin-top: 8px;
  }
}

body.admin .user-form-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 16px 20px;
  margin-bottom: 24px;
}

body.admin .user-form-field {
  display: flex;
  flex-direction: column;
}

body.admin .user-form-blocked {
  margin-top: 8px;
}

body.admin .user-form-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  justify-content: center;
  padding-top: 12px;
  border-top: 1px solid var(--border);
}

body.admin .user-form-checkbox {
  margin: 28px 0 0;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-size: 15px;
  font-weight: 600;
  color: #1f2937;
  cursor: pointer;
}

body.admin .user-form-checkbox input {
  width: 18px;
  height: 18px;
  cursor: pointer;
}

body.admin .password-field {
  position: relative;
  display: flex;
  align-items: center;
}

body.admin .password-field input {
  padding-right: 42px;
}

body.admin .btn-icon {
  position: absolute;
  right: 8px;
  border: none;
  background: transparent;
  color: var(--muted);
  width: 32px;
  height: 32px;
  border-radius: 8px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

body.admin .form-actions-center {
  justify-content: center;
}

body.admin .preview-center {
  display: flex;
  justify-content: center;
  margin-top: 12px;
}

body.admin .preview-center img {
  max-width: 320px;
}

@media (max-width: 720px) {
  body.admin .admin-toolbar.admin-toolbar-sticky {
    position: sticky;
    top: 12px;
    z-index: 30;
    background: #fff;
    box-shadow: 0 8px 18px rgba(15, 23, 42, 0.08);
    border-radius: 10px;
    padding: 12px;
  }

  body.admin .fab-new-user {
    display: inline-flex;
    align-items: center;
    justify-content: center;
  }

  body.admin .row-actions {
    flex-direction: column;
    align-items: stretch;
    gap: 6px;
  }

  body.admin .row-actions .btn {
    width: 100%;
  }

  body.admin .btn-new-user {
    display: none;
  }

  body.admin .btn-new-role {
    width: 100%;
  }

  body.admin .btn-refresh {
    padding: 8px 14px;
    font-size: 13px;
    gap: 8px;
    display: inline-flex;
    align-items: center;
  }

  body.admin .btn-refresh i {
    font-size: 14px;
  }

  /* HEADERS DE CARDS - LAYOUT UNIFICADO MOBILE */
  body.admin .user-card-header,
  body.admin .role-card-header,
  body.admin .admin-card-header {
    display: flex !important;
    justify-content: space-between;
    align-items: center !important; /* Fuerza centrado vertical - fix para roles */
    gap: 12px;
    min-height: 44px;
  }

  body.admin .user-card-header > div:first-child,
  body.admin .role-card-info,
  body.admin .admin-card-header > div:first-child {
    flex: 1;
    min-width: 0;
  }

  body.admin .user-card-id {
    display: block;
    margin-top: 2px;
    font-weight: 500;
    color: #94a3b8;
  }

  body.admin .user-card-meta {
    flex-direction: column;
    align-items: flex-start;
    gap: 6px;
  }

  body.admin .user-card-badges {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    justify-content: flex-start;
    width: 100%;
  }

  body.admin .user-card-date {
    font-size: 11px;
    color: #94a3b8;
    align-self: flex-start;
    text-align: left;
  }

  /* ACCIONES DE CARDS - ESTILO UNIFICADO MOBILE */
  /* Posición abajo de las cards para mobile (excepto email-templates) */
  body.admin .user-card-actions,
  body.admin .role-card-actions,
  body.admin .admin-card-actions {
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
    width: 100%;
    justify-content: flex-start;
    padding-top: 12px;
    margin-top: 12px;
    border-top: 1px solid #e5e7eb;
  }

  /* Excepción: Email templates mantienen acciones arriba a la derecha */
  body.admin .email-template-card .user-card-actions {
    width: auto;
    padding-top: 0;
    margin-top: 0;
    border-top: none;
  }

  body.admin .action-icon,
  body.admin .action-btn-circle {
    width: 36px;
    height: 36px;
    min-width: 36px;
    min-height: 36px;
    box-shadow: none;
    opacity: 0.85;
    flex-shrink: 0;
  }

  body.admin .action-icon.btn-edit {
    background: #bbf7d0;
    color: #047857;
    opacity: 1;
  }

  body.admin .action-icon.btn-delete {
    background: rgba(254, 226, 226, 0.6);
    color: #b91c1c;
    opacity: 0.9;
  }
}

/* ========================================
   TESTIMONIOS - GRILLA Y FORMULARIO
   ======================================== */

/* Grilla de testimonios */
body.admin .testimonials-grid-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 13px;
  min-width: 900px;
}

body.admin .testimonials-grid-table thead {
  background: #1e3a5f;
  background: linear-gradient(180deg, #2d5179 0%, #1e3a5f 100%);
  position: sticky;
  top: 0;
  z-index: 10;
}

body.admin .testimonials-grid-table thead th {
  color: #ffffff;
  font-weight: 700;
  padding: 14px 16px;
  text-transform: uppercase;
  font-size: 11px;
  letter-spacing: 0.08em;
  border: none;
  text-align: left;
  white-space: nowrap;
  border-right: 1px solid rgba(255, 255, 255, 0.1);
}

body.admin .testimonials-grid-table thead th:last-child {
  border-right: none;
}

body.admin .testimonials-grid-table thead th.th-actions {
  width: 200px;
  text-align: left;
  padding-left: 12px;
}

body.admin .testimonials-grid-table thead th.th-order {
  width: 80px;
}

body.admin .testimonials-grid-table thead th.th-company {
  width: 180px;
}

body.admin .testimonials-grid-table thead th.th-sector {
  width: 150px;
}

body.admin .testimonials-grid-table thead th.th-status {
  width: 120px;
}

body.admin .testimonials-grid-table tbody tr.testimonial-row {
  transition: all 0.2s ease;
  border-bottom: 1px solid #e2e8f0;
}

body.admin .testimonials-grid-table tbody tr.testimonial-row:hover {
  background-color: #f7fafc;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
}

body.admin .testimonials-grid-table tbody tr.testimonial-row:last-child {
  border-bottom: none;
}

body.admin .testimonials-grid-table tbody td {
  padding: 10px 16px;
  vertical-align: middle;
  border: none;
}

body.admin .testimonials-grid-table .td-actions {
  padding: 8px 12px;
  text-align: left;
}

body.admin .testimonials-grid-table .td-order {
  font-weight: 600;
  color: #4a5568;
  font-size: 14px;
}

body.admin .testimonials-grid-table .td-company strong {
  color: #1a202c;
  font-weight: 600;
  font-size: 14px;
}

body.admin .testimonials-grid-table .td-sector {
  color: #4a5568;
  font-size: 14px;
}

body.admin .testimonials-grid-table .td-quote {
  color: #718096;
  font-size: 13px;
  font-style: italic;
}

/* Formulario de testimonios */
body.admin .testimonial-form-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 16px 20px;
  margin-bottom: 24px;
}

body.admin .testimonial-form-field {
  display: flex;
  flex-direction: column;
}

body.admin .testimonial-form-full {
  grid-column: 1 / -1;
}

body.admin .testimonial-form-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  justify-content: center;
  padding-top: 12px;
  border-top: 1px solid var(--border);
}

@media (max-width: 720px) {
  body.admin .testimonial-form-grid {
    grid-template-columns: 1fr;
  }
  
  body.admin .testimonial-form-full {
    grid-column: 1;
  }
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 12px;
  background: var(--primary-soft);
  color: var(--primary);
  font-weight: 600;
}

.alert {
  padding: 12px 16px;
  border-radius: 12px;
  font-weight: 600;
}

.alert.success {
  background: #ecfdf3;
  color: #047857;
}

.alert.error {
  background: #fef2f2;
  color: #b91c1c;
}

.media-thumb {
  max-width: 100%;
  border-radius: 12px;
  border: 1px solid var(--border);
}

.row-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.login-card {
  width: min(420px, 92vw);
  margin: 80px auto;
}

.login-card h2 {
  margin-bottom: 8px;
}

.login-card .muted {
  margin-bottom: 32px;
}

.login-card form {
  display: flex;
  flex-direction: column;
}

.login-card form label {
  margin-top: 28px !important;
  margin-bottom: 10px !important;
  font-weight: 500;
}

.login-card form label:first-of-type {
  margin-top: 0 !important;
}

.login-card form input {
  margin: 0 !important;
}

.login-card .login-actions {
  display: flex;
  justify-content: center;
  margin-top: 32px;
}

body.admin .login-card form .btn {
  align-self: center;
  margin: 40px auto 0 !important;
  min-width: 160px;
}

@media (max-width: 720px) {
  .admin-topbar-inner {
    align-items: flex-start;
  }

  .admin-actions,
  .admin-meta {
    width: 100%;
    justify-content: space-between;
  }

  .btn {
    width: 100%;
  }
}

/* User actions: round colored buttons */
body.admin .action-buttons-horizontal {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: nowrap;
  white-space: nowrap;
}

body.admin .inline-action-form {
  margin: 0;
  padding: 0;
  display: inline-flex;
}

body.admin .action-btn-circle {
  width: 18px;
  height: 18px;
  min-width: 18px;
  border-radius: 50%;
  border: none;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
  padding: 0;
  font-size: 10px;
  line-height: 1;
  font-weight: 700;
  color: #0f172a;
  box-shadow: 0 1px 3px rgba(15, 23, 42, 0.2);
}

body.admin .action-btn-circle i {
  font-size: 10px;
  pointer-events: none;
}

body.admin .action-btn-circle:hover {
  transform: scale(1.2);
  box-shadow: 0 2px 6px rgba(15, 23, 42, 0.3);
}

body.admin .action-btn-circle.btn-edit {
  background: #34d399;
}

body.admin .action-btn-circle.btn-password {
  background: #93c5fd;
}

body.admin .action-btn-circle.btn-block {
  background: #fbbf24;
}

body.admin .action-btn-circle.btn-unlock {
  background: #a7f3d0;
}

body.admin .action-btn-circle.btn-delete {
  background: #fca5a5;
}

body.admin .action-btn-circle.btn-up {
  background: #93c5fd;
}

body.admin .action-btn-circle.btn-down {
  background: #60a5fa;
}

body.admin .action-btn-circle.btn-toggle {
  background: #e2e8f0;
}

body.admin .action-btn-circle.btn-reset {
  background: #fcd34d;
}

body.admin .gallery-grid-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 13px;
  min-width: 980px;
}

body.admin .gallery-grid-table thead {
  background: #1e3a5f;
  background: linear-gradient(180deg, #2d5179 0%, #1e3a5f 100%);
  position: sticky;
  top: 0;
  z-index: 10;
}

body.admin .gallery-grid-table thead th {
  color: #ffffff;
  font-weight: 700;
  padding: 14px 16px;
  text-transform: uppercase;
  font-size: 11px;
  letter-spacing: 0.08em;
  border: none;
  text-align: left;
  white-space: nowrap;
  border-right: 1px solid rgba(255, 255, 255, 0.1);
}

body.admin .gallery-grid-table thead th:last-child {
  border-right: none;
}

body.admin .gallery-grid-table thead th.th-actions {
  width: 220px;
  text-align: left;
  padding-left: 12px;
}

body.admin .gallery-grid-table thead th.th-order {
  width: 80px;
}

body.admin .gallery-grid-table thead th.th-status {
  width: 120px;
}

body.admin .gallery-grid-table thead th.th-preview {
  width: 140px;
}

body.admin .gallery-grid-table tbody tr {
  transition: all 0.2s ease;
  border-bottom: 1px solid #e2e8f0;
}

body.admin .gallery-grid-table tbody tr:hover {
  background-color: #f7fafc;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
}

body.admin .gallery-grid-table tbody tr:last-child {
  border-bottom: none;
}

body.admin .gallery-grid-table tbody td {
  padding: 10px 16px;
  vertical-align: middle;
  border: none;
}

body.admin .gallery-grid-table .td-actions {
  padding: 8px 12px;
  text-align: left;
}

body.admin .gallery-grid-table .td-order {
  font-weight: 600;
  color: #4a5568;
  font-size: 14px;
}

body.admin .gallery-grid-table .td-title {
  font-weight: 600;
  color: #1a202c;
  font-size: 14px;
}

body.admin .gallery-grid-table .td-caption {
  color: #4a5568;
  font-size: 14px;
}

body.admin .gallery-grid-table .td-preview img {
  width: 120px;
  height: auto;
  border-radius: 10px;
  border: 1px solid var(--border);
}

body.admin .preview-button {
  padding: 0;
  border: none;
  background: transparent;
  cursor: zoom-in;
}

body.admin .image-modal {
  position: fixed;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 999;
}

body.admin .image-modal.open {
  display: flex;
}

body.admin .image-modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(15, 23, 42, 0.6);
}

body.admin .image-modal-content {
  position: relative;
  background: #fff;
  border-radius: 16px;
  width: min(900px, 92vw);
  max-height: 90vh;
  overflow: auto;
  box-shadow: 0 30px 60px rgba(15, 23, 42, 0.25);
  padding: 20px;
}

body.admin .image-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
}

body.admin .image-modal-body img {
  width: 100%;
  height: auto;
  border-radius: 12px;
  border: 1px solid var(--border);
}

body.admin .gallery-grid-table .td-title {
  font-weight: 600;
}

body.admin .gallery-grid-table .td-caption {
  color: var(--muted);
}

body.admin .user-cards {
  display: none;
  gap: 14px;
}

body.admin .user-card {
  background: #fff;
  border-radius: 16px;
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  padding: 14px;
  display: grid;
  gap: 10px;
}

body.admin .user-card-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
}

body.admin .user-card-name {
  margin: 0 0 6px;
  font-size: 18px;
}

body.admin .user-card-id {
  font-size: 12px;
  color: var(--muted);
  font-weight: 600;
}

body.admin .user-card-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

body.admin .user-card-date {
  font-size: 12px;
  color: var(--muted);
}

body.admin .user-card-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

/* Role cards (mobile) */
body.admin .role-cards {
  display: none;
  gap: 14px;
}

body.admin .role-card {
  background: #fff;
  border-radius: 16px;
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  padding: 14px;
  display: grid;
  gap: 12px;
}

body.admin .role-card-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
}

body.admin .role-card-info {
  flex: 1;
}

body.admin .role-card-name {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 6px;
}

body.admin .role-card-name strong {
  font-size: 17px;
  color: var(--ink);
}

body.admin .role-card-id {
  font-size: 12px;
  color: var(--muted);
  font-weight: 600;
}

body.admin .role-card-type {
  margin-top: 4px;
}

body.admin .role-card-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

body.admin .role-card-permissions {
  padding-top: 10px;
  border-top: 1px solid var(--border);
}

body.admin .admin-cards {
  display: none;
  gap: 14px;
}

body.admin .admin-card {
  background: #fff;
  border-radius: 16px;
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  padding: 14px;
  display: grid;
  gap: 10px;
}

body.admin .admin-card-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
}

body.admin .admin-card-title {
  margin: 0 0 4px;
  font-size: 17px;
}

body.admin .admin-card-subtitle {
  margin: 0;
  font-size: 12px;
  color: var(--muted);
}

body.admin .admin-card-meta-text {
  font-size: 12px;
  color: var(--muted);
  font-weight: 600;
}

body.admin .admin-card-badges {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

body.admin .admin-card-body {
  margin: 0;
  font-size: 13px;
  color: #475569;
}

body.admin .admin-card-media {
  display: flex;
}

body.admin .admin-card-media .media-thumb {
  width: 100%;
  height: auto;
}

body.admin .admin-card-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

body.admin .action-icon {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  border: none;
  background: #f1f5f9;
  color: #0f172a;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
  box-shadow: 0 6px 14px rgba(15, 23, 42, 0.08);
}

body.admin .action-icon i {
  font-size: 14px;
}

body.admin .action-icon.btn-edit {
  background: #dcfce7;
  color: #047857;
}

body.admin .action-icon.btn-password {
  background: rgba(191, 219, 254, 0.7);
  color: #1d4ed8;
}

body.admin .action-icon.btn-block {
  background: rgba(254, 243, 199, 0.7);
  color: #92400e;
}

body.admin .action-icon.btn-unlock {
  background: rgba(220, 252, 231, 0.7);
  color: #047857;
}

body.admin .action-icon.btn-reset {
  background: rgba(252, 211, 77, 0.7);
  color: #713f12;
}

body.admin .action-icon.btn-delete {
  background: rgba(254, 226, 226, 0.75);
  color: #b91c1c;
}

body.admin .action-icon.btn-toggle {
  background: #e2e8f0;
  color: #0f172a;
}

body.admin .action-icon.btn-up {
  background: #e0f2fe;
  color: #0369a1;
}

body.admin .action-icon.btn-down {
  background: #dbeafe;
  color: #1d4ed8;
}

body.admin .action-icon:hover {
  transform: translateY(-1px);
  box-shadow: 0 10px 18px rgba(15, 23, 42, 0.12);
}

body.admin .fab-new-user {
  display: none;
  position: fixed;
  right: 18px;
  bottom: 20px;
  width: 52px;
  height: 52px;
  border-radius: 16px;
  border: none;
  background: linear-gradient(135deg, #4f46e5, #38bdf8);
  color: #fff;
  font-size: 18px;
  box-shadow: 0 12px 24px rgba(79, 70, 229, 0.3);
  cursor: pointer;
  z-index: 50;
}

@media (max-width: 720px) {
  /* ====================================================================
     MOBILE: 100% TARJETAS (CARDS) - NO GRILLAS/TABLAS
     Patrón: Usuarios (user-cards con acciones normalizadas)
     ==================================================================== */

  /* A) OCULTAR TODAS LAS TABLAS/GRILLAS EN MOBILE */
  body.admin .table-responsive {
    display: none !important;
  }

  /* Ocultar todas las tablas por clase específica también */
  body.admin table.users-grid-table,
  body.admin table.testimonials-grid-table,
  body.admin table.gallery-grid-table,
  body.admin table.contacts-grid-table,
  body.admin table {
    display: none !important;
  }

  /* B) MOSTRAR CARDS EN MOBILE (contenedores de tarjetas) */
  body.admin .user-cards,
  body.admin .role-cards,
  body.admin .admin-cards {
    display: grid !important;
    gap: 14px;
  }

  /* Cards ocupan 100% ancho, sin columnas */
  body.admin .user-card,
  body.admin .role-card,
  body.admin .admin-card {
    width: 100%;
    max-width: 100%;
  }

  /* C) NORMALIZAR BOTONES DE ACCIÓN EN CARDS (igual que Usuarios) */
  /* Contenedor de acciones: fila horizontal */
  body.admin .user-card-actions,
  body.admin .role-card-actions,
  body.admin .admin-card-actions {
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    justify-content: flex-start;
  }

  /* Botones de acción: tamaño fijo y uniforme */
  body.admin .action-btn-circle,
  body.admin .action-icon {
    width: 36px !important;
    height: 36px !important;
    min-width: 36px !important;
    min-height: 36px !important;
    max-width: 36px !important;
    max-height: 36px !important;
    border-radius: 10px;
    padding: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
  }

  body.admin .action-btn-circle i,
  body.admin .action-icon i {
    font-size: 14px;
  }

  /* Asegurar que forms inline no rompan el layout */
  body.admin .inline-action-form {
    margin: 0;
    padding: 0;
    display: inline-flex;
  }

  /* === SECCIONES SIN CARDS: Mostrar mensaje o crear cards === */
  /* Para subscribers, contacts, etc. que NO tienen cards HTML: */
  /* Opción 1: Tabla oculta (usuario debe crear cards) */
  /* Opción 2: Mostrar tabla como fallback (comentar líneas de arriba) */
  
  /* Si una sección no muestra nada, es porque le faltan cards.
     Copiar estructura de users.php para crear cards en esa sección. */

  body.admin .fab-new-user {
    display: inline-flex !important;
  }

  body.admin .admin-toolbar.admin-toolbar-sticky {
    position: sticky;
    top: 12px;
    z-index: 30;
    background: #fff;
    box-shadow: 0 8px 18px rgba(15, 23, 42, 0.08);
  }

  /* Tooltips accesibles en mobile: mostrar en focus y active */
  body.admin .action-icon[title]:focus::after,
  body.admin .action-icon[title]:active::after,
  body.admin .action-btn-circle[title]:focus::after,
  body.admin .action-btn-circle[title]:active::after,
  body.admin button[title]:focus::after,
  body.admin button[title]:active::after {
    content: attr(title);
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(15, 23, 42, 0.95);
    color: white;
    padding: 6px 10px;
    border-radius: 4px;
    font-size: 11px;
    white-space: nowrap;
    margin-bottom: 8px;
    z-index: 1000;
    pointer-events: none;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
  }

  /* Flecha del tooltip */
  body.admin .action-icon[title]:focus::before,
  body.admin .action-icon[title]:active::before,
  body.admin .action-btn-circle[title]:focus::before,
  body.admin .action-btn-circle[title]:active::before,
  body.admin button[title]:focus::before,
  body.admin button[title]:active::before {
    content: '';
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    border: 4px solid transparent;
    border-top-color: rgba(15, 23, 42, 0.95);
    margin-bottom: 0px;
    z-index: 1001;
    pointer-events: none;
  }

  /* Asegurar que botones sean focusables */
  body.admin .action-icon,
  body.admin .action-btn-circle {
    position: relative;
    outline: none;
  }

  body.admin .action-icon:focus,
  body.admin .action-btn-circle:focus {
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.3);
  }

  /* Eliminado: regla que impedía scroll horizontal de tablas */

  body.admin .btn-new {
    display: none !important;
  }

  /* Dashboard grid responsive en mobile */
  body.admin .card .panel {
    min-width: 160px;
  }

  /* Formularios más compactos en mobile */
  body.admin .settings-grid {
    grid-template-columns: 1fr !important;
  }

  body.admin label {
    font-size: 14px;
  }

  body.admin input[type="text"],
  body.admin input[type="email"],
  body.admin input[type="password"],
  body.admin input[type="number"],
  body.admin select,
  body.admin textarea {
    font-size: 16px; /* Evita zoom en iOS */
    padding: 10px 12px;
  }

  /* Botones full-width en mobile */
  body.admin .btn,
  body.admin .btn-primary,
  body.admin .btn-secondary {
    width: 100%;
    justify-content: center;
    padding: 12px 16px;
    font-size: 14px;
  }

  /* Modales full-screen en mobile */
  body.admin .modal-content {
    width: 95vw;
    max-width: 95vw;
    max-height: 90vh;
    overflow-y: auto;
    margin: 10px auto;
  }
  
  /* Suscriptores en modal más compactos en mobile */
  body.admin .subscriber-item {
    padding: 10px !important;
    flex-direction: row !important;
    gap: 8px !important;
  }
  
  body.admin .subscriber-item input[type="checkbox"] {
    width: 18px !important;
    height: 18px !important;
    flex-shrink: 0;
  }

  /* Prevenir overflow horizontal en tablas */
  body.admin .table-wrapper,
  body.admin .table-responsive {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    max-width: 100%;
  }

  /* Ajustar grid de dashboard */
  .admin-content > div[style*="grid"] {
    grid-template-columns: 1fr !important;
    gap: 12px;
  }
}

/* Estilos para lista de suscriptores en modal */
body.admin .subscriber-item:hover {
  background: #f3f4f6 !important;
  border-color: #d1d5db !important;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
}

body.admin .subscriber-item:has(input:checked) {
  background: #eff6ff !important;
  border-color: #667eea !important;
  box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

body.admin .subscriber-item input[type="checkbox"]:focus {
  outline: 2px solid #667eea;
  outline-offset: 2px;
}

/* ========== ORDENAMIENTO DE TABLAS ========== */
.sortable-header {
  cursor: pointer !important;
  user-select: none !important;
  transition: background-color 0.2s, color 0.2s;
}

.sortable-header:hover {
  background: var(--primary-soft) !important;
  color: var(--primary) !important;
}

.sortable-header:active {
  transform: scale(0.98);
}

.sort-indicators {
  display: inline-block;
  margin-left: 8px;
  font-size: 12px;
  font-weight: bold;
  color: var(--primary);
  transition: opacity 0.2s;
  vertical-align: middle;
}

/* ========== MODALES GLOBALES ========== */
/* Overlay con flexbox - Centrado real en viewport */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(15, 23, 42, 0.75);
  backdrop-filter: blur(6px);
  z-index: 10000;
  align-items: center;
  justify-content: center;
  padding: 20px;
  overflow-y: auto;
}

.modal-overlay.open,
.modal-overlay[style*="display: flex"],
.modal-overlay[style*="display: block"] {
  display: flex !important;
}

.modal-container {
  background: white;
  border-radius: 16px;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.25);
  max-width: 700px;
  width: 100%;
  max-height: calc(100vh - 80px);
  overflow-y: auto;
  position: relative;
  margin: auto;
  animation: modalFadeIn 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes modalFadeIn {
  from {
    opacity: 0;
    transform: scale(0.9);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 20px 24px;
  border-bottom: 1px solid #e5e7eb;
}

.modal-header h3 {
  margin: 0;
  font-size: 1.25rem;
  font-weight: 600;
}

.modal-close,
.btn-close-modal {
  background: none;
  border: none;
  font-size: 24px;
  cursor: pointer;
  color: #6b7280;
  padding: 0;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  transition: all 0.2s;
}

.modal-close:hover,
.btn-close-modal:hover {
  background: rgba(0,0,0,0.1);
  color: #111827;
  transform: rotate(90deg);
}

.modal-container > form,
.modal-container > div:not(.modal-header):not(.modal-footer) {
  padding: 24px;
}

.modal-footer {
  padding: 16px 24px;
  border-top: 1px solid #e5e7eb;
  display: flex;
  gap: 12px;
  justify-content: flex-end;
}

/* FIX: el modal NO debe heredar el max-width de .admin-content > * */
.admin-content > .modal-overlay {
  max-width: none !important;
  width: 100vw !important;
  margin: 0 !important;
}

/* aseguramos que el overlay cubra toda la pantalla */
.modal-overlay {
  position: fixed !important;
  inset: 0 !important;
}

/* ========== MOBILE FINAL OVERRIDES (MAX PRIORITY) ========== */
@media (max-width: 768px) {
  /* FIX CRÍTICO: Eliminar el margin-left que reserva espacio del sidebar */
  .admin-content {
    margin-left: 0 !important;
    padding: 16px !important;
    max-width: 100vw !important;
    width: 100% !important;
  }

  /* Asegurar que el sidebar colapsado tampoco afecte */
  .admin-sidebar.collapsed ~ .admin-content {
    margin-left: 0 !important;
    max-width: 100vw !important;
  }

  /* Eliminar scroll horizontal en toda la página */
  html,
  body {
    overflow-x: hidden !important;
    max-width: 100vw !important;
  }

  /* El shell no debe tener scroll horizontal */
  .admin-shell {
    overflow-x: hidden !important;
    max-width: 100vw !important;
  }

  /* Sidebar como drawer (oculto, no reserva espacio) */
  .admin-sidebar {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    bottom: 0 !important;
    transform: translateX(-100%) !important;
    width: 280px !important;
    max-width: 85vw !important;
    z-index: 9999 !important;
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1) !important;
  }

  /* Sidebar abierto */
  .admin-sidebar.open {
    transform: translateX(0) !important;
  }

  /* En mobile, collapsed no tiene sentido - siempre es drawer */
  .admin-sidebar.collapsed {
    transform: translateX(-100%) !important;
    width: 280px !important;
  }

  /* Topbar mobile siempre visible */
  .admin-topbar-mobile {
    display: flex !important;
  }

  /* Overlay del sidebar */
  .sidebar-overlay {
    display: block !important;
  }
}
