/* --- 1. Variables Globales (Paleta de Colores) --- */
:root {
  /* Colores base para modos */
  --bg-light: #f8fafc;
  /* Gris muy claro (refinado) */
  --bg-dark: #0f172a;
  /* Azul oscuro elegante */
  --card-light: rgba(255, 255, 255, 0.8);
  /* Blanco para Glassmorphism */
  --card-dark: rgba(30, 41, 59, 0.7);
  /* Azul oscuro para Glassmorphism */
  --text-light: #f1f5f9;
  --text-dark: #1f2937;
  --border-light: rgba(255, 255, 255, 0.3);
  --border-dark: rgba(148, 163, 184, 0.2);

  /* Paleta de Acentos */
  --accent-blue: #4eafff;
  --accent-green: #43d39e;
  --accent-yellow: #ffd166;
  --accent-red: #ff6b6b;
  --accent-purple: #a78bfa;
  --accent-pink: #ff9ff3;
}

/* --- 2. Estilos Base y Layout Principal --- */
body,
html {
  margin: 0;
  padding: 0;
  height: 100%;
  overflow: hidden;
  /* Vital para el split screen */
  font-family: 'Inter', sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  transition: background 0.4s ease, color 0.4s ease;
}

/* Modo Claro (Por defecto) */
body {
  background: var(--bg-light);
  color: var(--text-dark);
}

/* Modo Oscuro (Activado por clase) */
body.dark-mode {
  background: var(--bg-dark);
  color: var(--text-light);
}

/* Contenedor Flex para la pantalla dividida */
.main-container {
  display: flex;
  width: 100%;
  height: 100vh;
}

/* --- 3. PANEL IZQUIERDO (Tu contenido principal) --- */
.panel-left {
  width: 100%;
  height: 100%;
  padding: 40px;
  /* Padding traído de tu body original */
  box-sizing: border-box;

  /* Comportamiento de layout de tu diseño */
  display: flex;
  flex-direction: column;
  align-items: center;
  overflow-y: auto;
  /* Scroll independiente */
  position: relative;
  /* Para posicionar botones absolutos */

  transition: width 0.4s cubic-bezier(0.25, 0.8, 0.25, 1), background-color 0.4s ease;
  will-change: width;
}

/* --- 4. PANEL DERECHO (Visor Iframe) --- */
.panel-right {
  width: 0%;
  background-color: white;
  transition: width 0.4s cubic-bezier(0.25, 0.8, 0.25, 1);
  will-change: width;
  position: relative;
  border-left: 1px solid var(--border-dark);
  overflow: hidden;
}

iframe {
  width: 100%;
  height: 100%;
  border: none;
  display: block;
}

/* --- 5. Lógica del Split (Pantalla Dividida) --- */
.split-mode .panel-left {
  width: 40%;
}

.split-mode .panel-right {
  width: 60%;
}

/* --- 6. Contenedores de Tarjetas (Grid) --- */
.container {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 28px;
  width: 100%;
  max-width: 1200px;
  margin-top: 20px;
  padding-bottom: 80px;
  /* Espacio extra al final */
}

/* --- 7. Tarjetas (Sections) con Glassmorphism --- */
section {
  backdrop-filter: blur(12px);
  border-radius: 20px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  align-items: center;
  text-align: center;
  padding: 30px 20px;
  min-height: 100px;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.08);
  transition: transform 0.25s ease, box-shadow 0.25s ease, border-color 0.25s ease;
  animation: fadeInUp 0.7s ease;
}

/* Bordes de colores */
section:nth-child(1) {
  border-top: 4px solid var(--accent-blue);
}

section:nth-child(2) {
  border-top: 4px solid var(--accent-red);
}

section:nth-child(3) {
  border-top: 4px solid var(--accent-yellow);
}

section:nth-child(4) {
  border-top: 4px solid var(--accent-green);
}

section:nth-child(5) {
  border-top: 4px solid var(--accent-purple);
}

section:nth-child(6) {
  border-top: 4px solid var(--accent-pink);
}

section:hover {
  transform: translateY(-6px);
  box-shadow: 0 12px 25px rgba(0, 0, 0, 0.18);
}

/* Estilos Light/Dark para Cards */
body:not(.dark-mode) section {
  background: var(--card-light);
  border: 1px solid var(--border-light);
}

