/* ============================================================
   ESTILOS PRINCIPALES - GENERADOR DE IMÁGENES OPENGRAPH (OG IMAGE MAKER)
   ============================================================ */

:root {
  /* Paleta base y fondos de interfaz */
  --bg-app: #0a0c10;
  --bg-sidebar: #11141c;
  --bg-sidebar-header: #151924;
  --bg-card: #181d2a;
  --bg-card-hover: #1f2536;
  --bg-input: #0d1017;
  --bg-input-focus: #141824;
  --bg-active: #262e44;
  
  /* Bordes y separadores */
  --border-subtle: rgba(255, 255, 255, 0.08);
  --border-medium: rgba(255, 255, 255, 0.14);
  --border-active: rgba(99, 102, 241, 0.6);
  --border-focus: #6366f1;

  /* Colores de texto */
  --text-primary: #f8fafc;
  --text-secondary: #cbd5e1;
  --text-muted: #94a3b8;
  --text-dim: #64748b;

  /* Acentos de marca */
  --accent-primary: #6366f1;
  --accent-primary-hover: #4f46e5;
  --accent-gradient: linear-gradient(135deg, #6366f1 0%, #8b5cf6 50%, #d946ef 100%);
  --accent-glow: rgba(99, 102, 241, 0.25);
  --accent-success: #10b981;
  --accent-warning: #f59e0b;
  --accent-danger: #ef4444;

  /* Dimensiones y espaciados */
  --header-height: 64px;
  --sidebar-width: 420px;
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;
  --radius-xl: 20px;

  /* Sombras de interfaz */
  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.2);
  --shadow-md: 0 8px 24px rgba(0, 0, 0, 0.35);
  --shadow-lg: 0 16px 40px rgba(0, 0, 0, 0.45);
  --shadow-glow: 0 0 20px rgba(99, 102, 241, 0.35);

  /* Transiciones */
  --transition-fast: 0.15s ease;
  --transition-normal: 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

/* Reset básico y tipografía */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background-color: var(--bg-app);
  color: var(--text-primary);
  font-family: 'Inter', system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* Utilidad para lectores de pantalla */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border-width: 0;
}

/* ============================================================
   ESTRUCTURA Y DISPOSICIÓN PRINCIPAL (LAYOUT)
   ============================================================ */

.app-wrapper {
  display: flex;
  flex-direction: column;
  height: 100vh;
  width: 100vw;
  overflow: hidden;
}

/* Cabecera superior */
.app-header {
  height: var(--header-height);
  background: var(--bg-sidebar);
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  padding: 0 1.25rem;
  z-index: 40;
  flex-shrink: 0;
}

.header-container {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  gap: 1rem;
}

.brand-area {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  text-decoration: none;
  color: inherit;
  flex-shrink: 0;
}

.brand-logo-box {
  width: 38px;
  height: 38px;
  background: var(--accent-gradient);
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #ffffff;
  box-shadow: var(--shadow-glow);
}

.brand-text h1 {
  font-size: 1rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  color: var(--text-primary);
}

.badge-free {
  font-size: 0.6875rem;
  font-weight: 600;
  padding: 0.15rem 0.45rem;
  border-radius: 9999px;
  background: rgba(16, 185, 129, 0.15);
  color: #34d399;
  border: 1px solid rgba(16, 185, 129, 0.3);
  letter-spacing: 0.02em;
}

.brand-text p {
  font-size: 0.75rem;
  color: var(--text-muted);
  white-space: nowrap;
}

/* Acciones en la cabecera */
.header-actions {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  flex-wrap: nowrap;
}

.header-control-group {
  position: relative;
}

.form-select-header {
  background-color: var(--bg-card);
  border: 1px solid var(--border-subtle);
  color: var(--text-primary);
  padding: 0.45rem 2rem 0.45rem 0.75rem;
  border-radius: var(--radius-md);
  font-size: 0.8125rem;
  font-weight: 500;
  cursor: pointer;
  outline: none;
  transition: all var(--transition-fast);
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%2394a3b8' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.75rem center;
}

