/* ==========================================================================
   Instagram Post & Carousel Studio - PicDriver
   ========================================================================== */

/* Main Layout */
.post-studio-container {
  display: grid;
  grid-template-columns: 1fr 400px;
  gap: 24px;
  max-width: 1440px;
  margin: 0 auto;
  padding: 24px;
  min-height: calc(100vh - 140px);
}

@media (max-width: 1024px) {
  .post-studio-container {
    grid-template-columns: 1fr;
    padding: 16px;
  }
}

/* Left: Stage Area */
.post-stage-col {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.post-stage-wrapper {
  position: relative;
  background: #080c14;
  border: 1px solid var(--border-subtle, rgba(255, 255, 255, 0.08));
  border-radius: var(--radius-lg, 16px);
  min-height: 520px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  box-shadow: inset 0 2px 10px rgba(0, 0, 0, 0.5), 0 8px 32px rgba(0, 0, 0, 0.3);
  padding: 24px;
  user-select: none;
}

/* Canvas Viewport */
.canvas-viewport-container {
  position: relative;
  max-width: 100%;
  max-height: 70vh;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 14px 45px rgba(0, 0, 0, 0.7);
  border-radius: 8px;
  overflow: hidden;
  background: #000;
  transition: all 0.3s ease;
}

#postCanvas {
  display: block;
  max-width: 100%;
  max-height: 68vh;
  object-fit: contain;
}

/* Authentic Instagram Mockup Phone Frame (Optional Toggle) */
.instagram-mockup-frame {
  background: #000000;
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 24px;
  width: 100%;
  max-width: 440px;
  overflow: hidden;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.8);
  display: none;
}

.instagram-mockup-frame.show {
  display: block;
}

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

.mockup-user {
  display: flex;
  align-items: center;
  gap: 10px;
}

.mockup-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: linear-gradient(135deg, #f59e0b, #ec4899, #8b5cf6);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: bold;
}

.mockup-username {
  font-size: 0.85rem;
  font-weight: 700;
  color: #fff;
}

.mockup-footer {
  padding: 12px 16px;
}

.mockup-actions-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 1.2rem;
  margin-bottom: 8px;
  color: #ffffff;
}

.mockup-caption-text {
  font-size: 0.82rem;
  color: #e2e8f0;
  line-height: 1.4;
}

/* Stage HUD Overlay */
.stage-hud {
  position: absolute;
  top: 14px;
  left: 14px;
  right: 14px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  pointer-events: none;
  z-index: 30;
}

.hud-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: rgba(15, 23, 42, 0.85);
  backdrop-filter: blur(12px);
  border: 1px solid rgba(255, 255, 255, 0.12);
  padding: 6px 14px;
  border-radius: var(--radius-full, 9999px);
  font-size: 0.78rem;
  font-family: var(--font-mono, monospace);
  color: var(--text-primary, #ffffff);
}

.hud-dot {
  width: 8px;
  height: 8px;
  background: #ec4899;
  border-radius: 50%;
  box-shadow: 0 0 8px #ec4899;
}

/* Multi-Slide Carousel Navigation Bar */
.carousel-nav-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  max-width: 480px;
  margin-top: 14px;
  gap: 12px;
  background: rgba(15, 23, 42, 0.75);
  backdrop-filter: blur(10px);
  border: 1px solid rgba(255, 255, 255, 0.1);
  padding: 8px 16px;
  border-radius: var(--radius-full, 9999px);
}

.slide-dots-group {
  display: flex;
  align-items: center;
  gap: 6px;
  overflow-x: auto;
}

.slide-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.25);
  border: none;
  cursor: pointer;
  transition: all 0.2s ease;
}

.slide-dot.active {
  background: #ec4899;
  transform: scale(1.3);
  box-shadow: 0 0 8px #ec4899;
}

