/* ==========================================================================
   IconAI Studio — Interactive Generator, Canvas & Preview Styles
   ========================================================================== */

.studio-wrapper {
  margin-top: 1rem;
  margin-bottom: 3.5rem;
}

.studio-grid {
  display: grid;
  grid-template-columns: 1.15fr 0.85fr;
  gap: 2rem;
  align-items: start;
}

/* Studio Panels */
.studio-panel {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-xl);
  padding: 1.75rem;
  box-shadow: var(--shadow-sm);
}

.studio-preview-panel {
  position: sticky;
  top: calc(var(--nav-height) + 1.25rem);
}

/* Prompt Input Bar */
.prompt-group {
  margin-bottom: 1.5rem;
}

.prompt-label-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.5rem;
}

.prompt-input-wrapper {
  position: relative;
  display: flex;
  align-items: center;
}

.prompt-input {
  width: 100%;
  padding: 0.9rem 7.5rem 0.9rem 1.1rem;
  font-size: 1rem;
  font-family: inherit;
  color: var(--text-main);
  background: var(--bg-surface-alt);
  border: 1.5px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  transition: all 0.15s ease;
}

.prompt-input:focus {
  border-color: var(--primary);
  background: var(--bg-surface);
  outline: none;
  box-shadow: 0 0 0 3px var(--primary-glow);
}

.prompt-btn-group {
  position: absolute;
  right: 6px;
  display: flex;
  align-items: center;
  gap: 4px;
}

.btn-magic {
  background: var(--primary-light);
  color: var(--primary);
  border: 1px solid rgba(79, 70, 229, 0.2);
  padding: 0.45rem 0.75rem;
  border-radius: var(--radius-md);
  font-size: 0.825rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 0.35rem;
  cursor: pointer;
  transition: all 0.15s ease;
}

.btn-magic:hover {
  background: var(--primary);
  color: #FFFFFF;
}

.quick-suggestions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  margin-top: 0.65rem;
}

.chip-suggestion {
  font-size: 0.785rem;
  padding: 0.25rem 0.65rem;
  background: var(--bg-surface-alt);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-full);
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.15s ease;
}

.chip-suggestion:hover {
  background: var(--border-subtle);
  color: var(--text-main);
}

/* Style Matrix / Grid (10 Distinct Styles) */
.section-title {
  font-size: 0.925rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-dim);
  margin-bottom: 0.75rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

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

.style-card {
  position: relative;
  background: var(--bg-surface-alt);
  border: 1.5px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 0.75rem 0.5rem;
  text-align: center;
  cursor: pointer;
  transition: all 0.15s ease;
  user-select: none;
}

.style-card:hover {
  border-color: var(--border-strong);
  background: var(--bg-surface);
  transform: translateY(-1px);
}

.style-card.active {
  border-color: var(--primary);
  background: var(--primary-light);
  box-shadow: 0 0 0 1px var(--primary);
}

.style-icon-preview {
  font-size: 1.35rem;
  line-height: 1;
  margin-bottom: 0.35rem;
}

.style-card-name {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-main);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.style-badge {
  font-size: 0.65rem;
  color: var(--text-dim);
  display: block;
}

/* Concept / Icon Preset Selector */
.preset-search-bar {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 0.75rem;
}

.search-input {
  flex: 1;
  padding: 0.5rem 0.85rem;
  font-size: 0.875rem;
  background: var(--bg-surface-alt);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  color: var(--text-main);
}

.category-select {
  padding: 0.5rem 0.85rem;
  font-size: 0.875rem;
  background: var(--bg-surface-alt);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  color: var(--text-main);
  cursor: pointer;
}

.preset-scroll-container {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(56px, 1fr));
  gap: 0.5rem;
  max-height: 180px;
  overflow-y: auto;
  padding: 0.5rem;
  background: var(--bg-surface-alt);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  margin-bottom: 1.5rem;
}

