/* =====================================================
   EDITOR DE IMÁGENES - DISEÑO MODERNO Y PROFESIONAL
   ===================================================== */

:root {
  --primary: 147 197 253; /* pastel sky */
  --primary-dark: 165 180 252; /* pastel indigo */
  --secondary: 45 55 72; /* slate */
  --success: 187 247 208; /* green-200 */
  --danger: 254 202 202; /* red-200 */
  --warning: 253 230 138; /* amber-200 */
  --surface: 255 255 255;
  --surface-dark: 246 248 252;
  --border: 229 231 235;
  --border-dark: 203 213 225;
  --text: 15 23 42;
  --text-muted: 71 85 105;
  --shadow: 0 4px 10px -4px rgb(15 23 42 / 0.06), 0 2px 6px -2px rgb(15 23 42 / 0.04);
  --shadow-lg: 0 12px 20px -6px rgb(15 23 42 / 0.08), 0 6px 10px -4px rgb(15 23 42 / 0.06);
  --gradient-primary: linear-gradient(135deg, rgb(196 181 253) 0%, rgb(147 197 253) 100%);
  --ring: 0 0 0 3px rgb(147 197 253 / 0.35);
}

* {
  box-sizing: border-box;
}

/* ================= LAYOUT BASE ================= */
html { scroll-behavior: smooth; }
body { 
  font-family: 'Inter', ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
  line-height: 1.6;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* ================= HEADER MODERNO ================= */
.logo-container {
  position: relative;
  padding: 6px;
  border-radius: 10px;
  background: linear-gradient(135deg, rgba(147,197,253,0.12), rgba(196,181,253,0.12));
}

.app-logo {
  width: 180px;
  height: auto;
  border-radius: 8px;
  object-fit: contain;
  filter: drop-shadow(0 2px 4px rgba(0,0,0,0.1));
}

@media (max-width: 640px) {
  .app-logo { width: 120px; height: auto; }
}

/* ================= SISTEMA DE BOTONES MODERNO ================= */
.btn-modern {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.625rem 1rem;
  font-weight: 500;
  font-size: 0.875rem;
  border-radius: 0.75rem;
  border: 1px solid transparent;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  cursor: pointer;
  white-space: nowrap;
  outline: none;
  position: relative;
  overflow: hidden;
}

.btn-modern::before {
  content: '';
  position: absolute;
  inset: 0;
  opacity: 0;
  background: linear-gradient(135deg, rgba(255,255,255,0.2), rgba(255,255,255,0.1));
  transition: opacity 0.2s;
}

.btn-modern:hover::before { opacity: 1; }

.btn-modern:focus-visible {
  box-shadow: var(--ring);
}

.btn-modern:active {
  transform: translateY(1px) scale(0.98);
}

/* Variantes de botones */
.btn-primary {
  background: var(--gradient-primary);
  color: white;
  box-shadow: var(--shadow);
}

.btn-secondary {
  background: rgba(107, 114, 128, 0.1);
  color: rgb(75, 85, 99);
  border: 1px solid rgba(107, 114, 128, 0.2);
}

.btn-secondary:hover {
  background: rgba(107, 114, 128, 0.15);
  border-color: rgba(107, 114, 128, 0.3);
}

.btn-primary:hover {
  background: linear-gradient(135deg, rgb(165 180 252) 0%, rgb(129 140 248) 100%);
  box-shadow: var(--shadow-lg);
}

.btn-ghost {
  background: rgba(var(--primary), 0.06);
  color: rgb(var(--text));
  border-color: rgba(var(--primary), 0.18);
}

.btn-ghost:hover {
  background: rgba(var(--primary), 0.12);
  color: rgb(var(--primary));
  border-color: rgba(var(--primary), 0.28);
}

.btn-danger {
  background: linear-gradient(135deg, rgb(254 202 202) 0%, rgb(252 165 165) 100%);
  color: rgb(127 29 29);
}

.btn-danger:hover {
  background: linear-gradient(135deg, rgb(252 165 165) 0%, rgb(248 113 113) 100%);
  color: rgb(127 29 29);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(248, 113, 113, 0.4);
}

.btn-sm {
  padding: 0.5rem 0.75rem;
  font-size: 0.8rem;
}

.btn-xs {
  padding: 0.25rem 0.5rem;
  font-size: 0.75rem;
  min-width: 28px;
  height: 28px;
}

/* ================= TOGGLE SWITCH ELEGANTE ================= */
.toggle-switch {
  position: relative;
  display: inline-block;
  width: 48px;
  height: 24px;
  cursor: pointer;
}

.toggle-slider {
  position: absolute;
  inset: 0;
  background: rgb(var(--border));
  border-radius: 24px;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.toggle-slider::before {
  content: '';
  position: absolute;
  height: 18px;
  width: 18px;
  left: 3px;
  bottom: 3px;
  background: white;
  border-radius: 50%;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: 0 2px 4px rgba(0,0,0,0.2);
}

.toggle-switch input:checked + .toggle-slider {
  background: rgb(var(--primary));
}

.toggle-switch input:checked + .toggle-slider::before {
  transform: translateX(24px);
}

/* ================= SISTEMA DE TARJETAS MODERNO ================= */
.card-modern {
  background: rgba(var(--surface), 0.98);
  backdrop-filter: blur(6px);
  border: 1px solid rgba(var(--border), 0.4);
  border-radius: 1rem;
  box-shadow: var(--shadow);
  overflow: hidden;
  transition: box-shadow 0.25s ease, transform 0.25s ease, border-color 0.25s ease;
  margin: 12px;
}

.card-modern:hover {
  box-shadow: var(--shadow-lg);
  transform: translateY(-1px);
  border-color: rgba(var(--primary), 0.35);
}

.card-header {
  padding: 1rem 1.75rem 0.75rem;
  border-bottom: 1px solid rgba(var(--border), 0.3);
}

.card-title {
  font-size: 1.25rem;
  font-weight: 700;
  color: rgb(var(--text));
  margin: 0;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.card-content {
  padding: 1.25rem 1.75rem 1.5rem;
}

/* ================= DROPZONE ESPECTACULAR ================= */
.dropzone-modern {
  position: relative;
  border: 2px dashed rgba(var(--border), 0.6);
  border-radius: 1rem;
  padding: 2rem;
  text-align: center;
  background: linear-gradient(135deg, rgba(147,197,253,0.12), rgba(196,181,253,0.12));
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  cursor: pointer;
  min-height: 160px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.dropzone-modern::before {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: linear-gradient(135deg, rgba(147,197,253,0.18), rgba(196,181,253,0.18));
  opacity: 0;
  transition: opacity 0.3s;
}

.dropzone-modern:hover::before {
  opacity: 1;
}

.dropzone-modern.dragover {
  border-color: rgb(var(--primary));
  background: linear-gradient(135deg, rgba(147,197,253,0.2), rgba(196,181,253,0.2));
  transform: scale(1.02);
  box-shadow: 0 0 0 4px rgba(var(--primary), 0.1);
}

.dropzone-content {
  position: relative;
  z-index: 1;
  pointer-events: none;
}

.dropzone-icon {
  font-size: 2.5rem;
  margin-bottom: 0.75rem;
  opacity: 0.7;
}

.dropzone-title {
  font-size: 1.125rem;
  font-weight: 600;
  color: rgb(var(--text));
  margin-bottom: 0.25rem;
}

.dropzone-subtitle {
  font-size: 0.875rem;
  color: rgb(var(--text-muted));
  margin-bottom: 0.75rem;
}

.dropzone-formats {
  font-size: 0.75rem;
  color: rgb(var(--text-muted));
  background: rgba(var(--border), 0.3);
  padding: 0.25rem 0.75rem;
  border-radius: 2rem;
  display: inline-block;
}

.file-input {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  cursor: pointer;
}

/* ================= GALERÍA PROFESIONAL ================= */
.gallery-controls {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1rem;
  flex-wrap: wrap;
}

.control-group {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.gallery-counter {
  font-size: 0.875rem;
  font-weight: 500;
  color: rgb(var(--text-muted));
  padding: 0.5rem 1rem;
  background: rgba(var(--primary), 0.08);
  border: 1px solid rgba(var(--primary), 0.18);
  border-radius: 2rem;
}

.toggle-option {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  cursor: pointer;
}

.toggle-option-text {
  font-size: 0.875rem;
  color: rgb(var(--text-muted));
  transition: color 0.2s;
}

.toggle-option:hover .toggle-option-text {
  color: rgb(var(--primary));
}

.summary-bar {
  font-size: 0.75rem;
  color: rgb(var(--text-muted));
  background: linear-gradient(135deg, rgba(147,197,253,0.1), rgba(196,181,253,0.1));
  padding: 0.75rem 1rem;
  border-radius: 0.75rem;
  border: 1px solid rgba(var(--primary), 0.18);
  margin-bottom: 1.5rem;
  font-family: 'JetBrains Mono', 'Fira Code', monospace;
}

.gallery-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 1rem;
  margin-bottom: 1.5rem;
}

@media (min-width: 768px) {
  .gallery-grid {
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  }
}

.gallery-tip {
  font-size: 0.8rem;
  color: rgb(var(--text-muted));
  background: rgba(var(--warning), 0.12);
  border: 1px solid rgba(var(--warning), 0.25);
  padding: 0.75rem 1rem;
  border-radius: 0.75rem;
  line-height: 1.5;
  font-weight: 500;
}

.gallery-export-buttons {
  margin-top: 1rem;
  padding: 1rem;
  background: rgba(var(--surface), 0.98);
  border: 1px solid rgba(var(--border), 0.3);
  border-radius: 0.75rem;
  backdrop-filter: blur(4px);
}

.gallery-export-buttons .flex {
  justify-content: center;
  align-items: center;
}

@media (max-width: 640px) {
  .gallery-export-buttons .flex {
    flex-direction: column;
    gap: 0.75rem !important;
  }
  
  .gallery-export-buttons .btn-modern {
    width: 100%;
    justify-content: center;
  }
}

/* ================= MINIATURAS MEJORADAS ================= */
.thumb {
  position: relative;
  background: rgba(var(--surface), 0.98);
  border: 1px solid rgba(var(--border), 0.9);
  border-radius: 1rem;
  overflow: hidden;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  backdrop-filter: blur(4px);
  user-select: none;
}

.thumb:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow-lg);
  border-color: rgba(var(--primary), 0.3);
}

.thumb canvas {
  display: block;
  width: 100%;
  height: auto;
  border-radius: 0.75rem 0.75rem 0 0;
}

.thumb .meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 0.75rem;
  font-size: 0.75rem;
  background: rgba(var(--surface), 0.98);
  backdrop-filter: blur(8px);
}

/* ================= CHECKERBOARD MEJORADO ================= */
.checker {
  background-image: linear-gradient(45deg, rgba(0,0,0,0.1) 25%, transparent 25%),
                    linear-gradient(-45deg, rgba(0,0,0,0.1) 25%, transparent 25%),
                    linear-gradient(45deg, transparent 75%, rgba(0,0,0,0.1) 75%),
                    linear-gradient(-45deg, transparent 75%, rgba(0,0,0,0.1) 75%);
  background-size: 20px 20px;
  background-position: 0 0, 0 10px, 10px -10px, -10px 0px;
}

/* ================= SIDEBAR MÓVIL MEJORADO ================= */
.mobile-sidebar {
  position: relative;
}

@media (max-width: 1023px) {
  .mobile-sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: 90%;
    max-width: 380px;
    background: rgba(var(--surface), 0.95);
    backdrop-filter: blur(16px);
    padding: 1rem;
    overflow-y: auto;
    transform: translateX(-105%);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 50;
    border-right: 1px solid rgba(var(--border), 0.5);
  }
  
  .mobile-sidebar.open { 
    transform: translateX(0%); 
  }
  
  .sidebar-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
    z-index: 40;
    backdrop-filter: blur(2px);
  }
  
  .sidebar-backdrop.show { 
    opacity: 1; 
    pointer-events: auto; 
  }
}