body.dark-mode section {
  background: var(--card-dark);
  border: 1px solid var(--border-dark);
}

/* --- 8. Tipografía --- */
#h12 {
  font-size: 2.5rem;
  font-weight: 800;
  color: var(--accent-blue);
  text-align: center;
  margin-bottom: 40px;
  letter-spacing: -0.5px;
  animation: popIn 0.8s ease-out;
}

h2,
h3,
h4,
h5 {
  margin: 0 0 18px;
  color: inherit;
}

h3 {
  font-size: 33px;
  font-weight: 700;
  line-height: 1.3;
}

h4 {
  font-size: 27px;
  font-weight: 700;
  line-height: 1.3;
}

/* --- 9. Botones --- */
.buttons {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 10px;
  /* Aumentado gap para evitar superposición */
  margin-top: auto;
  margin-bottom: 0;
  width: 100%;
}

.buttons a {
  background: var(--accent-blue);
  color: #fff;
  padding: 10px 18px;
  border-radius: 10px;
  font-size: 0.9rem;
  font-weight: 600;
  text-decoration: none;
  transition: background 0.3s ease, transform 0.2s ease, padding 0.3s ease;
  cursor: pointer;
  display: inline-block;
  margin-bottom: 5px;
  /* Margen de seguridad vertical */
}

.buttons a:hover {
  background: #2563eb;
  transform: translateY(-2px);
}

/* --- NUEVO: Ajustes Inteligentes para Modo Split --- */
/* Estos estilos SOLO aplican cuando la pantalla está dividida */

/* 1. Forzar una sola columna centrada para las tarjetas */
.split-mode .container {
  grid-template-columns: 1fr;
  max-width: 500px;
  /* Evita que se estiren demasiado */
  padding-left: 10px;
  padding-right: 10px;
}

/* 2. Reducir padding de las tarjetas */
.split-mode section {
  padding: 20px 10px;
  min-height: auto;
  /* Dejar que la altura se ajuste al contenido */
}

/* 3. Botones más compactos */
.split-mode .buttons {
  gap: 6px;
  /* Menos espacio entre botones */
}

.split-mode .buttons a {
  padding: 8px 12px;
  /* Botones más pequeños */
  font-size: 0.85rem;
  /* Letra un poco más chica */
}

/* 4. Títulos más pequeños */
.split-mode h3 {
  font-size: 24px;
  margin-bottom: 15px;
}

.split-mode h4 {
  font-size: 20px;
  margin-bottom: 15px;
}

.split-mode #h12 {
  font-size: 2rem;
  margin-bottom: 30px;
}


/* Botones Flotantes (Top) */
.btn {
  display: inline-block;
  font-weight: 600;
  text-align: center;
  border: none;
  padding: 8px 16px;
  font-size: 0.9rem;
  border-radius: 10px;
  transition: all 0.3s ease;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.1);
  text-decoration: none;
  cursor: pointer;
}

.btn-warning {
  background: #facc15;
  color: #111;
}

.btn-warning:hover {
  background: #eab308;
  transform: scale(1.05);
}

.btn-secondary {
  background: #475569;
  color: #fff;
}

.btn-secondary:hover {
  background: #334155;
  transform: scale(1.05);
}

.btn-danger {
  background: var(--accent-red);
  color: white;
}

.btn-danger:hover {
  background: #e63946;
  transform: scale(1.05);
}

.ko {
  background: #dc3545 !important;
  color: #ffffff !important;
}

/* Posicionamiento Absoluto dentro del Panel Izquierdo */
.theme-toggle {
  position: absolute;
  top: 20px;
  right: 20px;
}

.logout1 {
  position: absolute;
  top: 67px;
  right: 20px;
}

.sops-link {
  position: absolute;
  top: 20px;
  left: 20px;
}

.cash-link {
  position: absolute;
  top: 75px;
  left: 20px;
}

