/* ================================================================
   Faith Schooling — Copywork Creator
   Premium App Styling
   ================================================================ */

/* ---- Light Mode Tokens ---- */
:root {
  --fs-bg:            #F9F5EF;
  --fs-primary:       #2D5016;
  --fs-primary-dark:  #1E3A0E;
  --fs-primary-glow:  rgba(45, 80, 22, 0.15);
  --fs-secondary:     #7B3F00;
  --fs-accent:        #C8860A;
  --fs-accent-light:  #E8A71E;
  --fs-earth:         #3D1C02;
  --fs-white:         #FFFFFF;

  --fs-text:          #1A0F00;
  --fs-text-light:    #4A3520;
  --fs-text-muted:    #7A6A55;

  --fs-card-bg:       #FFFFFF;
  --fs-card-shadow:   0 2px 12px rgba(61, 28, 2, 0.08);
  --fs-card-radius:   14px;

  --fs-border-light:  rgba(61, 28, 2, 0.10);
  --fs-divider:       rgba(61, 28, 2, 0.08);

  --fs-input-bg:      #FAFAFA;
  --fs-input-border:  rgba(61, 28, 2, 0.16);
  --fs-input-focus:   #2D5016;

  --fs-toolbar-bg:    linear-gradient(135deg, #1E3A0E 0%, #2D5016 40%, #3A6620 100%);
  --fs-toolbar-text:  #FFFFFF;
  --fs-toolbar-muted: rgba(255, 255, 255, 0.65);

  --fs-panel-bg:      #FFFFFF;
  --fs-panel-border:  rgba(61, 28, 2, 0.08);
  --fs-panel-header:  linear-gradient(180deg, #FAFAF7 0%, #F4F0EA 100%);
  --fs-panel-header-border: rgba(61, 28, 2, 0.10);
  --fs-panel-shadow:  0 4px 24px rgba(61, 28, 2, 0.10), 0 1px 3px rgba(61, 28, 2, 0.06);

  --fs-section-bg:    rgba(249, 245, 239, 0.50);
  --fs-section-border: rgba(61, 28, 2, 0.06);

  --fs-preview-bg:    #F0ECE5;
  --fs-preview-shadow: inset 0 2px 8px rgba(61, 28, 2, 0.08);

  --fs-workspace-bg:  linear-gradient(180deg, #EDE8DF 0%, #F4F0EA 50%, #F9F5EF 100%);
}

/* ---- Dark Mode Tokens ---- */
[data-theme="dark"] {
  --fs-bg:            #1A1410;
  --fs-primary:       #5A9B3A;
  --fs-primary-dark:  #4A8B2A;
  --fs-primary-glow:  rgba(90, 155, 58, 0.15);
  --fs-secondary:     #C8860A;
  --fs-accent:        #D4960A;
  --fs-accent-light:  #E8A71E;
  --fs-earth:         #C4B8A8;
  --fs-white:         #231A12;

  --fs-text:          #E8DDD0;
  --fs-text-light:    #C4B8A8;
  --fs-text-muted:    #8A7A65;

  --fs-card-bg:       #2A2018;
  --fs-card-shadow:   0 2px 12px rgba(0, 0, 0, 0.30);

  --fs-border-light:  rgba(232, 221, 208, 0.10);
  --fs-divider:       rgba(232, 221, 208, 0.06);

  --fs-input-bg:      #1E1610;
  --fs-input-border:  rgba(232, 221, 208, 0.16);
  --fs-input-focus:   #5A9B3A;

  --fs-toolbar-bg:    linear-gradient(135deg, #0D1A08 0%, #1A2E10 40%, #243D18 100%);
  --fs-toolbar-text:  #E8DDD0;
  --fs-toolbar-muted: rgba(232, 221, 208, 0.55);

  --fs-panel-bg:      #221A14;
  --fs-panel-border:  rgba(232, 221, 208, 0.06);
  --fs-panel-header:  linear-gradient(180deg, #2A2018 0%, #251C14 100%);
  --fs-panel-header-border: rgba(232, 221, 208, 0.08);
  --fs-panel-shadow:  0 4px 24px rgba(0, 0, 0, 0.30), 0 1px 3px rgba(0, 0, 0, 0.20);

  --fs-section-bg:    rgba(30, 22, 16, 0.60);
  --fs-section-border: rgba(232, 221, 208, 0.05);

  --fs-preview-bg:    #1A1410;
  --fs-preview-shadow: inset 0 2px 8px rgba(0, 0, 0, 0.20);

  --fs-workspace-bg:  linear-gradient(180deg, #141010 0%, #1A1410 50%, #1E1810 100%);
}

/* ================================================================
   RESET / BASE
   ================================================================ */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: 'Inter', sans-serif;
  background: var(--fs-bg);
  color: var(--fs-text);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow-x: hidden;
}

/* ================================================================
   APP SHELL
   ================================================================ */
.app-shell {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ================================================================
   APP TOOLBAR  (premium dark header)
   ================================================================ */
.app-toolbar {
  background: var(--fs-toolbar-bg);
  color: var(--fs-toolbar-text);
  padding: 0;
  box-shadow: 0 2px 16px rgba(0, 0, 0, 0.20), 0 1px 3px rgba(0, 0, 0, 0.10);
  position: relative;
  z-index: 10;
}

.app-toolbar::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: linear-gradient(90deg, var(--fs-accent) 0%, var(--fs-accent-light) 50%, var(--fs-accent) 100%);
}

.toolbar-inner {
  max-width: 1360px;
  margin: 0 auto;
  padding: 16px 28px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
}

.toolbar-brand {
  display: flex;
  align-items: center;
  gap: 16px;
}

.toolbar-logo-wrap {
  width: 52px;
  height: 52px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.12);
  border: 1px solid rgba(255, 255, 255, 0.15);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.toolbar-logo {
  width: 40px;
  height: 40px;
  object-fit: contain;
  border-radius: 6px;
}

.toolbar-title {
  font-family: 'Playfair Display', serif;
  font-weight: 700;
  font-size: 24px;
  color: var(--fs-toolbar-text);
  line-height: 1.15;
  letter-spacing: -0.3px;
}

.toolbar-tagline {
  font-size: 12px;
  font-weight: 500;
  color: var(--fs-toolbar-muted);
  margin-top: 2px;
  letter-spacing: 0.3px;
  text-transform: uppercase;
}

.mobile-tool-tabs {
  display: none;
}

/* ---- Toolbar badges ---- */
.toolbar-badges {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 5px 12px;
  font-size: 11px;
  font-weight: 600;
  border-radius: 20px;
  letter-spacing: 0.3px;
  white-space: nowrap;
}

.badge-free {
  background: rgba(200, 134, 10, 0.20);
  color: var(--fs-accent-light);
  border: 1px solid rgba(200, 134, 10, 0.30);
}

.badge-pdf {
  background: rgba(255, 255, 255, 0.08);
  color: rgba(255, 255, 255, 0.75);
  border: 1px solid rgba(255, 255, 255, 0.12);
}

.badge-grade {
  background: rgba(255, 255, 255, 0.08);
  color: rgba(255, 255, 255, 0.75);
  border: 1px solid rgba(255, 255, 255, 0.12);
}

/* ================================================================
   WORKSPACE  (main area with panels)
   ================================================================ */
.workspace {
  flex: 1;
  background: var(--fs-workspace-bg);
  padding: 28px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
  align-items: start;
  max-width: 1360px;
  margin: 0 auto;
  width: 100%;
}

/* ================================================================
   PANELS  (app-like cards)
   ================================================================ */
.panel {
  background: var(--fs-panel-bg);
  border-radius: var(--fs-card-radius);
  box-shadow: var(--fs-panel-shadow);
  border: 1px solid var(--fs-panel-border);
  overflow: hidden;
}

.panel-header {
  background: var(--fs-panel-header);
  border-bottom: 1px solid var(--fs-panel-header-border);
  padding: 12px 20px;
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  font-weight: 600;
  color: var(--fs-text-light);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.panel-icon {
  color: var(--fs-primary);
  flex-shrink: 0;
}

.panel-body {
  padding: 20px;
}

/* ================================================================
   SETTINGS SECTIONS  (grouped form areas)
   ================================================================ */
.settings-section {
  background: var(--fs-section-bg);
  border: 1px solid var(--fs-section-border);
  border-radius: 10px;
  padding: 16px;
  margin-bottom: 16px;
}

.settings-section:last-of-type {
  margin-bottom: 0;
}

.section-label {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 11px;
  font-weight: 700;
  color: var(--fs-primary);
  text-transform: uppercase;
  letter-spacing: 0.7px;
  margin-bottom: 14px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--fs-divider);
}

.section-label svg {
  color: var(--fs-primary);
  opacity: 0.70;
}

/* ================================================================
   FORM INPUTS
   ================================================================ */
.form-group { margin-bottom: 14px; }
.form-group:last-child { margin-bottom: 0; }

.form-group > label {
  display: block;
  font-weight: 600;
  font-size: 11px;
  color: var(--fs-text-muted);
  margin-bottom: 5px;
  text-transform: uppercase;
  letter-spacing: 0.4px;
}

.form-group input[type="text"],
.form-group select,
.form-group textarea {
  width: 100%;
  padding: 10px 14px;
  font-family: 'Inter', sans-serif;
  font-size: 14px;
  color: var(--fs-text);
  background: var(--fs-input-bg);
  border: 1px solid var(--fs-input-border);
  border-radius: 8px;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.form-group input[type="text"]:focus,
.form-group select:focus,
.form-group textarea:focus {
  border-color: var(--fs-input-focus);
  box-shadow: 0 0 0 3px var(--fs-primary-glow);
  background: var(--fs-card-bg);
}

.form-group select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%234A3520' stroke-width='1.5' fill='none'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 34px;
  cursor: pointer;
}

[data-theme="dark"] .form-group select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%23C4B8A8' stroke-width='1.5' fill='none'/%3E%3C/svg%3E");
}

.form-group textarea {
  resize: vertical;
  min-height: 100px;
  line-height: 1.6;
}

/* ---- Form row (side-by-side) ---- */
.form-row {
  display: flex;
  gap: 12px;
}

.form-group-half {
  flex: 1;
}

/* ================================================================
   TOGGLE GROUPS  (replacing radio buttons)
   ================================================================ */
.toggle-group {
  display: flex;
  gap: 0;
  background: var(--fs-input-bg);
  border: 1px solid var(--fs-input-border);
  border-radius: 8px;
  padding: 3px;
  overflow: hidden;
}

.toggle-group-3 .toggle-option {
  flex: 1;
}

.toggle-option {
  flex: 1;
  position: relative;
}

.toggle-option input[type="radio"] {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}

.toggle-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 12px;
  font-family: 'Inter', sans-serif;
  font-size: 13px;
  font-weight: 500;
  color: var(--fs-text-muted);
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.2s ease;
  text-align: center;
  white-space: nowrap;
  user-select: none;
}

.toggle-btn svg {
  flex-shrink: 0;
  opacity: 0.6;
  transition: opacity 0.2s;
}

.toggle-option input[type="radio"]:checked + .toggle-btn {
  background: var(--fs-primary);
  color: #FFFFFF;
  box-shadow: 0 2px 8px rgba(45, 80, 22, 0.25);
  font-weight: 600;
}

.toggle-option input[type="radio"]:checked + .toggle-btn svg {
  opacity: 1;
}

.toggle-btn:hover {
  background: var(--fs-divider);
  color: var(--fs-text);
}

.toggle-option input[type="radio"]:checked + .toggle-btn:hover {
  background: var(--fs-primary-dark);
  color: #FFFFFF;
}

[data-theme="dark"] .toggle-option input[type="radio"]:checked + .toggle-btn {
  box-shadow: 0 2px 8px rgba(90, 155, 58, 0.20);
}

/* ================================================================
   SAMPLE CONTENT BUTTONS
   ================================================================ */
.sample-buttons {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.btn-sample {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 6px 12px;
  font-family: 'Inter', sans-serif;
  font-size: 11px;
  font-weight: 600;
  color: var(--fs-secondary);
  background: transparent;
  border: 1px solid var(--fs-secondary);
  border-radius: 7px;
  cursor: pointer;
  transition: all 0.2s ease;
  white-space: nowrap;
}

.btn-sample svg {
  flex-shrink: 0;
  opacity: 0.7;
}

.btn-sample:hover {
  background: var(--fs-secondary);
  color: #FFFFFF;
  transform: translateY(-1px);
  box-shadow: 0 2px 8px rgba(123, 63, 0, 0.20);
}

.btn-sample:hover svg { opacity: 1; }

.btn-sample.active {
  background: var(--fs-secondary);
  color: #FFFFFF;
}

.btn-sample.active svg { opacity: 1; }

/* ================================================================
   GENERATE BUTTON
   ================================================================ */
.btn-generate {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  width: 100%;
  margin-top: 20px;
  padding: 15px 24px;
  font-family: 'Inter', sans-serif;
  font-size: 15px;
  font-weight: 700;
  color: #FFFFFF;
  background: linear-gradient(135deg, var(--fs-primary) 0%, var(--fs-primary-dark) 100%);
  border: none;
  border-radius: 10px;
  cursor: pointer;
  transition: all 0.25s ease;
  letter-spacing: 0.3px;
  box-shadow: 0 4px 16px rgba(45, 80, 22, 0.30), inset 0 1px 0 rgba(255, 255, 255, 0.10);
  position: relative;
  overflow: hidden;
}

.btn-generate::before {
  content: '';
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.08), transparent);
  transition: left 0.5s ease;
}

.btn-generate:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 24px rgba(45, 80, 22, 0.40), inset 0 1px 0 rgba(255, 255, 255, 0.12);
}

.btn-generate:hover::before {
  left: 100%;
}

.btn-generate:active {
  transform: translateY(0);
  box-shadow: 0 2px 8px rgba(45, 80, 22, 0.30);
}

.btn-generate:disabled {
  opacity: 0.65;
  cursor: wait;
  transform: none;
}

.btn-generate svg {
  flex-shrink: 0;
}

/* ================================================================
   PREVIEW PANEL
   ================================================================ */
.panel-preview {
  position: sticky;
  top: 16px;
}

.panel-header-preview {
  justify-content: flex-start;
}

.preview-hint {
  margin-left: auto;
  font-size: 10px;
  font-weight: 500;
  color: var(--fs-text-muted);
  text-transform: none;
  letter-spacing: 0;
  opacity: 0.7;
}

.preview-body {
  padding: 16px;
}

.preview-container {
  background: var(--fs-preview-bg);
  box-shadow: var(--fs-preview-shadow);
  border-radius: 8px;
  padding: 16px;
  display: flex;
  justify-content: center;
  overflow: hidden;
}

.preview-container canvas {
  background: #FFFFFF;
  box-shadow:
    0 2px 12px rgba(0, 0, 0, 0.12),
    0 0 0 1px rgba(0, 0, 0, 0.06);
  border-radius: 2px;
  max-width: 100%;
  height: auto;
}

/* ================================================================
   APP FOOTER
   ================================================================ */
.app-footer {
  background: var(--fs-panel-header);
  border-top: 1px solid var(--fs-panel-header-border);
  padding: 12px 28px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px;
}

.footer-brand {
  font-size: 11px;
  font-weight: 600;
  color: var(--fs-text-muted);
  letter-spacing: 0.3px;
}

.footer-features {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  color: var(--fs-text-muted);
  flex-wrap: wrap;
}

.footer-dot {
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: var(--fs-accent);
  display: inline-block;
}

.footer-dot:first-child {
  display: none;
}

/* ================================================================
   TOAST NOTIFICATION
   ================================================================ */
.toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  background: linear-gradient(135deg, var(--fs-primary) 0%, var(--fs-primary-dark) 100%);
  color: #FFFFFF;
  padding: 14px 24px;
  border-radius: 10px;
  font-family: 'Inter', sans-serif;
  font-size: 14px;
  font-weight: 600;
  box-shadow: 0 6px 24px rgba(0, 0, 0, 0.25);
  transform: translateY(100px);
  opacity: 0;
  transition: transform 0.35s ease, opacity 0.35s ease;
  pointer-events: none;
  z-index: 1000;
}