/* ================= NUEVO LAYOUT HORIZONTAL ================= */

/* Sección superior: Cargar + Galería lado a lado (OPTIMIZADO) */
.top-section {
    display: grid;
  grid-template-columns: 1fr 2fr;
    gap: 1.5rem;
  margin-bottom: 2rem;
  align-items: start;
}

.upload-section {
  min-height: 400px;
}

/* Nota: adjustments-section se movió abajo del grid, reglas específicas removidas */

.gallery-section {
  min-height: 400px;
}

/* Desktop Grid 2x2 + Tarjeta 6 - Ancho completo */
.desktop-grid-2x2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  grid-template-rows: auto auto auto;
  gap: 1.5rem;
  width: 100%;
  margin-bottom: 2rem;
}

.grid-card {
  width: 100%;
}

.grid-card .card {
  transition: all 0.3s ease;
  box-shadow: 0 2px 8px rgba(0,0,0,0.1);
  height: auto;
}

.grid-card .card:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0,0,0,0.15);
}

/* Estilos para botones de collapse Bootstrap */
.card-header .btn-link {
  font-size: 1.1rem;
  text-decoration: none !important;
  color: #1e293b !important;
}

.card-header .btn-link:hover {
  color: #3b82f6 !important;
}

.card-header .btn-link:focus {
  box-shadow: none;
}