.preset-item {
  width: 100%;
  aspect-ratio: 1;
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 4px;
  cursor: pointer;
  transition: all 0.12s ease;
}

.preset-item svg {
  width: 24px;
  height: 24px;
  color: var(--text-muted);
}

.preset-item:hover {
  border-color: var(--primary);
  background: var(--primary-light);
}

.preset-item.active {
  border-color: var(--primary);
  background: var(--primary-light);
  box-shadow: 0 0 0 1px var(--primary);
}

.preset-item.active svg {
  color: var(--primary);
}

/* Parametric Customizers (Sliders & Toggles) */
.customizer-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.control-group {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.control-label {
  font-size: 0.825rem;
  font-weight: 600;
  color: var(--text-muted);
  display: flex;
  justify-content: space-between;
}

.slider-input {
  width: 100%;
  accent-color: var(--primary);
  height: 6px;
  cursor: pointer;
}

/* Color Controls & Palettes */
.color-swatch-row {
  display: flex;
  gap: 0.75rem;
  align-items: center;
  margin-bottom: 1rem;
}

.color-picker-box {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex: 1;
  background: var(--bg-surface-alt);
  border: 1px solid var(--border-subtle);
  padding: 0.4rem 0.6rem;
  border-radius: var(--radius-md);
}

.color-input {
  width: 28px;
  height: 28px;
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  background: transparent;
}

.color-code-label {
  font-size: 0.8rem;
  font-family: var(--font-mono);
  color: var(--text-main);
  font-weight: 600;
}

.preset-palettes {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 1.5rem;
}

.palette-pill {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 4px 8px;
  background: var(--bg-surface-alt);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-full);
  cursor: pointer;
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--text-muted);
}

.palette-pill:hover {
  border-color: var(--primary);
}

.palette-dots {
  display: flex;
  gap: 2px;
}

.palette-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
}

/* Container Shape Selector */
.shape-selector-row {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 1.5rem;
}

.shape-btn {
  flex: 1;
  padding: 0.5rem;
  background: var(--bg-surface-alt);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  transition: all 0.12s ease;
}

.shape-btn:hover {
  border-color: var(--border-strong);
  color: var(--text-main);
}

.shape-btn.active {
  border-color: var(--primary);
  background: var(--primary-light);
  color: var(--primary);
}

/* ==========================================================================
   PREVIEW PANEL & MOCKUPS
   ========================================================================== */

.preview-tabs {
  display: flex;
  border-bottom: 1px solid var(--border-subtle);
  margin-bottom: 1.25rem;
  overflow-x: auto;
  gap: 0.25rem;
}

.preview-tab-btn {
  background: none;
  border: none;
  padding: 0.6rem 0.9rem;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  white-space: nowrap;
  transition: all 0.15s ease;
}

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

.preview-tab-btn.active {
  color: var(--primary);
  border-bottom-color: var(--primary);
}

/* Stage & Isolated Canvas */
.preview-stage {
  position: relative;
  min-height: 340px;
  display: grid;
  place-items: center;
  background: #E2E8F0;
  border-radius: var(--radius-lg);
  overflow: hidden;
  margin-bottom: 1.25rem;
  border: 1px solid var(--border-subtle);
}

[data-theme="dark"] .preview-stage {
  background: #0D131F;
}

/* Checkerboard transparency pattern */
.checkerboard {
  background-color: var(--bg-surface);
  background-image: 
    linear-gradient(45deg, var(--border-subtle) 25%, transparent 25%), 
    linear-gradient(-45deg, var(--border-subtle) 25%, transparent 25%), 
    linear-gradient(45deg, transparent 75%, var(--border-subtle) 75%), 
    linear-gradient(-45deg, transparent 75%, var(--border-subtle) 75%);
  background-size: 20px 20px;
  background-position: 0 0, 0 10px, 10px -10px, -10px 0px;
}

.main-icon-render {
  width: 220px;
  height: 220px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.2s ease;
}

