/* ============================================================
   MODULES — Slides, Antes/Despues, Video, Caption, Biblioteca
   ============================================================ */

/* ── Slides Preview Area ── */
.slides-area {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: var(--space-5);
  margin-top: var(--space-5);
}

.slide-wrapper {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  animation: fadeIn var(--duration-slow) var(--ease-out) both;
}

.slide-canvas-container {
  position: relative;
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow-md);
  transition: box-shadow var(--duration-normal);
}
.slide-canvas-container:hover { box-shadow: var(--shadow-lg); }

.slide-inner {
  position: relative;
  width: 100%;
  height: 100%;
  overflow: hidden;
  font-family: var(--font-sans);
}

.slide-content {
  position: absolute;
  inset: 0;
  padding: 20px;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  z-index: 5;
}

.slide-logo-area {
  position: absolute;
  top: 16px; right: 16px;
  font-weight: 700;
  font-size: 12px;
  letter-spacing: 3px;
  text-transform: uppercase;
  z-index: 6;
}

.slide-number {
  position: absolute;
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 2px;
  opacity: 0.6;
  z-index: 5;
}

.slide-category {
  font-size: 9px;
  font-weight: 600;
  letter-spacing: 2.5px;
  text-transform: uppercase;
  margin-bottom: var(--space-2);
  opacity: 0.8;
}

.slide-title {
  font-size: 18px;
  font-weight: 700;
  line-height: var(--leading-tight);
  margin-bottom: var(--space-3);
  outline: none;
  cursor: text;
  border-bottom: 1px solid transparent;
  transition: border-color var(--duration-fast);
}
.slide-title:focus { border-bottom-color: rgba(255,255,255,0.4); }

.slide-body {
  font-size: 11px;
  font-weight: 400;
  line-height: 1.6;
  opacity: 0.88;
  outline: none;
  cursor: text;
}

.slide-cta {
  display: inline-block;
  margin-top: var(--space-3);
  font-size: 9px;
  font-weight: 600;
  letter-spacing: 2px;
  text-transform: uppercase;
  padding: 5px 14px;
  border-radius: var(--radius-full);
  border: 1.5px solid currentColor;
}

.slide-disclaimer {
  font-size: 8px;
  opacity: 0.5;
  margin-top: var(--space-2);
  font-style: italic;
}