.toast.show {
  transform: translateY(0);
  opacity: 1;
}

/* ================================================================
   RESPONSIVE  (<960 px → adjust panel sizing)
   ================================================================ */
@media (max-width: 960px) {
  .workspace {
    grid-template-columns: 1fr 1fr;
    padding: 20px 16px;
    gap: 16px;
  }

  .toolbar-inner {
    padding: 14px 16px;
  }

  .toolbar-badges { display: none; }
}

/* ================================================================
   RESPONSIVE  (<768 px → single column)
   ================================================================ */
@media (max-width: 768px) {
  html,
  body {
    max-width: 100%;
    overflow-x: hidden;
  }

  .app-shell,
  .app-toolbar,
  .workspace,
  .panel {
    max-width: 100%;
    min-width: 0;
  }

  .mobile-tool-tabs {
    background: var(--fs-bg);
    border-bottom: 1px solid var(--fs-border-light);
    display: grid;
    gap: 8px;
    grid-template-columns: 1fr 1fr;
    padding: 10px 12px;
    position: sticky;
    top: 0;
    z-index: 20;
  }

  .mobile-tool-tab {
    background: var(--fs-card-bg);
    border: 1px solid var(--fs-input-border);
    border-radius: 8px;
    color: var(--fs-text-light);
    font-weight: 700;
    min-height: 42px;
  }

  .mobile-tool-tab.active {
    background: var(--fs-primary);
    border-color: var(--fs-primary);
    color: #fff;
  }

  .workspace {
    grid-template-columns: 1fr;
    padding: 16px 12px;
  }

  body.copywork-view-settings .panel-preview,
  body.copywork-view-preview .panel-settings {
    display: none;
  }

  body.copywork-view-preview .panel-preview {
    display: block;
  }

  .panel-preview {
    position: static;
  }

  .toolbar-title { font-size: 20px; }
  .toolbar-tagline { font-size: 11px; }

  .toolbar-logo-wrap {
    width: 44px;
    height: 44px;
  }

  .toolbar-logo {
    width: 34px;
    height: 34px;
  }

  .toolbar-brand,
  .toolbar-title-group {
    min-width: 0;
  }

  .toolbar-title-group {
    max-width: calc(100vw - 92px);
  }

  .toolbar-tagline {
    line-height: 1.25;
    max-width: 100%;
    overflow-wrap: anywhere;
    white-space: normal;
  }

  .panel-body { padding: 16px; }
  .settings-section { padding: 12px; }

  .form-row {
    flex-direction: column;
    gap: 0;
  }

  .toggle-group-3 {
    display: grid;
    grid-template-columns: 1fr;
  }

  .toggle-group-3 .toggle-option {
    min-width: 0;
  }

  .sample-buttons {
    display: grid;
    grid-template-columns: 1fr 1fr;
  }

  .app-footer {
    flex-direction: column;
    text-align: center;
    gap: 4px;
    padding: 10px 12px;
  }

  .footer-features { justify-content: center; }
}