.form-select-header:hover {
  background-color: var(--bg-card-hover);
  border-color: var(--border-medium);
}

.form-select-header:focus {
  border-color: var(--border-focus);
  box-shadow: 0 0 0 2px var(--accent-glow);
}

.resolution-selector-wrapper {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  background: var(--bg-card);
  padding: 0.2rem 0.35rem 0.2rem 0.6rem;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-subtle);
}

.selector-label {
  font-size: 0.75rem;
  color: var(--text-muted);
  font-weight: 500;
}

.btn-group-segmented {
  display: flex;
  gap: 2px;
}

.btn-segment {
  background: transparent;
  border: none;
  color: var(--text-muted);
  padding: 0.25rem 0.5rem;
  font-size: 0.75rem;
  font-weight: 600;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all var(--transition-fast);
}

.btn-segment:hover {
  color: var(--text-primary);
  background: rgba(255, 255, 255, 0.05);
}

.btn-segment.active {
  background: var(--accent-primary);
  color: #ffffff;
}

/* Botones estándar */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
  padding: 0.45rem 0.85rem;
  border-radius: var(--radius-md);
  font-size: 0.8125rem;
  font-weight: 600;
  cursor: pointer;
  border: 1px solid transparent;
  outline: none;
  transition: all var(--transition-fast);
  white-space: nowrap;
}

.btn-primary {
  background: var(--accent-primary);
  color: #ffffff;
  box-shadow: 0 2px 10px rgba(99, 102, 241, 0.3);
}

.btn-primary:hover {
  background: var(--accent-primary-hover);
  box-shadow: 0 4px 16px rgba(99, 102, 241, 0.45);
}

.btn-secondary {
  background: var(--bg-card);
  border-color: var(--border-subtle);
  color: var(--text-primary);
}

.btn-secondary:hover {
  background: var(--bg-card-hover);
  border-color: var(--border-medium);
}

.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
}

.btn-ghost:hover {
  background: rgba(255, 255, 255, 0.08);
  color: var(--text-primary);
}

.btn-icon {
  width: 36px;
  height: 36px;
  padding: 0;
  border-radius: var(--radius-md);
}

.btn-sm {
  padding: 0.3rem 0.6rem;
  font-size: 0.75rem;
}

/* Cuerpo principal */
.app-main {
  display: flex;
  flex: 1;
  overflow: hidden;
  position: relative;
}

/* ============================================================
   BARRA LATERAL DE CONFIGURACIÓN (SIDEBAR)
   ============================================================ */

.app-sidebar {
  width: var(--sidebar-width);
  background: var(--bg-sidebar);
  border-right: 1px solid var(--border-subtle);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  height: calc(100vh - var(--header-height));
  z-index: 20;
  overflow: hidden;
}

/* Pestañas de navegación en la barra lateral */
.sidebar-tabs {
  display: flex;
  background: var(--bg-sidebar-header);
  border-bottom: 1px solid var(--border-subtle);
  padding: 0.35rem 0.5rem;
  gap: 0.25rem;
  flex-shrink: 0;
  overflow-x: auto;
  scrollbar-width: none;
}

.sidebar-tabs::-webkit-scrollbar {
  display: none;
}

.tab-button {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  padding: 0.5rem 0.6rem;
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 0.75rem;
  font-weight: 600;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all var(--transition-fast);
  white-space: nowrap;
}

.tab-button:hover {
  color: var(--text-primary);
  background: rgba(255, 255, 255, 0.05);
}

.tab-button.active {
  background: var(--bg-card);
  color: #ffffff;
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border-subtle);
}

.tab-button svg {
  width: 15px;
  height: 15px;
}

/* Contenido scrolleable de paneles */
.sidebar-content {
  flex: 1;
  overflow-y: auto;
  padding: 1.15rem;
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 255, 255, 0.15) transparent;
}

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

.sidebar-content::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.15);
  border-radius: 9999px;
}

.tab-panel {
  display: none;
  flex-direction: column;
  gap: 1.25rem;
}

.tab-panel.active {
  display: flex;
}