/* Estilos para botones de exportación en galería */
.gallery-export-buttons #btn-preview-all {
    background: linear-gradient(135deg, #3b82f6, #1d4ed8) !important;
    color: white !important;
    border: none !important;
  }
.gallery-export-buttons #btn-preview-all:hover {
    background: linear-gradient(135deg, #2563eb, #1e40af) !important;
    transform: translateY(-1px) !important;
  }

.gallery-export-buttons #btn-download-selected {
    background: linear-gradient(135deg, #10b981, #059669) !important;
    color: white !important;
    border: none !important;
  }
.gallery-export-buttons #btn-download-selected:hover {
    background: linear-gradient(135deg, #059669, #047857) !important;
    transform: translateY(-1px) !important;
  }

.gallery-export-buttons #btn-download-zip {
    background: linear-gradient(135deg, #8b5cf6, #7c3aed) !important;
    color: white !important;
    border: none !important;
  }
.gallery-export-buttons #btn-download-zip:hover {
    background: linear-gradient(135deg, #7c3aed, #6d28d9) !important;
    transform: translateY(-1px) !important;
  }

.gallery-export-buttons #btn-reset-settings {
    background: linear-gradient(135deg, #ef4444, #dc2626) !important;
    color: white !important;
    border: none !important;
  }
