/* ============================================================
   CVFlow — Editor Page Styles
   ============================================================ */

.editor-body {
  overflow: hidden;
  height: 100vh;
  display: flex;
  flex-direction: column;
}

/* =====================
   EDITOR NAVBAR
   ===================== */
.editor-navbar {
  height: var(--navbar-height);
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 var(--space-5);
  gap: var(--space-4);
  flex-shrink: 0;
  z-index: var(--z-fixed);
  box-shadow: var(--shadow-sm);
}

.editor-nav-left {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  flex: 1;
  min-width: 0;
}

.editor-back {
  flex-shrink: 0;
}

.editor-template-info {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.editor-template-name {
  font-size: var(--text-sm);
  font-weight: var(--font-semibold);
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.editor-save-status {
  font-size: var(--text-xs);
  color: var(--brand-success);
  display: flex;
  align-items: center;
  gap: 4px;
}

.editor-nav-center {
  flex-shrink: 0;
}

.preview-breakpoints {
  display: flex;
  background: var(--bg-elevated);
  border-radius: var(--radius-lg);
  padding: 3px;
  gap: 2px;
}

.bp-btn {
  width: 34px;
  height: 28px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: var(--text-sm);
  color: var(--text-muted);
  cursor: pointer;
  background: none;
  border: none;
  transition: all var(--transition-fast);
}

.bp-btn.active, .bp-btn:hover {
  background: var(--bg-surface);
  color: var(--brand-primary);
  box-shadow: var(--shadow-sm);
}

.editor-nav-right {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  flex-shrink: 0;
}

/* =====================
   EDITOR LAYOUT
   ===================== */
.editor-layout {
  display: flex;
  flex: 1;
  min-height: 0;
  overflow: hidden;
}

/* =====================
   LEFT PANEL
   ===================== */
.editor-panel {
  width: 360px;
  flex-shrink: 0;
  background: var(--bg-surface);
  border-right: 1px solid var(--border-subtle);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* Tabs */
.panel-tabs {
  display: flex;
  border-bottom: 1px solid var(--border-subtle);
  flex-shrink: 0;
}

.panel-tab {
  flex: 1;
  padding: var(--space-3);
  font-size: var(--text-sm);
  font-weight: var(--font-medium);
  color: var(--text-muted);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  background: none;
  border-left: none;
  border-right: none;
  border-top: none;
  transition: all var(--transition-fast);
}

.panel-tab:hover { color: var(--brand-primary); }

.panel-tab.active {
  color: var(--brand-primary);
  border-bottom-color: var(--brand-primary);
  background: rgba(99, 102, 241, 0.04);
}

/* Panel Content scrollable area */
.panel-content {
  display: none;
  flex: 1;
  overflow-y: auto;
  padding: var(--space-4);
}

.panel-content.active { display: block; }

/* Custom scrollbar in panel */
.panel-content::-webkit-scrollbar { width: 4px; }
.panel-content::-webkit-scrollbar-track { background: transparent; }
.panel-content::-webkit-scrollbar-thumb { background: var(--border-default); border-radius: 4px; }

/* =====================
   FORM SECTIONS (Collapsible)
   ===================== */
.form-section {
  margin-bottom: var(--space-3);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-xl);
  overflow: hidden;
  background: var(--bg-base);
}

.form-section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-3) var(--space-4);
  font-size: var(--text-sm);
  font-weight: var(--font-semibold);
  color: var(--text-primary);
  cursor: pointer;
  background: var(--bg-surface);
  user-select: none;
  transition: background var(--transition-fast);
}

.form-section-header:hover { background: var(--bg-elevated); }

.form-section-header span {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  color: var(--brand-primary);
}

.form-section-header i:not(.section-arrow) {
  font-size: var(--text-sm);
}

.section-arrow {
  color: var(--text-muted);
  font-size: var(--text-xs);
  transition: transform var(--transition-fast);
}

.form-section.collapsed .section-arrow { transform: rotate(-90deg); }

.form-section-body {
  padding: var(--space-4);
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  border-top: 1px solid var(--border-subtle);
}

.form-section.collapsed .form-section-body { display: none; }

/* Grid helper */
.form-grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-3);
}

.form-hint {
  font-size: var(--text-xs);
  color: var(--text-muted);
  margin-top: 2px;
}

.char-count {
  font-size: var(--text-xs);
  color: var(--text-muted);
  text-align: right;
}

/* Input with icon */
.input-with-icon {
  position: relative;
  display: flex;
  align-items: center;
}

.input-icon {
  position: absolute;
  left: var(--space-3);
  color: var(--text-muted);
  font-size: var(--text-sm);
  pointer-events: none;
  z-index: 1;
}