/* Slide Styles */
.style-classic { background: #fdf8f5; }
.style-classic .slide-logo-area,
.style-classic .slide-title { color: #5c2020; }
.style-classic .slide-body { color: #6b4035; }
.style-classic .slide-category { color: #b35d54; }
.style-classic .slide-number { color: #a07060; }
.style-classic .slide-cta { color: #b35d54; }

.style-dark { background: #1a0a08; }
.style-dark .slide-logo-area,
.style-dark .slide-title { color: #fdf8f5; }
.style-dark .slide-body { color: rgba(253,248,245,0.8); }
.style-dark .slide-category { color: #d28560; }
.style-dark .slide-number { color: rgba(253,248,245,0.4); }
.style-dark .slide-cta { color: #d28560; }

.style-minimal { background: #ffffff; border: 2px solid #f1f3f5; }
.style-minimal .slide-logo-area,
.style-minimal .slide-title { color: #212529; }
.style-minimal .slide-body { color: #495057; }
.style-minimal .slide-category { color: #6C5CE7; }
.style-minimal .slide-number { color: #adb5bd; }
.style-minimal .slide-cta { color: #6C5CE7; }

.style-terra { background: #b35d54; }
.style-terra .slide-logo-area,
.style-terra .slide-title,
.style-terra .slide-body { color: #fdf8f5; }
.style-terra .slide-category { color: #fde5dc; }
.style-terra .slide-number { color: rgba(253,248,245,0.5); }
.style-terra .slide-cta { color: #fdf8f5; }

.style-violet { background: linear-gradient(135deg, #6C5CE7, #4834D4); }
.style-violet .slide-logo-area,
.style-violet .slide-title,
.style-violet .slide-body { color: #ffffff; }
.style-violet .slide-category { color: #A29BFE; }
.style-violet .slide-number { color: rgba(255,255,255,0.4); }
.style-violet .slide-cta { color: #A29BFE; }

/* Slide design panel */
.slide-panel {
  background: var(--surface-sunken);
  border: 1.5px solid var(--gray-200);
  border-radius: var(--radius-lg);
  padding: var(--space-3);
}

.slide-panel-row {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  flex-wrap: wrap;
}

.slide-panel-label {
  font-size: 9px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: var(--tracking-wider);
  color: var(--text-tertiary);
  flex-shrink: 0;
}

.slide-field-row {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  background: var(--surface);
  border-radius: var(--radius-md);
  padding: var(--space-1) var(--space-2);
  border: 1px solid var(--gray-100);
}

/* ── Antes/Despues ── */
.ad-upload-zone {
  border: 2px dashed var(--gray-300);
  border-radius: var(--radius-lg);
  height: 200px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all var(--duration-fast);
  overflow: hidden;
  position: relative;
  background: var(--surface-sunken);
}
.ad-upload-zone:hover {
  border-color: var(--primary);
  background: var(--primary-bg);
}
.ad-upload-zone.loaded {
  border-style: solid;
  border-color: var(--primary);
  cursor: default;
}

.ad-foto-preview {
  width: 100%; height: 100%;
  object-fit: cover;
  display: block;
}

.ad-consent-btn {
  font-family: var(--font-sans);
  font-size: var(--text-xs);
  font-weight: 500;
  padding: var(--space-2) var(--space-3);
  border: 1.5px solid var(--gray-200);
  border-radius: var(--radius-md);
  background: var(--surface);
  color: var(--text-secondary);
  cursor: pointer;
  transition: all var(--duration-fast);
  text-align: center;
}
.ad-consent-btn:hover { border-color: var(--primary); color: var(--text-primary); }
.ad-consent-btn.active {
  background: var(--primary);
  color: var(--white);
  border-color: var(--primary);
}

/* ── Video Export ── */
.ve-preview-box {
  position: relative;
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow-md);
  background: #111;
}

.ve-preview-box video {
  width: 100%; height: 100%;
  object-fit: cover;
  display: block;
}

.video-upload-zone {
  border: 2px dashed var(--primary);
  border-radius: var(--radius-lg);
  padding: var(--space-5);
  text-align: center;
  cursor: pointer;
  transition: all var(--duration-fast);
  background: rgba(108,92,231,0.04);
}
.video-upload-zone:hover { background: rgba(108,92,231,0.08); }

/* ── Caption IG ── */
.caption-preview {
  background: var(--surface);
  border: 1.5px solid var(--gray-200);
  border-radius: var(--radius-lg);
  padding: var(--space-4);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

.caption-header {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  margin-bottom: var(--space-3);
}

.caption-avatar {
  width: 32px; height: 32px;
  border-radius: var(--radius-full);
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  display: flex; align-items: center; justify-content: center;
  font-size: 11px;
  font-weight: 700;
  color: var(--white);
  flex-shrink: 0;
}

.caption-username {
  font-size: var(--text-sm);
  font-weight: 700;
  color: var(--text-primary);
}

.caption-body {
  font-size: var(--text-sm);
  line-height: var(--leading-relaxed);
  color: var(--text-primary);
  white-space: pre-wrap;
  word-break: break-word;
}

.caption-hook { font-weight: 700; }
.caption-hashtags {
  color: #00376b;
  margin-top: var(--space-2);
  display: block;
}
.caption-collapsed {
  color: var(--text-tertiary);
  font-size: var(--text-sm);
  cursor: pointer;
}

/* Hashtag chips */
.hashtag-chip {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  background: var(--gray-50);
  border: 1.5px solid var(--gray-200);
  border-radius: var(--radius-full);
  padding: var(--space-2) var(--space-3);
  font-size: var(--text-sm);
  font-weight: 500;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all var(--duration-fast);
  user-select: none;
}
.hashtag-chip:hover {
  border-color: var(--primary);
  color: var(--primary);
  background: var(--primary-bg);
}
.hashtag-chip.copied {
  border-color: var(--success);
  color: #1a7a5c;
  background: var(--success-bg);
}

/* ── Biblioteca Grid ── */
.biblioteca-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: var(--space-5);
}

.biblioteca-item {
  background: var(--surface);
  border-radius: var(--radius-lg);
  overflow: hidden;
  border: var(--border-light);
  cursor: pointer;
  transition: all var(--duration-fast) var(--ease-out);
  position: relative;
}
.biblioteca-item:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow-md);
}

.biblioteca-thumb {
  height: 120px;
  display: flex; align-items: center; justify-content: center;
  flex-direction: column;
  gap: var(--space-1);
  font-size: var(--text-xs);
  font-weight: 600;
  letter-spacing: var(--tracking-wide);
  text-transform: uppercase;
}

.biblioteca-info {
  padding: var(--space-3);
}
.biblioteca-info h4 {
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 3px;
}
.biblioteca-info p {
  font-size: var(--text-xs);
  color: var(--text-tertiary);
}

.biblioteca-actions {
  display: flex; gap: var(--space-2);
  padding: var(--space-3);
  border-top: var(--border-light);
}

.bib-badge-wip {
  position: absolute; top: var(--space-2); right: var(--space-2);
  background: var(--accent);
  color: var(--white);
  font-size: 9px;
  font-weight: 700;
  letter-spacing: var(--tracking-wide);
  padding: 2px 8px;
  border-radius: var(--radius-full);
  text-transform: uppercase;
}

/* ── Dashboard ── */
.dashboard-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: var(--space-4);
  margin-bottom: var(--space-8);
}

.stat-card {
  background: var(--surface);
  border: var(--border-light);
  border-radius: var(--radius-lg);
  padding: var(--space-5);
  transition: all var(--duration-fast);
  position: relative;
  overflow: hidden;
}
.stat-card:hover {
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
}
.stat-card::after {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 3px;
}
.stat-card:nth-child(1)::after { background: linear-gradient(90deg, var(--primary), var(--primary-light)); }
.stat-card:nth-child(2)::after { background: linear-gradient(90deg, var(--accent), var(--accent-light)); }
.stat-card:nth-child(3)::after { background: linear-gradient(90deg, var(--success), #6fddaa); }
.stat-card:nth-child(4)::after { background: linear-gradient(90deg, var(--info), #a8d4ff); }

.stat-icon {
  width: 44px; height: 44px;
  border-radius: var(--radius-md);
  display: flex; align-items: center; justify-content: center;
  font-size: 20px;
  margin-bottom: var(--space-3);
}
.stat-icon.purple { background: var(--primary); color: var(--white); }
.stat-icon.orange { background: var(--accent); color: var(--white); }
.stat-icon.green  { background: var(--success); color: var(--white); }
.stat-icon.blue   { background: var(--info); color: var(--white); }

.stat-value {
  font-size: var(--text-3xl);
  font-weight: 800;
  color: var(--text-primary);
  line-height: 1;
}

.stat-label {
  font-size: var(--text-xs);
  color: var(--text-secondary);
  margin-top: var(--space-1);
  font-weight: 500;
}

/* ── Quick Actions Grid (Dashboard) ── */
.quick-actions {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: var(--space-3);
}

.quick-action {
  display: flex; align-items: center; gap: var(--space-3);
  padding: var(--space-4);
  background: var(--surface);
  border: var(--border-light);
  border-radius: var(--radius-lg);
  cursor: pointer;
  transition: all var(--duration-fast);
  font-size: var(--text-sm);
  font-weight: 500;
  color: var(--text-primary);
}
.quick-action:hover {
  border-color: var(--primary-light);
  background: var(--primary-bg);
  transform: translateY(-2px);
  box-shadow: var(--shadow-sm);
}
.quick-action .qa-icon {
  width: 40px; height: 40px;
  border-radius: var(--radius-md);
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  color: var(--white);
  display: flex; align-items: center; justify-content: center;
  font-size: 16px;
  flex-shrink: 0;
  box-shadow: 0 2px 8px rgba(91,75,199,0.25);
}

/* ── Logo Manager ── */
.logo-slots {
  display: flex; gap: var(--space-3); flex-wrap: wrap;
}

.logo-slot {
  width: 80px; height: 50px;
  border: 2px dashed var(--gray-300);
  border-radius: var(--radius-md);
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  transition: all var(--duration-fast);
  background: var(--surface-sunken);
  position: relative;
  overflow: hidden;
  flex-shrink: 0;
}
.logo-slot:hover { border-color: var(--primary); }
.logo-slot.active {
  border-color: var(--primary);
  border-style: solid;
  box-shadow: 0 0 0 3px rgba(108,92,231,0.12);
}
.logo-slot.loaded { border-style: solid; border-color: var(--gray-300); }

.logo-slot img {
  max-width: 100%; max-height: 100%;
  object-fit: contain;
  padding: 4px;
}

/* ── Font Picker ── */
.font-picker { position: relative; }

.font-picker-trigger {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-3) var(--space-4);
  border: 1.5px solid var(--gray-200);
  border-radius: var(--radius-md);
  background: var(--surface);
  cursor: pointer;
  transition: border-color var(--duration-fast);
  user-select: none;
  gap: var(--space-2);
}
.font-picker-trigger:hover { border-color: var(--primary-light); }

.font-picker-dropdown {
  position: absolute;
  top: calc(100% + 4px);
  left: 0; right: 0;
  background: var(--surface);
  border: 1.5px solid var(--gray-200);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  z-index: 500;
  max-height: 280px;
  overflow-y: auto;
  display: none;
}
.font-picker-dropdown.open { display: block; }

.font-option {
  padding: var(--space-3) var(--space-4);
  cursor: pointer;
  transition: background var(--duration-fast);
  border-bottom: 1px solid var(--gray-100);
}
.font-option:last-child { border-bottom: none; }
.font-option:hover { background: var(--gray-50); }
.font-option.selected { background: var(--primary-bg); }

.font-option .font-name {
  font-size: 15px;
  color: var(--text-primary);
  display: block;
}
.font-option .font-label {
  font-size: 10px;
  color: var(--text-tertiary);
  font-family: var(--font-sans) !important;
  margin-top: 1px;
}

/* ── Tendencias Widget ── */
.tendencias-widget {
  padding: var(--space-3) var(--space-4) var(--space-2);
  border-top: 1px solid rgba(255,255,255,0.08);
}

.tendencias-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--space-2);
}

.tendencias-title {
  font-size: 9px;
  font-weight: 700;
  letter-spacing: var(--tracking-wider);
  text-transform: uppercase;
  color: var(--primary-light);
}

.tendencias-refresh {
  background: none; border: none;
  color: rgba(255,255,255,0.35);
  font-size: 12px;
  cursor: pointer;
  padding: 2px 4px;
  border-radius: var(--radius-sm);
  transition: all var(--duration-fast);
}
.tendencias-refresh:hover { color: var(--primary-light); }
.tendencias-refresh.spinning { animation: spin 1s linear infinite; }

.tendencia-item {
  display: flex;
  align-items: flex-start;
  gap: var(--space-2);
  padding: var(--space-2) 0;
  border-bottom: 1px solid rgba(255,255,255,0.06);
  cursor: pointer;
  transition: opacity var(--duration-fast);
}
.tendencia-item:last-child { border-bottom: none; }
.tendencia-item:hover { opacity: 0.75; }

.tendencia-rank {
  font-size: 9px;
  font-weight: 700;
  color: var(--primary-light);
  width: 14px;
  flex-shrink: 0;
}

.tendencia-info { flex: 1; min-width: 0; }
.tendencia-nombre {
  font-size: var(--text-xs);
  font-weight: 600;
  color: rgba(255,255,255,0.85);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.tendencia-meta {
  font-size: 9px;
  color: rgba(255,255,255,0.35);
  margin-top: 1px;
}

.tendencia-trend {
  font-size: 9px;
  font-weight: 700;
  flex-shrink: 0;
}
.tendencia-trend.up   { color: var(--success); }
.tendencia-trend.down { color: var(--error); }
.tendencia-trend.new  { color: var(--primary); }

/* ── Image Gen Modal ── */
.img-template-btn {
  font-family: var(--font-sans);
  font-size: var(--text-xs);
  font-weight: 500;
  padding: var(--space-2) var(--space-3);
  border: 1.5px solid var(--gray-200);
  border-radius: var(--radius-md);
  background: var(--surface-sunken);
  color: var(--text-secondary);
  cursor: pointer;
  transition: all var(--duration-fast);
}
.img-template-btn:hover {
  border-color: var(--primary);
  color: var(--primary);
  background: var(--primary-bg);
}

.img-gallery {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(110px, 1fr));
  gap: var(--space-2);
  max-height: 280px;
  overflow-y: auto;
}

.img-gallery-item {
  position: relative;
  aspect-ratio: 1/1;
  border-radius: var(--radius-md);
  overflow: hidden;
  cursor: pointer;
  border: 1.5px solid var(--gray-200);
  transition: all var(--duration-fast);
}
.img-gallery-item:hover {
  border-color: var(--primary);
  transform: scale(1.03);
}

.img-gallery-item img {
  width: 100%; height: 100%;
  object-fit: cover;
}

.img-gallery-overlay {
  position: absolute; inset: 0;
  background: rgba(91,75,199,0.75);
  display: flex; align-items: center; justify-content: center;
  color: var(--white);
  font-size: var(--text-xs);
  font-weight: 700;
  letter-spacing: var(--tracking-wider);
  text-transform: uppercase;
  opacity: 0;
  transition: opacity var(--duration-fast);
}
.img-gallery-item:hover .img-gallery-overlay { opacity: 1; }

/* ── Responsive modules ── */
@media (max-width: 768px) {
  .slides-area { grid-template-columns: 1fr; }
  .biblioteca-grid { grid-template-columns: 1fr 1fr; }
  .dashboard-grid { grid-template-columns: 1fr 1fr; }
  .quick-actions { grid-template-columns: 1fr; }
}

@media (max-width: 480px) {
  .biblioteca-grid { grid-template-columns: 1fr; }
  .dashboard-grid { grid-template-columns: 1fr; }
}