.gallery-export-buttons #btn-reset-settings:hover {
    background: linear-gradient(135deg, #dc2626, #b91c1c) !important;
    transform: translateY(-1px) !important;
  }

/* Desktop: Grid 2x2 limpio */
@media (min-width: 1024px) {
  section.config-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    grid-template-rows: auto auto;
    gap: 1.5rem;
    width: 100%;
    position: static;
  }
  
  /* Layout colapsable del botón Panel */
  .layout-collapsed section.config-grid { 
    display: none; 
  }
  .layout-collapsed .top-section { 
    grid-template-columns: 1fr; 
  }
  .layout-collapsed .gallery-section { 
    display: none; 
  }
}

/* Responsive design móvil */
@media (max-width: 1023px) {
  .top-section {
    grid-template-columns: 1fr;
    gap: 1rem;
  }
  
  /* Ajustes section se movió abajo del grid, ya no aplica aquí */
  
  .desktop-grid-2x2 {
    grid-template-columns: 1fr;
    grid-template-rows: auto auto auto auto auto;
    gap: 1rem;
  }
}

/* (Modo oscuro eliminado) */

/* ================= INPUTS Y CONTROLES MODERNOS ================= */
.input, .checkbox, .radio input, .btn {
  outline: none;
}

.input {
  width: 100%;
  appearance: none;
  border: 1px solid rgba(var(--border), 0.6);
  background: rgba(var(--surface), 1);
  color: rgb(var(--text));
  border-radius: 0.5rem;
  padding: 0.8rem 1rem;
  font-size: 0.875rem;
  transition: all 0.2s ease;
  backdrop-filter: blur(4px);
  box-shadow: inset 0 1px 3px rgba(0,0,0,0.08), 0 1px 2px rgba(0,0,0,0.05);
}