/* Secciones dentro de la barra lateral */
.sidebar-section {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.section-title {
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-dim);
}

.section-toggle {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.75rem;
  color: var(--text-muted);
  cursor: pointer;
}

/* Grupos y campos de formulario */
.form-group {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
}

.form-row-3 {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 0.5rem;
}

.form-label {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.form-label-helper {
  font-size: 0.6875rem;
  color: var(--text-muted);
  font-weight: normal;
}

.form-input, .form-textarea, .form-select {
  width: 100%;
  background: var(--bg-input);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  padding: 0.55rem 0.75rem;
  font-size: 0.8125rem;
  outline: none;
  font-family: inherit;
  transition: all var(--transition-fast);
}

.form-input:focus, .form-textarea:focus, .form-select:focus {
  border-color: var(--border-focus);
  background: var(--bg-input-focus);
  box-shadow: 0 0 0 2px var(--accent-glow);
}

.form-textarea {
  resize: vertical;
  min-height: 60px;
  line-height: 1.4;
}

.form-select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%2394a3b8' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.75rem center;
  cursor: pointer;
}

/* Selector de colores / Color pickers */
.color-picker-group {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  background: var(--bg-input);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 0.3rem 0.5rem;
}

.color-input-native {
  width: 26px;
  height: 26px;
  border: none;
  border-radius: var(--radius-sm);
  background: transparent;
  cursor: pointer;
  padding: 0;
  appearance: none;
}

.color-input-native::-webkit-color-swatch-wrapper {
  padding: 0;
}

.color-input-native::-webkit-color-swatch {
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: var(--radius-sm);
}

.color-hex-text {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.75rem;
  color: var(--text-primary);
  background: transparent;
  border: none;
  outline: none;
  width: 100%;
}

/* Sliders de rango */
.range-slider-wrapper {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.form-range {
  flex: 1;
  height: 6px;
  border-radius: 3px;
  background: var(--bg-card);
  outline: none;
  appearance: none;
  cursor: pointer;
}

.form-range::-webkit-slider-thumb {
  appearance: none;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--accent-primary);
  border: 2px solid #ffffff;
  box-shadow: 0 1px 4px rgba(0,0,0,0.4);
  cursor: pointer;
  transition: transform 0.1s ease;
}

.form-range::-webkit-slider-thumb:hover {
  transform: scale(1.15);
}

.range-value-badge {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.6875rem;
  background: var(--bg-card);
  padding: 0.15rem 0.4rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-subtle);
  color: var(--text-secondary);
  min-width: 36px;
  text-align: center;
}

/* Cuadrículas de selección de plantillas y layouts */
.layout-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.6rem;
}

.layout-card {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 0.6rem;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  transition: all var(--transition-fast);
  text-align: left;
}

.layout-card:hover {
  background: var(--bg-card-hover);
  border-color: var(--border-medium);
}

.layout-card.active {
  border-color: var(--accent-primary);
  background: rgba(99, 102, 241, 0.1);
  box-shadow: 0 0 0 1px var(--accent-primary);
}

.layout-preview-box {
  width: 100%;
  height: 52px;
  border-radius: var(--radius-sm);
  background: var(--bg-app);
  border: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  overflow: hidden;
}

.layout-preview-box svg {
  width: 100%;
  height: 100%;
}

.layout-name {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-primary);
}

.layout-desc {
  font-size: 0.6875rem;
  color: var(--text-muted);
}

/* Selector de degradados */
.gradient-presets-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0.5rem;
}

.gradient-preset-btn {
  height: 38px;
  border-radius: var(--radius-md);
  border: 2px solid transparent;
  cursor: pointer;
  transition: all var(--transition-fast);
  position: relative;
  overflow: hidden;
}

.gradient-preset-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0,0,0,0.3);
}

.gradient-preset-btn.active {
  border-color: #ffffff;
  box-shadow: 0 0 0 2px var(--accent-primary);
}

/* Patrones de fondo */
.patterns-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.5rem;
}

.pattern-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.3rem;
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 0.6rem 0.4rem;
  cursor: pointer;
  color: var(--text-secondary);
  font-size: 0.6875rem;
  transition: all var(--transition-fast);
}