@media (max-width: 480px) {
  .toolbar-inner {
    padding: 12px;
    gap: 10px;
  }

  .toolbar-brand { gap: 10px; }

  .toolbar-logo-wrap {
    width: 38px;
    height: 38px;
    border-radius: 8px;
  }

  .toolbar-logo {
    width: 28px;
    height: 28px;
  }

  .toolbar-title {
    font-size: 18px;
    max-width: 100%;
    overflow-wrap: anywhere;
  }
  .toolbar-tagline {
    font-size: 10px;
    max-width: 220px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .workspace { padding: 12px 8px; }
  .panel-body { padding: 12px; }
  .settings-section { padding: 10px; }

  .form-row {
    flex-direction: column;
    gap: 0;
  }

  .toggle-btn { padding: 7px 8px; font-size: 12px; }
  .toggle-btn svg { display: none; }
  .toggle-group {
    min-width: 0;
    width: 100%;
  }
  .toggle-group-3 {
    display: grid;
    grid-template-columns: 1fr;
  }
  .toggle-group-3 .toggle-option {
    min-width: 0;
  }

  .btn-sample { font-size: 10px; padding: 5px 9px; }
  .btn-sample svg { display: none; }
  .sample-buttons {
    display: grid;
    grid-template-columns: 1fr 1fr;
  }

  .btn-generate { padding: 13px 20px; font-size: 14px; }

  .preview-body { padding: 10px; }
  .preview-container { padding: 10px; }

  .app-footer { font-size: 10px; }
  .footer-features { font-size: 10px; }
}

/* ================================================================
   SCROLLBAR STYLING  (premium detail)
   ================================================================ */
.panel-body::-webkit-scrollbar,
.preview-body::-webkit-scrollbar {
  width: 6px;
}

.panel-body::-webkit-scrollbar-track,
.preview-body::-webkit-scrollbar-track {
  background: transparent;
}

.panel-body::-webkit-scrollbar-thumb,
.preview-body::-webkit-scrollbar-thumb {
  background: var(--fs-border-light);
  border-radius: 3px;
}

/* ================================================================
   SUBTLE ANIMATIONS
   ================================================================ */
.panel {
  animation: panelSlideIn 0.4s ease both;
}

.panel-settings { animation-delay: 0.05s; }
.panel-preview  { animation-delay: 0.15s; }

@keyframes panelSlideIn {
  from {
    opacity: 0;
    transform: translateY(12px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.settings-section {
  transition: box-shadow 0.2s ease;
}

.settings-section:hover {
  box-shadow: 0 1px 6px rgba(61, 28, 2, 0.06);
}

[data-theme="dark"] .settings-section:hover {
  box-shadow: 0 1px 6px rgba(0, 0, 0, 0.15);
}