.input:focus {
  box-shadow: var(--ring), inset 0 1px 3px rgba(0,0,0,0.08), 0 1px 2px rgba(0,0,0,0.05);
  border-color: rgb(var(--primary));
  background: rgba(var(--surface), 1);
}

.input::placeholder {
  color: rgba(var(--text-muted), 0.7);
  font-style: italic;
}

.checkbox {
  width: 1.125rem;
  height: 1.125rem;
  border: 1px solid rgba(var(--border), 0.6);
  border-radius: 0.375rem;
  accent-color: rgb(var(--primary));
  box-shadow: 0 1px 2px rgba(0,0,0,0.05);
}

.radio {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  border: 1px solid rgba(var(--border), 0.6);
  border-radius: 0.75rem;
  padding: 0.5rem 0.875rem;
  background: rgba(var(--surface), 1);
  cursor: pointer;
  transition: all 0.2s ease;
  backdrop-filter: blur(4px);
  box-shadow: 0 1px 2px rgba(0,0,0,0.05);
}

.radio:hover {
  border-color: rgba(var(--primary), 0.5);
  background: rgba(var(--primary), 0.05);
}

.form-field {
  display: grid;
  gap: 0.6rem;
  font-size: 0.875rem;
}

.form-field > span {
  font-weight: 600;
  color: rgb(var(--text));
  font-size: 0.85rem;
  margin-bottom: 0.25rem;
  letter-spacing: 0.025em;
}

/* ================= SCROLLBAR SUTIL ================= */
*::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

*::-webkit-scrollbar-track {
  background: transparent;
}

*::-webkit-scrollbar-thumb {
  background: rgba(var(--text-muted), 0.3);
  border-radius: 8px;
}

*::-webkit-scrollbar-thumb:hover {
  background: rgba(var(--text-muted), 0.5);
}

/* ================= ANIMACIONES Y EFECTOS ================= */
@keyframes slideUp {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.7; }
}

.animate-slide-up {
  animation: slideUp 0.3s ease-out;
}

.animate-pulse {
  animation: pulse 1.5s ease-in-out infinite;
}

/* ================= RESPONSIVE MEJORADO ================= */
@media (max-width: 640px) {
  .card-content {
    padding: 1rem;
  }
  
  .dropzone-modern {
    padding: 1.5rem 1rem;
    min-height: 120px;
  }
  
  .gallery-grid {
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 0.75rem;
  }
  
  .gallery-controls {
    flex-direction: column;
    align-items: stretch;
    gap: 0.75rem;
  }
  
  .control-group {
    justify-content: center;
  }
  
  /* Mejoras para móvil */
  .card-modern {
    margin: 8px;
  }
  
  .form-field > span {
    font-size: 0.8rem;
  }
  
  .btn-modern {
    padding: 0.7rem 1rem;
    font-size: 0.8rem;
  }
}

/* ================= UTILIDADES FINALES ================= */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* Variantes adicionales */
.btn-accent {
  background: linear-gradient(135deg, rgb(var(--primary)) 0%, rgb(37 99 235) 100%);
  color: white;
}

/* Estados del botón Panel */
.btn-panel-hidden {
  background: linear-gradient(135deg, rgb(var(--danger)) 0%, rgb(220 38 38) 100%);
  color: white;
  border-color: rgba(var(--danger), 0.3);
}

.btn-panel-visible {
  background: linear-gradient(135deg, rgb(var(--success)) 0%, rgb(34 197 94) 100%);
  color: white;
  border-color: rgba(var(--success), 0.3);
}

