/* ===== LAYOUT RESPONSIVO MÓVIL ===== */

/* Aplicar variables de tema a elementos base */
* {
  transition: var(--mm-transition-fast);
}

body {
  background-color: var(--mm-bg);
  color: var(--mm-text);
  transition: background-color 0.3s ease, color 0.3s ease;
}

/* ===== HEADER RESPONSIVO ===== */
.header-responsive {
  background-color: var(--mm-surface);
  border-bottom: 1px solid var(--mm-border);
  box-shadow: var(--mm-shadow-sm);
  transition: var(--mm-transition);
}

/* ===== MENÚ HAMBURGUESA ===== */
.hamburger-menu {
  display: none;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  width: 44px;
  height: 44px;
  background: transparent;
  border: none;
  cursor: pointer;
  padding: 8px;
  border-radius: var(--mm-radius-sm);
  transition: var(--mm-transition);
  position: relative;
  z-index: 1001;
}

.hamburger-menu:hover {
  background-color: var(--mm-primary-light);
  transform: scale(1.05);
}

.hamburger-menu:focus {
  outline: 2px solid var(--mm-primary);
  outline-offset: 2px;
}

/* Líneas del hamburger */
.hamburger-line {
  width: 24px;
  height: 3px;
  background-color: var(--mm-text);
  border-radius: 2px;
  transition: all 0.3s cubic-bezier(0.68, -0.55, 0.265, 1.55);
  transform-origin: center;
}

.hamburger-line:not(:last-child) {
  margin-bottom: 4px;
}

/* Animación a X cuando está activo */
.hamburger-menu.active .hamburger-line:nth-child(1) {
  transform: rotate(45deg) translate(6px, 6px);
}

.hamburger-menu.active .hamburger-line:nth-child(2) {
  opacity: 0;
  transform: scale(0);
}

.hamburger-menu.active .hamburger-line:nth-child(3) {
  transform: rotate(-45deg) translate(6px, -6px);
}

/* Mantener el botón visible y accesible al abrir el menú */
/* Ocultar el botón hamburguesa cuando el menú está abierto */
.hamburger-menu.is-hidden { opacity: 0; pointer-events: none; }

/* ===== MENÚ MÓVIL DESPLEGABLE ===== */
.mobile-nav {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100vh;
  background-color: var(--mm-surface);
  z-index: 1000;
  transform: translateX(-100%);
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  overflow-y: auto;
  padding-top: 80px;
}

.mobile-nav.active {
  transform: translateX(0);
}

.mobile-nav-content {
  padding: 2rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
  max-width: 400px;
  margin: 0 auto;
}

.mobile-nav-item {
  display: flex;
  align-items: center;
  padding: 1rem;
  border-radius: var(--mm-radius);
  text-decoration: none;
  color: var(--mm-text);
  background-color: var(--mm-bg-soft);
  border: 1px solid var(--mm-border);
  transition: var(--mm-transition);
  font-weight: 500;
  box-shadow: var(--mm-shadow-sm);
}

.mobile-nav-item:hover {
  background-color: var(--mm-primary-light);
  border-color: var(--mm-primary);
  transform: translateY(-2px);
  box-shadow: var(--mm-shadow-md);
}

.mobile-nav-item.primary {
  background-color: var(--mm-primary);
  color: white;
  border-color: var(--mm-primary);
}

.mobile-nav-item.primary:hover {
  background-color: var(--mm-primary-hover);
  transform: translateY(-2px) scale(1.02);
}

.mobile-nav-item.danger {
  background-color: var(--mm-danger);
  color: white;
  border-color: var(--mm-danger);
}

.mobile-nav-item.danger:hover {
  background-color: var(--mm-danger-hover);
}

/* Toggle de tema eliminado */

/* ===== OVERLAY PARA MENÚ MÓVIL ===== */
.mobile-nav-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100vh;
  background-color: rgba(0, 0, 0, 0.5);
  z-index: 999;
  opacity: 0;
  visibility: hidden;
  transition: all 0.3s ease;
}

.mobile-nav-overlay.active {
  opacity: 1;
  visibility: visible;
}

/* ===== MEDIA QUERIES RESPONSIVAS ===== */

/* Tablets y móviles grandes */
@media (max-width: 1024px) {
  .desktop-nav {
    display: none;
  }
  
  .hamburger-menu {
    display: flex;
  }
  
  .theme-toggle {
    margin-left: auto;
    margin-right: 1rem;
  }
}

/* Móviles medianos */
@media (max-width: 768px) {
  .mobile-nav-content {
    padding: 1.5rem;
    gap: 0.75rem;
  }
  
  .mobile-nav-item {
    padding: 0.875rem;
    font-size: 0.95rem;
  }
  
  .header-responsive .container {
    padding-left: 1rem;
    padding-right: 1rem;
  }
}