.main-icon-render svg {
  width: 100%;
  height: 100%;
  display: block;
}

/* iOS Home Screen Mockup */
.ios-mockup {
  width: 280px;
  height: 380px;
  background: linear-gradient(180deg, #1E293B 0%, #0F172A 100%);
  border-radius: 36px;
  padding: 18px;
  border: 4px solid #334155;
  box-shadow: var(--shadow-xl);
  display: flex;
  flex-direction: column;
  color: #FFFFFF;
}

.ios-status-bar {
  display: flex;
  justify-content: space-between;
  font-size: 0.7rem;
  font-weight: 600;
  margin-bottom: 1.5rem;
  padding: 0 4px;
}

.ios-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  align-content: start;
  flex: 1;
}

.ios-app-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}

.ios-icon-slot {
  width: 48px;
  height: 48px;
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 4px 8px rgba(0,0,0,0.3);
}

.ios-icon-slot svg {
  width: 100%;
  height: 100%;
}

.ios-app-label {
  font-size: 0.625rem;
  color: #FFFFFF;
  text-shadow: 0 1px 2px rgba(0,0,0,0.8);
  white-space: nowrap;
}

.ios-dock {
  background: rgba(255,255,255,0.18);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-radius: 20px;
  padding: 8px 12px;
  display: flex;
  justify-content: space-around;
  margin-top: auto;
}

/* Android Adaptive Mockup */
.android-mockup-wrapper {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1.5rem;
  padding: 1.5rem;
}

.android-masks-row {
  display: flex;
  gap: 1.5rem;
}

.android-mask-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
}

.android-icon-box {
  width: 72px;
  height: 72px;
  box-shadow: var(--shadow-md);
  overflow: hidden;
}

.mask-circle { border-radius: 50%; }
.mask-squircle { border-radius: 20px; }
.mask-teardrop { border-radius: 50% 50% 50% 8px; }