/* Botón Dark Mode específico */
body.dark-mode .theme-toggle button {
  background: linear-gradient(180deg, #0f172a 0%, #1e293b 100%);
  color: #fff;
  border: 1px solid var(--border-dark);
}

/* --- 10. Badges (Insignias) --- */
.badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  position: absolute;
  top: -12px;
  right: -12px;
  z-index: 10;
  background: linear-gradient(135deg, #ff6f61 0%, #de483c 100%);
  color: #ffffff;
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  padding: 0.4em 0.8em;
  border-radius: 8px;
  min-width: 45px;
  box-shadow: 0 6px 15px rgba(255, 111, 97, 0.3), 0 2px 4px rgba(0, 0, 0, 0.1);
  transition: all 0.3s ease-in-out;
}

.badge:hover {
  transform: translateY(-2px) scale(1.03);
  box-shadow: 0 8px 20px rgba(255, 111, 97, 0.4), 0 3px 6px rgba(0, 0, 0, 0.15);
}

.badge.pulsing {
  animation: pulseBadge 2s infinite ease-in-out;
}

/* --- 11. Burbuja Flotante --- */
#burbuja-flotante {
  position: fixed;
  /* Fixed para que flote sobre todo */
  bottom: 25px;
  left: 25px;
  /* Cambiado a izquierda para no tapar el iframe cuando se abre */
  z-index: 999;
  background-color: var(--accent-blue);
  color: white;
  padding: 12px 20px;
  border-radius: 50px;
  font-weight: bold;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.2);
  transition: opacity 0.3s ease;
  cursor: pointer;
}

#burbuja-flotante:hover {
  opacity: 0;
}

/* --- 12. Elementos del Visor (Cerrar / Loader) --- */
.close-btn {
  position: absolute;
  top: 15px;
  left: 15px;
  background-color: var(--accent-blue);
  color: white;
  border: none;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  font-weight: bold;
  cursor: pointer;
  z-index: 100;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.2);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
}

.close-btn:hover {
  background-color: #ff6b81;
  transform: scale(1.1);
}

#loader {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-size: 20px;
  color: var(--text-dark);
  display: none;
}

/* --- Animaciones --- */
@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(20px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes popIn {
  0% {
    transform: scale(0.9);
    opacity: 0;
  }

  100% {
    transform: scale(1);
    opacity: 1;
  }
}

@keyframes pulseBadge {
  0% {
    transform: scale(1);
    opacity: 1;
  }

  50% {
    transform: scale(1.02);
    opacity: 0.95;
  }

  100% {
    transform: scale(1);
    opacity: 1;
  }
}

/* NUEVO: Botón Ayuda Pequeño (22px = mitad de 44px) */
.help-btn {
  position: absolute;
  top: 26px;
  /* Ajustado para centrar verticalmente respecto a los grandes */
  left: 70px;
  background-color: var(--accent-purple);
  color: white;
  border: none;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  font-weight: bold;
  cursor: pointer;
  z-index: 100;
  box-shadow: 0 2px 8px rgba(139, 92, 246, 0.4);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
}

.help-btn:hover {
  transform: scale(1.1);
  transition: transform 0.3s ease;
  background-color: #7c3aed;
}

/* --- Estilos del Modal (Alert con Imagen) --- */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.6);
  z-index: 2000;
  display: none;
  /* Oculto por defecto */
  align-items: center;
  justify-content: center;
  backdrop-filter: blur(4px);
  animation: fadeIn 0.2s ease;
}

.modal-content {
  background: white;
  padding: 25px;
  border-radius: 15px;
  max-width: 90%;
  width: 450px;
  text-align: center;
  position: relative;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.3);
  border: 1px solid rgba(0, 0, 0, 0.1);
}

body.dark-mode .modal-content {
  background: #1e293b;
  color: #e2e8f0;
  border: 1px solid rgba(255, 255, 255, 0.1);
}

.modal-img-container {
  width: 100%;
  height: 200px;
  /* Altura fija o auto según prefieras */
  background-color: #f1f5f9;
  border-radius: 8px;
  margin-bottom: 15px;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

body.dark-mode .modal-img-container {
  background-color: #0f172a;
}

.modal-img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
}

.modal-text {
  font-size: 1rem;
  line-height: 1.5;
  color: #334155;
  font-weight: 500;
}

body.dark-mode .modal-text {
  color: #cbd5e1;
}

.modal-close-icon {
  position: absolute;
  top: 10px;
  right: 15px;
  font-size: 24px;
  cursor: pointer;
  color: #94a3b8;
  transition: color 0.2s;
}

.modal-close-icon:hover {
  color: var(--accent-red);
}