.btn-panel-hidden:hover {
  background: linear-gradient(135deg, rgb(220 38 38) 0%, rgb(185 28 28) 100%);
}

.btn-panel-visible:hover {
  background: linear-gradient(135deg, rgb(34 197 94) 0%, rgb(22 163 74) 100%);
}

/* Mejoras finales de rendimiento y accesibilidad */
.card-modern, .btn-modern, .input, .radio, .checkbox {
  will-change: auto;
}

.card-modern:hover, .btn-modern:hover, .input:focus {
  will-change: transform, box-shadow, border-color;
}

/* Mejoras de accesibilidad */
.btn-modern:focus-visible,
.input:focus,
.checkbox:focus,
.radio:focus-within {
  outline: 2px solid rgb(var(--primary));
  outline-offset: 2px;
}

/* ================= SISTEMA DE COLAPSO/EXPANSIÓN ================= */
.card-header-collapsible {
  cursor: pointer;
  user-select: none;
  position: relative;
  transition: all 0.3s ease;
}

.card-header-collapsible:hover {
  background: rgba(var(--primary), 0.05);
  border-radius: 0.75rem 0.75rem 0 0;
}

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

.collapse-icon {
  display: inline-block;
  font-size: 0.875rem;
  margin-left: 0.5rem;
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  color: rgb(var(--primary));
  font-weight: bold;
}

.card-modern.collapsed .collapse-icon {
  transform: rotate(-90deg);
}

.card-content-collapsible {
  max-height: 2000px;
  overflow: hidden;
  transition: max-height 0.4s cubic-bezier(0.4, 0, 0.2, 1), 
              opacity 0.3s ease,
              padding 0.4s ease;
  opacity: 1;
}

.card-modern.collapsed .card-content-collapsible {
  max-height: 0;
  opacity: 0;
  padding-top: 0;
  padding-bottom: 0;
}

.card-modern.collapsed {
  border-color: rgba(var(--border), 0.3);
}

.card-modern.collapsed:hover {
  border-color: rgba(var(--primary), 0.4);
  transform: none;
}

/* Indicador visual de estado colapsado */
.card-modern.collapsed::after {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: linear-gradient(90deg, rgba(var(--primary), 0.6), rgba(var(--primary-dark), 0.6));
  border-radius: 1rem 1rem 0 0;
  opacity: 0.7;
}

/* Mejoras para diferentes dispositivos */
@media (max-width: 1023px) {
  .card-header-collapsible:hover {
    background: rgba(var(--primary), 0.08);
  }
  
  .card-content-collapsible {
    transition: max-height 0.3s ease, opacity 0.25s ease, padding 0.3s ease;
  }
}

/* Estados específicos para cada tarjeta colapsable */
#card-redimensionado.collapsed::after {
  background: linear-gradient(90deg, rgba(147,197,253,0.6), rgba(129,140,248,0.6));
}

#card-marca-imagen.collapsed::after {
  background: linear-gradient(90deg, rgba(196,181,253,0.6), rgba(167,139,250,0.6));
}

#card-marca-texto.collapsed::after {
  background: linear-gradient(90deg, rgba(187,247,208,0.6), rgba(134,239,172,0.6));
}

#card-exportacion.collapsed::after {
  background: linear-gradient(90deg, rgba(253,230,138,0.6), rgba(251,191,36,0.6));
}

/* ================= CSS PERSONALIZADO REEMPLAZO DE TAILWIND ================= */