/* Browser Tab Favicon Mockup */
.browser-mockup {
  width: 100%;
  max-width: 420px;
  background: var(--bg-surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  overflow: hidden;
}

.browser-bar {
  background: var(--bg-surface-alt);
  padding: 8px 12px;
  display: flex;
  align-items: center;
  gap: 8px;
  border-bottom: 1px solid var(--border-subtle);
}

.browser-dots {
  display: flex;
  gap: 4px;
}

.browser-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
}
.dot-red { background: #EF4444; }
.dot-yellow { background: #F59E0B; }
.dot-green { background: #10B981; }

.browser-tab {
  background: var(--bg-surface);
  padding: 4px 10px;
  border-radius: 6px 6px 0 0;
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--text-main);
  border: 1px solid var(--border-subtle);
  border-bottom: none;
}

.favicon-slot {
  width: 16px;
  height: 16px;
}

.favicon-slot svg {
  width: 100%;
  height: 100%;
}

.browser-content-area {
  padding: 2rem;
  text-align: center;
  color: var(--text-dim);
  font-size: 0.85rem;
}

/* Multi-Framework Code Viewer */
.code-viewer-container {
  width: 100%;
  background: #090D16;
  border-radius: var(--radius-md);
  padding: 1rem;
  max-height: 320px;
  overflow: auto;
  position: relative;
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.code-tabs-bar {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  margin-bottom: 0.75rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  padding-bottom: 0.5rem;
  overflow-x: auto;
}

.code-lang-tab {
  background: transparent;
  border: 1px solid transparent;
  color: #94A3B8;
  font-size: 0.75rem;
  font-weight: 600;
  padding: 0.3rem 0.65rem;
  border-radius: var(--radius-sm);
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.15s ease;
}

.code-lang-tab:hover {
  color: #F8FAFC;
  background: rgba(255, 255, 255, 0.06);
}

.code-lang-tab.active {
  background: var(--primary);
  color: #FFFFFF;
  border-color: var(--primary);
}

.code-header-actions {
  margin-left: auto;
}

.svg-code-pre {
  margin: 0;
  font-family: var(--font-mono);
  font-size: 0.785rem;
  color: #38BDF8;
  white-space: pre-wrap;
  word-break: break-word;
  overflow-wrap: anywhere;
  line-height: 1.5;
}

.code-copy-btn {
  background: rgba(255, 255, 255, 0.1);
  color: #FFFFFF;
  border: 1px solid rgba(255, 255, 255, 0.15);
  padding: 0.35rem 0.65rem;
  border-radius: var(--radius-sm);
  font-size: 0.75rem;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 0.35rem;
  transition: all 0.15s ease;
}

.code-copy-btn:hover {
  background: var(--primary);
  border-color: var(--primary);
}

/* Export Buttons & Actions */
.export-section {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.export-grid-primary {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.65rem;
}

.export-btn-zip {
  background: linear-gradient(135deg, var(--primary) 0%, var(--secondary) 100%);
  color: #FFFFFF;
  padding: 0.85rem 1.25rem;
  font-size: 0.95rem;
  font-weight: 700;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.65rem;
  border: none;
  cursor: pointer;
  box-shadow: 0 4px 12px var(--primary-glow);
  transition: all 0.15s ease;
}

.export-btn-zip:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 16px var(--primary-glow);
}

.resolution-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

.res-btn {
  font-size: 0.75rem;
  font-weight: 600;
  padding: 4px 8px;
  background: var(--bg-surface-alt);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  cursor: pointer;
}

.res-btn:hover {
  border-color: var(--primary);
  color: var(--primary);
}

/* Pack Grid & Multi-Glyph Harmonization */
.pack-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1rem;
  margin-bottom: 1.5rem;
}

/* Mobile Quick Action Dock */
.mobile-studio-dock {
  display: none;
}

/* Mobile Responsive Studio System */
@media (max-width: 960px) {
  .studio-grid {
    grid-template-columns: 1fr;
    gap: 1.5rem;
  }

  .studio-preview-panel {
    position: static;
    order: -1;
  }
}

@media (max-width: 768px) {
  .studio-wrapper {
    margin-top: 0.5rem;
    margin-bottom: 5.5rem; /* Room for mobile action dock */
  }

  .studio-panel {
    padding: 1.15rem;
    border-radius: var(--radius-lg);
  }

  .preview-tabs {
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
  }

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

  .preview-tab-btn {
    padding: 0.65rem 0.85rem;
    font-size: 0.825rem;
    min-height: 42px;
    flex-shrink: 0;
  }

  .preview-stage {
    min-height: 240px;
    padding: 1rem;
  }

  .main-icon-render {
    width: 170px;
    height: 170px;
  }

  .ios-mockup {
    max-width: 100%;
    width: 250px;
    height: 330px;
    padding: 14px;
    margin: 0 auto;
  }

  .ios-status-bar {
    margin-bottom: 1rem;
  }

  .ios-icon-slot {
    width: 40px;
    height: 40px;
    border-radius: 10px;
  }

  .android-masks-row {
    flex-wrap: wrap;
    justify-content: center;
    gap: 1rem;
  }

  .android-icon-box {
    width: 60px;
    height: 60px;
  }

  .browser-mockup {
    max-width: 100%;
  }

  .browser-content-area {
    padding: 1.25rem;
  }

  .code-viewer-container {
    padding: 0.75rem;
    max-height: 260px;
  }

  .code-tabs-bar {
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
  }

  .code-tabs-bar::-webkit-scrollbar {
    display: none;
  }

  .code-lang-tab {
    min-height: 38px;
    padding: 0.35rem 0.65rem;
    flex-shrink: 0;
  }

  .slider-input {
    height: 8px;
  }

  .slider-input::-webkit-slider-thumb {
    width: 22px;
    height: 22px;
  }

  .res-btn {
    min-height: 38px;
    min-width: 44px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 4px 10px;
  }

  .export-btn-zip {
    min-height: 48px;
    font-size: 0.9rem;
    padding: 0.75rem 1rem;
    width: 100%;
    text-align: center;
  }

  /* Fixed Mobile Action Dock */
  .mobile-studio-dock {
    display: flex;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: var(--bg-surface);
    border-top: 1px solid var(--border-strong);
    padding: 0.6rem 1rem;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    z-index: 90;
    box-shadow: 0 -4px 14px rgba(0, 0, 0, 0.12);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
  }

  .dock-preview-thumb {
    width: 42px;
    height: 42px;
    border-radius: var(--radius-sm);
    background: var(--bg-surface-alt);
    border: 1px solid var(--border-subtle);
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    flex-shrink: 0;
    cursor: pointer;
  }

  .dock-preview-thumb svg {
    width: 100%;
    height: 100%;
  }

  .dock-actions {
    display: flex;
    gap: 0.5rem;
    flex: 1;
  }

  .dock-actions .btn {
    flex: 1;
    min-height: 42px;
    font-size: 0.85rem;
    padding: 0.45rem 0.75rem;
  }
}

@media (max-width: 540px) {
  .prompt-input-wrapper {
    flex-direction: column;
    gap: 0.5rem;
    align-items: stretch;
  }

  .prompt-input {
    padding: 0.85rem 1rem;
    font-size: 16px; /* Prevents auto-zoom in iOS Safari */
  }

  .prompt-btn-group {
    position: static;
    display: flex;
    width: 100%;
  }

  .prompt-btn-group .btn {
    width: 100%;
    min-height: 44px;
    font-size: 0.95rem;
  }

  .prompt-label-bar {
    flex-wrap: wrap;
    gap: 0.5rem;
  }

  .btn-magic {
    min-height: 36px;
    padding: 0.4rem 0.65rem;
  }

  .chip-suggestion {
    min-height: 34px;
    display: inline-flex;
    align-items: center;
    padding: 0.35rem 0.75rem;
  }

  /* Style Selector on Mobile */
  .style-grid {
    grid-template-columns: repeat(auto-fill, minmax(95px, 1fr));
    gap: 0.5rem;
  }

  .style-card {
    padding: 0.65rem 0.4rem;
    min-height: 64px;
  }

  .style-card-name {
    font-size: 0.75rem;
  }

  /* Presets on Mobile */
  .preset-search-bar {
    flex-direction: column;
    gap: 0.5rem;
  }

  .search-input, .category-select {
    width: 100%;
    font-size: 16px; /* Prevents iOS auto-zoom */
    min-height: 42px;
  }

  .preset-scroll-container {
    grid-template-columns: repeat(auto-fill, minmax(44px, 1fr));
    gap: 0.4rem;
    max-height: 160px;
  }

  .preset-item {
    min-height: 44px;
  }

  /* Color Swatches 2x2 Grid on Mobile */
  .color-swatch-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.5rem;
  }

  .color-picker-box {
    min-height: 44px;
  }

  .color-input {
    width: 32px;
    height: 32px;
  }

  /* Shapes 3x2 Grid on Mobile */
  .shape-selector-row {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 0.45rem;
  }

  .shape-btn {
    min-height: 48px;
    padding: 0.45rem 0.25rem;
    font-size: 0.775rem;
  }

  /* Sliders Single Column on Mobile */
  .customizer-grid {
    grid-template-columns: 1fr;
    gap: 0.85rem;
  }

  /* Primary Export Buttons Stacked */
  .export-grid-primary {
    grid-template-columns: 1fr;
    gap: 0.5rem;
  }

  .export-grid-primary .btn {
    width: 100%;
    min-height: 46px;
    font-size: 0.9rem;
  }

  /* Pack Grid Responsive on Mobile */
  .pack-grid {
    grid-template-columns: repeat(2, 1fr) !important;
    gap: 0.65rem !important;
  }
}

@media (max-width: 360px) {
  .pack-grid {
    grid-template-columns: 1fr !important;
  }
}
