/**
 * Firefly AI Studio - Tema Visual Completo (Inspirado en Adobe Firefly)
 */

.app-container {
  display: flex;
  height: 100vh;
  width: 100vw;
  overflow: hidden;
  background-color: var(--bg-app);
}

/* =======================================================
   1. SIDEBAR LATERAL IZQUIERDO (COLAPSABLE / MINIMALISTA)
   ======================================================= */
.app-sidebar {
  width: 240px;
  background-color: var(--bg-sidebar);
  border-right: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  transition: width 0.25s ease;
  z-index: 50;
}

.sidebar-header {
  padding: 16px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.brand-link {
  display: flex;
  align-items: center;
  gap: 10px;
}

.brand-link img {
  height: 32px;
  object-fit: contain;
}

.btn-new-project {
  margin: 16px 16px 8px 16px;
  background: #2563eb;
  color: white;
  padding: 10px 16px;
  border-radius: var(--radius-full);
  font-size: 14px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  box-shadow: 0 4px 12px rgba(37, 99, 235, 0.35);
  transition: var(--transition);
}

.btn-new-project:hover {
  background: #1d4ed8;
  transform: translateY(-1px);
}

.sidebar-nav {
  flex: 1;
  overflow-y: auto;
  padding: 12px 10px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 10px 14px;
  border-radius: var(--radius-md);
  color: var(--text-muted);
  font-size: 13.5px;
  font-weight: 500;
  transition: var(--transition);
}

.nav-item:hover {
  background-color: var(--bg-hover);
  color: var(--text-main);
}

.nav-item.active {
  background-color: rgba(138, 43, 226, 0.15);
  color: var(--text-main);
  border-left: 3px solid var(--primary-color);
}

.nav-item svg {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
  opacity: 0.8;
}

.nav-item.active svg {
  opacity: 1;
  color: var(--primary-color);
}

.nav-divider {
  height: 1px;
  background: var(--border-color);
  margin: 8px 6px;
}

.sidebar-footer {
  padding: 14px 16px;
  border-top: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

/* =======================================================
   2. MAIN CONTENT AREA Y HEADER SUPERIOR
   ======================================================= */
.main-wrapper {
  flex: 1;
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow: hidden;
  position: relative;
}

.top-header {
  height: 56px;
  background: var(--bg-sidebar);
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  flex-shrink: 0;
  z-index: 40;
}

.header-left {
  display: flex;
  align-items: center;
  gap: 16px;
}

.back-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--text-muted);
  font-size: 13px;
  font-weight: 600;
  transition: var(--transition);
}

.back-btn:hover {
  color: var(--text-main);
}

.header-center-tabs {
  display: flex;
  align-items: center;
  gap: 24px;
}

.tab-link {
  color: var(--text-muted);
  font-size: 13.5px;
  font-weight: 600;
  padding: 16px 4px;
  border-bottom: 2px solid transparent;
  transition: var(--transition);
}

.tab-link:hover {
  color: var(--text-main);
}

.tab-link.active {
  color: var(--text-main);
  border-bottom-color: #2563eb;
}

.header-right {
  display: flex;
  align-items: center;
  gap: 14px;
}

/* Botón llamativo "Obtener Créditos" (con degradado y corona) */
.btn-crown-credits {
  background: var(--gradient-crown);
  color: white;
  padding: 7px 16px;
  border-radius: var(--radius-full);
  font-size: 13px;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 8px;
  box-shadow: 0 2px 10px rgba(236, 72, 153, 0.35);
  transition: var(--transition);
}

.btn-crown-credits:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 14px rgba(236, 72, 153, 0.5);
}

.user-credits-pill {
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.12);
  padding: 6px 14px;
  border-radius: var(--radius-full);
  font-size: 13px;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 6px;
  color: #fbbf24;
}

.user-profile-menu {
  position: relative;
}

.avatar-btn {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: var(--gradient-brand);
  color: white;
  font-weight: 700;
  font-size: 13px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 2px solid var(--border-color);
}

/* =======================================================
   3. ESTUDIO DE GENERACIÓN (SPLIT VIEW FIREFLY)
   ======================================================= */
.studio-layout {
  flex: 1;
  display: flex;
  height: calc(100vh - 56px);
  overflow: hidden;
  position: relative;
}

/* Panel Izquierdo: Configuración General */
.inspector-panel {
  width: 310px;
  background: var(--bg-surface);
  border-right: 1px solid var(--border-color);
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  padding: 20px;
  gap: 22px;
  flex-shrink: 0;
  z-index: 30;
}

.inspector-section-header {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13.5px;
  font-weight: 700;
  color: var(--text-main);
  margin-bottom: 12px;
}

.inspector-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.inspector-label {
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: #3b82f6; /* Acento azul según la captura */
}

.select-control {
  width: 100%;
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  color: var(--text-main);
  padding: 10px 14px;
  font-size: 13.5px;
  font-weight: 500;
  appearance: none;
  background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%2394a3b8' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3e%3cpolyline points='6 9 12 15 18 9'%3e%3c/polyline%3e%3c/svg%3e");
  background-repeat: no-repeat;
  background-position: right 14px center;
  background-size: 16px;
  cursor: pointer;
  transition: var(--transition);
}

.select-control:focus {
  outline: none;
  border-color: #3b82f6;
  box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.2);
}

/* Área de Imágenes de Referencia */
.reference-upload-box {
  border: 2px dashed var(--border-color);
  border-radius: var(--radius-md);
  padding: 20px 14px;
  text-align: center;
  cursor: pointer;
  background: rgba(255, 255, 255, 0.02);
  transition: var(--transition);
  user-select: none;
}

.reference-upload-box:hover,
.reference-upload-box.drag-active {
  border-color: #3b82f6;
  background: rgba(59, 130, 246, 0.08);
}