/* LAYOUT PRINCIPAL */
.custom-body {
  margin: 0;
  padding: 0;
  font-family: 'Inter', ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
  background: linear-gradient(135deg, #f8fafc 0%, #ffffff 50%, #eff6ff 100%);
  color: #1e293b;
  min-height: 100vh;
}

.custom-header {
  position: sticky;
  top: 0;
  z-index: 20;
  background: rgba(255, 255, 255, 0.8);
  backdrop-filter: blur(16px);
  border-bottom: 1px solid rgba(226, 232, 240, 0.5);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.custom-container {
  max-width: 1280px;
  margin: 0 auto;
  padding: 0 1rem;
}

.custom-header-content {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.75rem 0;
}

.custom-header-left {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.custom-header-right {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.custom-title {
  font-size: 1.5rem;
  font-weight: 700;
  margin: 0;
  background: linear-gradient(135deg, #1e293b 0%, #3b82f6 50%, #1e293b 100%);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  line-height: 1.2;
}

.custom-subtitle {
  font-size: 0.75rem;
  color: #64748b;
  margin: 0.25rem 0 0 0;
}

.custom-button-text {
  font-size: 0.875rem;
}

/* MAIN LAYOUT */
.custom-main {
  max-width: 1280px;
  margin: 0 auto;
  padding: 1.5rem 1rem;
}

/* BOOTSTRAP COMPATIBILITY - Form styling overrides */
.form-label {
  font-weight: 500;
  color: #374151;
  margin-bottom: 0.5rem;
}

.form-control:focus {
  border-color: #3b82f6;
  box-shadow: 0 0 0 0.2rem rgba(59, 130, 246, 0.25);
}

.form-check-input:checked {
  background-color: #3b82f6;
  border-color: #3b82f6;
}

.form-check-input:focus {
  border-color: #93c5fd;
  box-shadow: 0 0 0 0.2rem rgba(59, 130, 246, 0.25);
}

/* FLEX UTILITIES */
.custom-flex-between {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
}

.custom-flex-center {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.custom-inline-flex {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
}

.custom-button-container {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  padding-top: 0.75rem;
}

/* RESPONSIVE HELPERS */
.mobile-only {
  display: none;
}

.desktop-only {
  display: inline-flex;
}

.mobile-hide,
.mobile-show {
  display: inline;
}

@media (max-width: 1023px) {
  .mobile-only {
    display: inline-flex;
  }
  
  .desktop-only {
    display: none;
  }
  
  .mobile-hide {
    display: none;
  }
  
  .mobile-show {
    display: inline;
  }
  
  .custom-title {
    font-size: 1.25rem;
  }
}

/* CLASES ADICIONALES PARA REEMPLAZAR TAILWIND */
.custom-checkbox-label {
  grid-column: 1 / -1;
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
}

.custom-text-sm {
  font-size: 0.875rem;
}

.custom-mt-4 {
  margin-top: 1rem;
}

.custom-mb-2 {
  margin-bottom: 0.5rem;
}

.text-xs {
  font-size: 0.75rem;
}

.text-slate-500 {
  color: #64748b;
}

.mt-2 {
  margin-top: 0.5rem;
}

.font-medium {
  font-weight: 500;
}

@media (max-width: 640px) {
  .custom-header-content {
    flex-direction: column;
    align-items: stretch;
    gap: 0.75rem;
  }
  
  .custom-header-left {
    justify-content: center;
  }
  
  .custom-title {
    font-size: 1.125rem;
    text-align: center;
  }
  
  .custom-button-container {
    flex-direction: column;
    gap: 0.75rem;
  }
}

/* Optimización para animaciones suaves */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
  
  .card-content-collapsible {
    transition: none !important;
  }
  
  .collapse-icon {
    transition: none !important;
  }
}

/* Iconos de collapse/expand con rotación */
.card-header button span {
  transition: transform 0.2s ease;
  display: inline-block;
}

.card-header button[aria-expanded="true"] span {
  transform: rotate(90deg);
}

/* ================= BOTÓN ELIMINAR INDIVIDUAL ================= */
/* Estilos específicos para el botón de eliminar en la galería */
.thumb .btn-danger.btn-xs {
  min-width: 28px;
  width: 28px;
  height: 28px;
  padding: 2px;
  font-size: 12px;
  margin: 0 4px;
  transition: all 0.2s ease;
  border-radius: 6px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.thumb .btn-danger.btn-xs:hover {
  transform: translateY(-1px) scale(1.1);
  box-shadow: 0 2px 8px rgba(248, 113, 113, 0.5);
}

/* ================= BOTÓN ROTAR INDIVIDUAL ================= */
/* Estilos específicos para el botón de rotar en la galería */
.thumb .btn-secondary.btn-xs {
  min-width: 28px;
  width: 28px;
  height: 28px;
  padding: 2px;
  font-size: 12px;
  border-radius: 6px;
  background: rgba(107, 114, 128, 0.1);
  border: 1px solid rgba(107, 114, 128, 0.2);
  color: rgb(75, 85, 99);
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.thumb .btn-secondary.btn-xs:hover {
  transform: translateY(-1px) scale(1.1);
  box-shadow: 0 2px 8px rgba(107, 114, 128, 0.4);
  background: rgba(107, 114, 128, 0.15);
  border-color: rgba(107, 114, 128, 0.3);
}

/* Ajustar el layout del lado izquierdo para acomodar ambos botones */
.thumb .meta .flex.items-center {
  align-items: center;
  gap: 6px;
}

/* ================= MODALES PERSONALIZADOS ================= */
.custom-modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 10000;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  visibility: hidden;
  transition: all 0.3s ease;
}

.custom-modal.show {
  opacity: 1;
  visibility: visible;
}

.custom-modal-backdrop {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(4px);
}

.custom-modal-content {
  position: relative;
  background: white;
  border-radius: 16px;
  box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
  max-width: 400px;
  width: 90%;
  max-height: 90vh;
  overflow: hidden;
  transform: scale(0.9);
  transition: transform 0.3s ease;
}

.custom-modal.show .custom-modal-content {
  transform: scale(1);
}

.custom-modal-header {
  padding: 20px 24px 0;
  border-bottom: 1px solid rgba(var(--border), 0.5);
  padding-bottom: 16px;
}

.custom-modal-title {
  margin: 0;
  font-size: 1.25rem;
  font-weight: 600;
  color: rgb(var(--text));
}

.custom-modal-body {
  padding: 20px 24px;
}

.custom-modal-message {
  margin: 0;
  color: rgb(var(--text-muted));
  line-height: 1.6;
}

.custom-modal-footer {
  padding: 16px 24px 20px;
  border-top: 1px solid rgba(var(--border), 0.5);
  display: flex;
  justify-content: flex-end;
  gap: 12px;
}

/* ================= NOTIFICACIONES TOAST ================= */
.toast-container {
  position: fixed;
  top: 20px;
  right: 20px;
  z-index: 10001;
  display: flex;
  flex-direction: column;
  gap: 12px;
  max-width: 400px;
  width: auto;
}

.toast {
  background: white;
  border-radius: 12px;
  box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
  border-left: 4px solid;
  padding: 16px 20px;
  display: flex;
  align-items: center;
  gap: 12px;
  transform: translateX(100%);
  opacity: 0;
  transition: all 0.3s ease;
  position: relative;
  overflow: hidden;
}

.toast.show {
  transform: translateX(0);
  opacity: 1;
}

.toast.success {
  border-left-color: #10b981;
}

.toast.error {
  border-left-color: #ef4444;
}

.toast.warning {
  border-left-color: #f59e0b;
}

.toast.info {
  border-left-color: #3b82f6;
}

.toast-icon {
  font-size: 1.25rem;
  flex-shrink: 0;
}

.toast-content {
  flex-grow: 1;
}

.toast-title {
  font-weight: 600;
  color: rgb(var(--text));
  margin: 0 0 4px 0;
  font-size: 0.875rem;
}

.toast-message {
  color: rgb(var(--text-muted));
  margin: 0;
  font-size: 0.8rem;
  line-height: 1.4;
}

.toast-close {
  background: none;
  border: none;
  color: rgb(var(--text-muted));
  cursor: pointer;
  padding: 0;
  font-size: 1.25rem;
  line-height: 1;
  transition: color 0.2s ease;
}

.toast-close:hover {
  color: rgb(var(--text));
}

/* Responsive para móviles */
@media (max-width: 640px) {
  .toast-container {
    left: 20px;
    right: 20px;
    max-width: none;
  }
  
  .custom-modal-content {
    margin: 20px;
    width: calc(100% - 40px);
  }
}