.input-with-icon .form-control {
  padding-left: calc(var(--space-3) * 2 + 1em);
}

/* =====================
   DYNAMIC LISTS (Experience, Education, Languages)
   ===================== */
.dynamic-list {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}

.dynamic-item {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-xl);
  overflow: hidden;
}

.dynamic-item-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-3) var(--space-4);
  cursor: pointer;
  background: var(--bg-elevated);
}

.dynamic-item-title {
  font-size: var(--text-sm);
  font-weight: var(--font-medium);
  color: var(--text-primary);
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.dynamic-item-actions {
  display: flex;
  align-items: center;
  gap: var(--space-1);
  flex-shrink: 0;
  margin-left: var(--space-2);
}

.btn-item-delete {
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-md);
  color: var(--text-muted);
  cursor: pointer;
  background: none;
  border: none;
  font-size: var(--text-xs);
  transition: all var(--transition-fast);
}

.btn-item-delete:hover { color: var(--brand-accent); background: rgba(244,63,94,0.08); }

.dynamic-item-body {
  padding: var(--space-4);
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}

.btn-add {
  width: 100%;
  padding: var(--space-3);
  border: 2px dashed var(--border-default);
  border-radius: var(--radius-xl);
  color: var(--brand-primary);
  font-size: var(--text-sm);
  font-weight: var(--font-medium);
  cursor: pointer;
  background: none;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  transition: all var(--transition-fast);
  margin-top: var(--space-2);
}

.btn-add:hover {
  background: rgba(99, 102, 241, 0.05);
  border-color: var(--brand-primary);
}

/* =====================
   SKILLS INPUT
   ===================== */
.skills-input-area {
  min-height: 80px;
  padding: var(--space-2) var(--space-3);
  border: 2px solid var(--border-default);
  border-radius: var(--radius-lg);
  cursor: text;
  background: var(--bg-surface);
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  align-items: flex-start;
  transition: border-color var(--transition-fast);
}

.skills-input-area:focus-within {
  border-color: var(--brand-primary);
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.15);
}

.skills-tags {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
}

.skill-tag {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  padding: 3px 10px;
  background: rgba(99, 102, 241, 0.1);
  color: var(--brand-primary);
  border-radius: var(--radius-full);
  font-size: var(--text-xs);
  font-weight: var(--font-medium);
}

.skill-tag-remove {
  cursor: pointer;
  opacity: 0.6;
  font-size: 10px;
  background: none;
  border: none;
  color: inherit;
  display: flex;
  padding: 0;
  line-height: 1;
}

.skill-tag-remove:hover { opacity: 1; }

.skills-input {
  border: none;
  outline: none;
  background: transparent;
  font-size: var(--text-sm);
  color: var(--text-primary);
  flex: 1;
  min-width: 120px;
}

/* =====================
   DESIGN TAB
   ===================== */
.design-section {
  margin-bottom: var(--space-6);
}

.design-section-title {
  font-size: var(--text-sm);
  font-weight: var(--font-semibold);
  color: var(--text-secondary);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  margin-bottom: var(--space-3);
}

.color-swatches {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
}

.color-swatch {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-lg);
  cursor: pointer;
  border: 3px solid transparent;
  transition: all var(--transition-fast);
  position: relative;
}

.color-swatch:hover { transform: scale(1.15); }

.color-swatch.active {
  border-color: var(--text-primary);
  box-shadow: 0 0 0 3px rgba(255,255,255,0.4);
}

.color-swatch-custom {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-lg);
  border: 2px dashed var(--border-default);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  position: relative;
  overflow: hidden;
  color: var(--text-muted);
  transition: all var(--transition-fast);
}

.color-swatch-custom:hover {
  border-color: var(--brand-primary);
  color: var(--brand-primary);
}

.color-swatch-custom input[type="color"] {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
  width: 100%;
  height: 100%;
}

.font-options {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
}

.font-option {
  padding: var(--space-2) var(--space-4);
  border-radius: var(--radius-lg);
  font-size: var(--text-base);
  cursor: pointer;
  border: 2px solid var(--border-default);
  background: var(--bg-surface);
  color: var(--text-secondary);
  transition: all var(--transition-fast);
}

.font-option:hover {
  border-color: var(--brand-primary);
  color: var(--brand-primary);
}

.font-option.active {
  border-color: var(--brand-primary);
  background: rgba(99,102,241,0.08);
  color: var(--brand-primary);
}