.reference-icon {
  width: 32px;
  height: 32px;
  color: var(--text-muted);
  margin-bottom: 6px;
  pointer-events: none;
}

.reference-previews-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-top: 4px;
}

.reference-previews-grid:empty {
  display: none;
}

.ref-thumb-item {
  position: relative;
  width: 100%;
  aspect-ratio: 1 / 1;
  border-radius: 8px;
  overflow: hidden;
  border: 1px solid var(--border-color);
  background: #0e0f14;
}

.ref-thumb-item img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.ref-thumb-remove {
  position: absolute;
  top: 4px;
  right: 4px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.75);
  color: #fff;
  font-size: 13px;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  border: 1px solid rgba(255, 255, 255, 0.2);
}

.ref-thumb-remove:hover {
  background: #ef4444;
}

/* Lienzo Central (Canvas) */
.canvas-stage {
  flex: 1;
  display: flex;
  flex-direction: column;
  position: relative;
  overflow: hidden;
  background-color: var(--bg-app);
}

.canvas-viewport {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  padding-bottom: 120px; /* Espacio para barra inferior */
  overflow: auto;
}

/* Estado Vacío de Inicio (Empezar a generar imágenes) */
.empty-hero-state {
  max-width: 480px;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.empty-icon-card {
  width: 72px;
  height: 72px;
  border-radius: 16px;
  background: linear-gradient(135deg, #1e3a8a, #3b82f6);
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  margin-bottom: 20px;
  box-shadow: 0 10px 25px rgba(59, 130, 246, 0.35);
}

.empty-hero-state h2 {
  font-size: 26px;
  font-weight: 800;
  color: white;
  margin-bottom: 10px;
  letter-spacing: -0.5px;
}

.empty-hero-state p {
  color: var(--text-muted);
  font-size: 14.5px;
  line-height: 1.6;
}

/* Estado de Generación en Progreso */
.loading-canvas {
  display: none;
  flex-direction: column;
  align-items: center;
  gap: 16px;
}

.spinner-glow {
  width: 60px;
  height: 60px;
  border: 4px solid rgba(255, 255, 255, 0.1);
  border-top-color: var(--accent-color);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  box-shadow: 0 0 20px rgba(255, 65, 108, 0.4);
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* Imagen Generada */
.generated-image-card {
  display: none;
  max-width: 900px;
  max-height: calc(100vh - 220px);
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow-lg);
  position: relative;
  border: 1px solid var(--border-color);
  background: #000;
}

.generated-image-card img {
  width: 100%;
  height: auto;
  max-height: calc(100vh - 260px);
  object-fit: contain;
  display: block;
}

.image-actions-bar {
  position: absolute;
  top: 16px;
  right: 16px;
  display: flex;
  gap: 10px;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(8px);
  padding: 6px 12px;
  border-radius: var(--radius-full);
  border: 1px solid rgba(255, 255, 255, 0.15);
}

.btn-action-icon {
  color: white;
  padding: 6px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition);
}

.btn-action-icon:hover {
  background: rgba(255, 255, 255, 0.2);
}

/* =======================================================
   4. BARRA DE INDICACIÓN FLOTANTE INFERIOR (BOTTOM DOCKED)
   ======================================================= */
.bottom-docked-bar {
  position: absolute;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  width: calc(100% - 48px);
  max-width: 960px;
  background: #18191f;
  border: 1px solid var(--border-color);
  border-radius: 18px;
  padding: 12px 18px;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.6);
  z-index: 50;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.prompt-input-row {
  display: flex;
  align-items: center;
  gap: 14px;
}

.prompt-textarea {
  flex: 1;
  background: transparent;
  border: none;
  outline: none;
  color: white;
  font-size: 14.5px;
  resize: none;
  height: 38px;
  max-height: 120px;
  line-height: 1.4;
  font-family: inherit;
}

.prompt-textarea::placeholder {
  color: var(--text-subtle);
}

.prompt-actions-right {
  display: flex;
  align-items: center;
  gap: 12px;
}

.credits-cost-tag {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13.5px;
  font-weight: 700;
  color: #fbbf24;
  padding: 6px 10px;
  background: rgba(251, 191, 36, 0.1);
  border-radius: var(--radius-full);
}

.btn-generate-main {
  background: #2563eb;
  color: white;
  padding: 10px 22px;
  border-radius: var(--radius-full);
  font-size: 14px;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 8px;
  box-shadow: 0 4px 14px rgba(37, 99, 235, 0.4);
  transition: var(--transition);
}

.btn-generate-main:hover {
  background: #1d4ed8;
  transform: translateY(-1px);
}

.btn-generate-main:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* Estilos de Sugerencias / Pills */
.style-pills-row {
  display: flex;
  align-items: center;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 2px;
}

.pill-item {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border-color);
  padding: 4px 12px;
  border-radius: var(--radius-full);
  font-size: 12px;
  color: var(--text-muted);
  cursor: pointer;
  white-space: nowrap;
  transition: var(--transition);
}

.pill-item:hover {
  background: rgba(255, 255, 255, 0.1);
  color: white;
  border-color: #3b82f6;
}

/* =======================================================
   5. RESPONSIVE DESIGN
   ======================================================= */
@media (max-width: 992px) {
  .app-sidebar {
    display: none;
  }
  .inspector-panel {
    width: 260px;
  }
}

@media (max-width: 768px) {
  .studio-layout {
    flex-direction: column;
  }
  .inspector-panel {
    width: 100%;
    height: auto;
    max-height: 200px;
    border-right: none;
    border-bottom: 1px solid var(--border-color);
  }
  .bottom-docked-bar {
    width: calc(100% - 20px);
    bottom: 10px;
  }
}