.pattern-btn:hover {
  background: var(--bg-card-hover);
  color: var(--text-primary);
}

.pattern-btn.active {
  border-color: var(--accent-primary);
  color: #ffffff;
  background: rgba(99, 102, 241, 0.12);
}

/* Buscador y selector de iconos */
.icon-selector-container {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.icon-search-input {
  width: 100%;
  background: var(--bg-input);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 0.45rem 0.65rem 0.45rem 2rem;
  color: var(--text-primary);
  font-size: 0.75rem;
  outline: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%2394a3b8' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='11' cy='11' r='8'/%3E%3Cpath d='m21 21-4.3-4.3'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: 0.6rem center;
}

.icons-grid-scroll {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 0.35rem;
  max-height: 140px;
  overflow-y: auto;
  padding: 0.25rem;
  background: var(--bg-input);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
}

.icon-select-btn {
  aspect-ratio: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  cursor: pointer;
  transition: all var(--transition-fast);
}

.icon-select-btn:hover {
  background: var(--bg-card);
  color: var(--text-primary);
}

.icon-select-btn.active {
  background: var(--accent-primary);
  color: #ffffff;
}

.icon-select-btn svg {
  width: 18px;
  height: 18px;
}

/* Área de subida de imágenes (Drag & Drop) */
.dropzone-box {
  border: 2px dashed var(--border-medium);
  border-radius: var(--radius-md);
  padding: 0.85rem;
  text-align: center;
  cursor: pointer;
  transition: all var(--transition-fast);
  background: rgba(255, 255, 255, 0.01);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.35rem;
}

.dropzone-box:hover, .dropzone-box.dragover {
  border-color: var(--accent-primary);
  background: rgba(99, 102, 241, 0.05);
}

.dropzone-icon {
  color: var(--text-muted);
}

.dropzone-text {
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--text-secondary);
}

.dropzone-hint {
  font-size: 0.6875rem;
  color: var(--text-dim);
}

.image-preview-badge {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 0.4rem 0.6rem;
  font-size: 0.75rem;
}

.image-preview-thumb {
  width: 28px;
  height: 28px;
  border-radius: var(--radius-sm);
  object-fit: cover;
  border: 1px solid var(--border-subtle);
}

/* Interruptor Toggle Switch */
.toggle-switch {
  position: relative;
  display: inline-block;
  width: 36px;
  height: 20px;
}

.toggle-switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.toggle-slider {
  position: absolute;
  cursor: pointer;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: var(--bg-card);
  border: 1px solid var(--border-subtle);
  transition: .2s;
  border-radius: 20px;
}

.toggle-slider:before {
  position: absolute;
  content: "";
  height: 14px;
  width: 14px;
  left: 2px;
  bottom: 2px;
  background-color: var(--text-muted);
  transition: .2s;
  border-radius: 50%;
}

input:checked + .toggle-slider {
  background-color: var(--accent-primary);
  border-color: var(--accent-primary);
}

input:checked + .toggle-slider:before {
  transform: translateX(16px);
  background-color: #ffffff;
}

/* ============================================================
   RESPONSIVIDAD Y AJUSTES MÓVILES
   ============================================================ */

@media (max-width: 1024px) {
  :root {
    --sidebar-width: 360px;
  }
}

@media (max-width: 768px) {
  html, body {
    overflow: auto;
  }

  .app-wrapper {
    height: auto;
    min-height: 100vh;
    overflow: visible;
  }

  .app-header {
    height: auto;
    padding: 0.75rem 1rem;
  }

  .header-container {
    flex-direction: column;
    align-items: stretch;
    gap: 0.75rem;
  }

  .header-actions {
    overflow-x: auto;
    padding-bottom: 0.25rem;
  }

  .app-main {
    flex-direction: column-reverse;
    overflow: visible;
  }

  .app-sidebar {
    width: 100%;
    height: auto;
    border-right: none;
    border-top: 1px solid var(--border-subtle);
  }

  .sidebar-content {
    overflow-y: visible;
  }
}