/* Quick Action Download Bar */
.action-download-bar {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

/* Right Controls Column */
.tool-controls-panel {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.control-section {
  background: var(--bg-card, #0e1524);
  border: 1px solid var(--border-subtle, rgba(255, 255, 255, 0.08));
  border-radius: var(--radius-md, 12px);
  padding: 16px;
}

.control-title {
  font-size: 0.88rem;
  font-weight: 700;
  color: var(--text-primary, #ffffff);
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  gap: 8px;
}

/* Format Aspect Ratio Selector */
.aspect-ratio-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

.aspect-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  background: var(--bg-surface, #131d31);
  border: 1px solid var(--border-subtle, rgba(255, 255, 255, 0.1));
  border-radius: var(--radius-sm, 8px);
  padding: 12px 6px;
  cursor: pointer;
  transition: all 0.2s ease;
  color: var(--text-secondary, #94a3b8);
}

.aspect-btn:hover {
  border-color: #ec4899;
  color: #ffffff;
}

.aspect-btn.active {
  border-color: #ec4899;
  background: rgba(236, 72, 153, 0.15);
  color: #ffffff;
  box-shadow: 0 2px 10px rgba(236, 72, 153, 0.3);
}

.aspect-icon-box {
  border: 1.5px solid currentColor;
  border-radius: 3px;
}

/* Template Cards Grid */
.template-cards-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
}

.template-card-choice {
  background: var(--bg-surface, #131d31);
  border: 1px solid var(--border-subtle, rgba(255, 255, 255, 0.08));
  border-radius: var(--radius-sm, 8px);
  padding: 10px;
  cursor: pointer;
  text-align: center;
  transition: all 0.2s ease;
  color: var(--text-secondary, #94a3b8);
  font-size: 0.8rem;
  font-weight: 600;
}

.template-card-choice:hover {
  border-color: #ec4899;
  color: #fff;
}

.template-card-choice.active {
  border-color: #ec4899;
  background: linear-gradient(135deg, rgba(236, 72, 153, 0.25) 0%, rgba(139, 92, 246, 0.25) 100%);
  color: #ffffff;
}

/* Text Inputs */
.input-group {
  margin-bottom: 12px;
}

.input-label {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-secondary, #94a3b8);
  margin-bottom: 6px;
  display: block;
}

.styled-text-input {
  width: 100%;
  padding: 9px 12px;
  background: #131d31;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 6px;
  color: #fff;
  font-size: 0.84rem;
  outline: none;
}

.styled-text-input:focus {
  border-color: #ec4899;
}

/* Range Slider & Font Controls */
.range-slider-row {
  display: flex;
  align-items: center;
  gap: 12px;
}

.styled-range-input {
  flex: 1;
  -webkit-appearance: none;
  appearance: none;
  height: 6px;
  background: rgba(255, 255, 255, 0.15);
  border-radius: 3px;
  outline: none;
  cursor: pointer;
}

.styled-range-input::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #ec4899;
  cursor: pointer;
  box-shadow: 0 0 8px rgba(236, 72, 153, 0.6);
  transition: transform 0.15s ease;
}

.styled-range-input::-webkit-slider-thumb:hover {
  transform: scale(1.2);
}

/* Color Controls & Swatches */
.color-control-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 12px;
  background: #131d31;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 8px;
  margin-bottom: 8px;
}

.color-picker-wrapper {
  display: flex;
  align-items: center;
  gap: 8px;
}

.styled-color-picker {
  -webkit-appearance: none;
  appearance: none;
  border: 2px solid rgba(255, 255, 255, 0.25);
  width: 30px;
  height: 30px;
  border-radius: 6px;
  cursor: pointer;
  background: transparent;
  padding: 0;
  outline: none;
}

.styled-color-picker::-webkit-color-swatch-wrapper {
  padding: 0;
}

.styled-color-picker::-webkit-color-swatch {
  border: none;
  border-radius: 4px;
}

.quick-color-dots {
  display: flex;
  align-items: center;
  gap: 6px;
}

.color-dot-choice {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, 0.25);
  cursor: pointer;
  padding: 0;
  transition: transform 0.15s ease, border-color 0.15s ease;
}

.color-dot-choice:hover {
  transform: scale(1.3);
  border-color: #ffffff;
}

/* Upload Dropzone */
.dropzone-compact {
  position: relative;
  display: block;
  border: 2px dashed rgba(236, 72, 153, 0.35);
  border-radius: var(--radius-md, 12px);
  padding: 16px 12px;
  text-align: center;
  background: rgba(15, 23, 42, 0.5);
  cursor: pointer;
  transition: all 0.25s ease;
  margin-bottom: 12px;
  overflow: hidden;
  user-select: none;
}

.dropzone-compact:hover,
.dropzone-compact.drag-over {
  border-color: #ec4899;
  background: rgba(236, 72, 153, 0.12);
  transform: translateY(-1px);
  box-shadow: 0 4px 16px rgba(236, 72, 153, 0.2);
}

.dropzone-icon {
  font-size: 1.6rem;
  margin-bottom: 4px;
}

.dropzone-text {
  font-size: 0.84rem;
  font-weight: 600;
  color: var(--text-primary, #ffffff);
}

.dropzone-browse-link {
  color: #ec4899;
  text-decoration: underline;
  font-weight: 700;
}

.dropzone-sub {
  font-size: 0.7rem;
  color: var(--text-muted, #64748b);
  margin-top: 3px;
}

/* Background Color / Gradient Swatches */
.bg-swatches-row {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 4px;
}

.bg-swatch {
  width: 34px;
  height: 34px;
  border-radius: 6px;
  border: 2px solid transparent;
  cursor: pointer;
  flex: 0 0 auto;
  transition: transform 0.2s ease, border-color 0.2s ease;
}

.bg-swatch:hover {
  transform: scale(1.1);
}

.bg-swatch.active {
  border-color: #ec4899;
  box-shadow: 0 0 10px rgba(236, 72, 153, 0.5);
}

/* Toast Pill */
.toast-pill {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(100px);
  background: rgba(15, 23, 42, 0.95);
  backdrop-filter: blur(16px);
  border: 1px solid #ec4899;
  color: #fff;
  padding: 10px 24px;
  border-radius: var(--radius-full, 9999px);
  font-size: 0.85rem;
  font-weight: 600;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
  pointer-events: none;
  opacity: 0;
  transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  z-index: 100000;
}

.toast-pill.show {
  transform: translateX(-50%) translateY(0);
  opacity: 1;
}

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

/* Toggle Switch Safeguards */
.switch-toggle,
.toggle-switch {
  position: relative !important;
  display: inline-block !important;
  width: 44px !important;
  height: 24px !important;
  flex-shrink: 0;
  vertical-align: middle;
}

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

.toggle-slider {
  position: absolute !important;
  cursor: pointer;
  top: 0; left: 0; right: 0; bottom: 0;
  background-color: rgba(255, 255, 255, 0.15);
  transition: .2s;
  border-radius: 24px;
}

.toggle-slider:before {
  position: absolute;
  content: "";
  height: 18px;
  width: 18px;
  left: 3px;
  bottom: 3px;
  background-color: white;
  transition: .2s;
  border-radius: 50%;
}

.switch-toggle input:checked + .toggle-slider,
.toggle-switch input:checked + .toggle-slider {
  background-color: #ec4899;
}

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

/* Educational SEO Guide Section */
.seo-guide-container {
  max-width: 1200px;
  margin: 48px auto;
  padding: 0 24px;
  color: var(--text-secondary, #94a3b8);
  line-height: 1.7;
}

.seo-guide-container h2 {
  color: var(--text-primary, #ffffff);
  font-size: 1.6rem;
  font-weight: 800;
  margin: 32px 0 16px;
  border-left: 4px solid #ec4899;
  padding-left: 14px;
}

.seo-guide-container h3 {
  color: var(--text-primary, #ffffff);
  font-size: 1.25rem;
  font-weight: 700;
  margin: 24px 0 12px;
}

.seo-guide-container p {
  margin-bottom: 16px;
}

.seo-guide-container ul,
.seo-guide-container ol {
  margin: 12px 0 20px 24px;
}

.seo-guide-container li {
  margin-bottom: 8px;
}

.faq-accordion {
  margin-top: 24px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.faq-item {
  background: var(--bg-card, #0e1524);
  border: 1px solid var(--border-subtle, rgba(255, 255, 255, 0.08));
  border-radius: var(--radius-md, 12px);
  padding: 16px 20px;
}

.faq-question {
  color: var(--text-primary, #ffffff);
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.faq-answer {
  margin-top: 10px;
  font-size: 0.9rem;
  color: var(--text-secondary, #94a3b8);
  line-height: 1.6;
}

/* Fluid Canvas Constraint & Mobile Responsiveness */
canvas,
#postCanvas {
  max-width: 100%;
  height: auto;
}

@media (max-width: 768px) {
  .post-studio-container {
    grid-template-columns: 1fr;
    padding: 12px;
    gap: 16px;
  }

  .post-stage-wrapper {
    min-height: 380px;
    padding: 16px;
  }

  .carousel-nav-bar {
    max-width: 100%;
    padding: 6px 12px;
  }

  .aspect-ratio-grid {
    grid-template-columns: repeat(3, 1fr);
    gap: 6px;
  }

  .template-cards-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .action-download-bar {
    flex-direction: column;
    width: 100%;
  }

  .action-download-bar button {
    width: 100%;
  }
}