/* Móviles pequeños */
@media (max-width: 480px) {
  .mobile-nav {
    padding-top: 70px;
  }
  
  .mobile-nav-content {
    padding: 1rem;
    gap: 0.5rem;
  }
  
  .mobile-nav-item {
    padding: 0.75rem;
    font-size: 0.9rem;
  }
  
  .hamburger-menu,
  .theme-toggle {
    width: 40px;
    height: 40px;
  }
  
  .hamburger-line {
    width: 20px;
    height: 2px;
  }
  
  .theme-icon {
    font-size: 1.1rem;
  }
}

/* ===== ANIMACIONES ADICIONALES ===== */
@keyframes slideInRight {
  from {
    transform: translateX(100%);
    opacity: 0;
  }
  to {
    transform: translateX(0);
    opacity: 1;
  }
}

@keyframes slideOutRight {
  from {
    transform: translateX(0);
    opacity: 1;
  }
  to {
    transform: translateX(100%);
    opacity: 0;
  }
}

@keyframes fadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

/* Animación para elementos que aparecen */
.animate-slide-in {
  animation: slideInRight 0.3s ease-out;
}

.animate-fade-in {
  animation: fadeIn 0.3s ease-out;
}

/* ===== MEJORAS DE ACCESIBILIDAD ===== */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* Focus visible para navegación por teclado */
.mobile-nav-item:focus-visible,
.theme-toggle:focus-visible,
.hamburger-menu:focus-visible {
  outline: 2px solid var(--mm-primary);
  outline-offset: 2px;
}

/* ===== ESTILOS PARA ELEMENTOS EXISTENTES ===== */
.mm-btn {
  background-color: var(--mm-surface);
  color: var(--mm-text);
  border: 1px solid var(--mm-border);
  transition: var(--mm-transition);
}

.mm-btn:hover {
  transform: translateY(-1px);
  box-shadow: var(--mm-shadow-md);
}

.mm-btn-primary {
  background-color: var(--mm-primary);
  color: white;
  border-color: var(--mm-primary);
}

.mm-btn-primary:hover {
  background-color: var(--mm-primary-hover);
}

.mm-btn-outline {
  background-color: transparent;
  color: var(--mm-primary);
  border-color: var(--mm-primary);
}

.mm-btn-outline:hover {
  background-color: var(--mm-primary);
  color: white;
}

.mm-btn-danger {
  background-color: var(--mm-danger);
  color: white;
  border-color: var(--mm-danger);
}

.mm-btn-danger:hover {
  background-color: var(--mm-danger-hover);
}

/* Footer responsivo */
footer {
  background-color: var(--mm-bg-soft);
  border-top: 1px solid var(--mm-border);
  color: var(--mm-text);
}

footer h3, footer h4, footer h5 {
  color: var(--mm-text);
}

footer a {
  color: var(--mm-text-secondary);
  transition: var(--mm-transition-fast);
}

footer a:hover {
  color: var(--mm-primary);
}
/* Botón de cierre dentro del menú móvil */
.mobile-nav-close {
  position: absolute;
  top: 16px;
  right: 16px;
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--mm-bg-soft);
  border: 1px solid var(--mm-border);
  border-radius: var(--mm-radius);
  cursor: pointer;
  color: var(--mm-text);
  font-size: 1.25rem;
  line-height: 1;
  z-index: 1001;
  transition: var(--mm-transition);
}

.mobile-nav-close:hover {
  background-color: var(--mm-primary-light);
  border-color: var(--mm-primary);
  transform: scale(1.05);
  box-shadow: var(--mm-shadow-md);
}

.mobile-nav-close:focus {
  outline: 2px solid var(--mm-primary);
  outline-offset: 2px;
}

/* ===== TABLAS RESPONSIVAS PARA ADMIN ===== */
/* Patrón mobile-first: en pantallas pequeñas, las filas se muestran como tarjetas */
@media (max-width: 768px) {
  table.responsive-table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
  }
  table.responsive-table thead {
    display: none;
  }
  table.responsive-table tbody tr {
    display: block;
    background: var(--mm-surface);
    border: 1px solid var(--mm-border);
    border-radius: var(--mm-radius);
    margin: 0 0 12px 0;
    box-shadow: var(--mm-shadow-sm);
    overflow: hidden;
  }
  table.responsive-table tbody td {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 12px 14px;
    border-bottom: 1px solid var(--mm-border);
    min-width: 0; /* importante para wrap dentro de flex */
    overflow-wrap: break-word;
    word-break: normal;
    white-space: normal;
  }
  table.responsive-table tbody tr td:last-child {
    border-bottom: none;
  }
  table.responsive-table tbody td::before {
    content: attr(data-label);
    font-weight: 600;
    color: var(--mm-text-secondary);
    margin-right: 8px;
    flex: 0 0 auto;
  }
  /* Grupo de botones de acciones: usar wrap y mejor toque */
  .admin-btn-group {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
  }
  .admin-btn-group .admin-btn-small {
    flex: 1 1 140px; /* se ajusta a 2-3 columnas dependiendo del ancho */
    min-width: 120px;
  }
}