/* Range Slider */
.slider-group {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.range-slider {
  width: 100%;
  height: 6px;
  appearance: none;
  -webkit-appearance: none;
  background: linear-gradient(to right, var(--brand-primary) 0%, var(--border-default) 0%);
  border-radius: var(--radius-full);
  cursor: pointer;
  outline: none;
}

.range-slider::-webkit-slider-thumb {
  appearance: none;
  -webkit-appearance: none;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--brand-primary);
  cursor: pointer;
  box-shadow: 0 2px 6px rgba(99,102,241,0.4);
  transition: transform var(--transition-fast);
}

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

.slider-labels {
  display: flex;
  justify-content: space-between;
  font-size: var(--text-xs);
  color: var(--text-muted);
}

.slider-labels span:nth-child(2) {
  color: var(--brand-primary);
  font-weight: var(--font-semibold);
}

/* =====================
   RIGHT PANEL: Preview
   ===================== */
.editor-preview-area {
  flex: 1;
  background: var(--bg-elevated);
  display: flex;
  align-items: flex-start;
  justify-content: center;
  overflow: auto;
  padding: var(--space-6);
}

.preview-wrapper {
  width: 100%;
  max-width: 900px;
  box-shadow: var(--shadow-xl);
  border-radius: var(--radius-xl);
  overflow: hidden;
  background: white;
  transition: all var(--transition-base);
}

.preview-wrapper.mobile-view {
  max-width: 390px;
}

.resume-preview-frame {
  width: 100%;
  min-height: 1000px;
  border: none;
  display: block;
}

/* Mobile Preview Controls (Hidden on Desktop) */
.mobile-preview-fab {
  display: none;
}
.mobile-close-preview {
  display: none;
}

/* =====================
   PDF OVERLAY
   ===================== */
.pdf-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(8px);
  z-index: var(--z-modal);
  display: flex;
  align-items: center;
  justify-content: center;
}

.pdf-overlay[hidden] {
  display: none !important;
}

.pdf-overlay-content {
  background: var(--bg-surface);
  padding: var(--space-10) var(--space-12);
  border-radius: var(--radius-2xl);
  text-align: center;
  box-shadow: var(--shadow-xl);
}

.pdf-spinner {
  width: 48px;
  height: 48px;
  border: 4px solid var(--border-subtle);
  border-top-color: var(--brand-primary);
  border-radius: 50%;
  margin: 0 auto var(--space-4);
  animation: spin 0.8s linear infinite;
}

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

.pdf-overlay-content p {
  font-size: var(--text-base);
  font-weight: var(--font-medium);
  color: var(--text-primary);
}

/* =====================
   RESPONSIVE
   ===================== */
@media (max-width: 900px) {
  .editor-body {
    height: 100vh;
  }
  
  .editor-layout {
    flex-direction: column;
    overflow: hidden;
  }

  .editor-panel {
    width: 100%;
    flex: 1;
    max-height: none;
    border-right: none;
  }

  /* Preview area becomes a full-screen overlay */
  .editor-preview-area {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100vh;
    z-index: var(--z-modal);
    background: var(--bg-surface);
    padding: var(--space-4);
    padding-top: calc(var(--navbar-height) + var(--space-4));
    transform: translateY(100%);
    transition: transform var(--transition-spring);
    visibility: hidden;
  }

  body.preview-active .editor-preview-area {
    transform: translateY(0);
    visibility: visible;
  }

  /* FAB and Close buttons */
  .mobile-preview-fab {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    position: fixed;
    bottom: var(--space-6);
    right: var(--space-6);
    background: var(--brand-primary);
    color: white;
    padding: var(--space-3) var(--space-5);
    border-radius: var(--radius-full);
    font-size: var(--text-base);
    font-weight: var(--font-semibold);
    box-shadow: var(--shadow-lg);
    z-index: var(--z-fixed);
    border: none;
    cursor: pointer;
    transition: transform var(--transition-fast);
  }
  
  [dir="rtl"] .mobile-preview-fab {
    right: auto;
    left: var(--space-6);
  }

  body.preview-active .mobile-preview-fab {
    transform: translateY(150px);
  }

  .mobile-close-preview {
    display: flex;
    position: absolute;
    top: var(--space-4);
    right: var(--space-4);
    width: 40px;
    height: 40px;
    background: var(--bg-elevated);
    border-radius: 50%;
    align-items: center;
    justify-content: center;
    font-size: var(--text-xl);
    color: var(--text-primary);
    z-index: 10;
    box-shadow: var(--shadow-md);
  }
  
  [dir="rtl"] .mobile-close-preview {
    right: auto;
    left: var(--space-4);
  }
}

@media (max-width: 600px) {
  .editor-navbar {
    padding: 0 var(--space-3);
  }

  .editor-nav-center { display: none; }

  .form-grid-2 { grid-template-columns: 1fr; }
}
