/* ===================================
   Document Settings - Simplified UI
   =================================== */

/* Container */
.documents-customization {
  max-width: 1400px;
  margin: 0 auto;
  padding: 2rem;
}

/* Header Section */
.header-section {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-bottom: 2.5rem;
}

.header-section .icon-wrapper {
  width: 3.5rem;
  height: 3.5rem;
  border-radius: 1rem;
  background: linear-gradient(135deg, var(--accent), var(--accent-hover));
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.header-section .icon {
  width: 1.75rem;
  height: 1.75rem;
  color: white;
}

.page-title {
  font-size: 2rem;
  font-weight: 700;
  color: var(--text-primary);
  margin: 0;
}

.page-subtitle {
  font-size: 1rem;
  color: var(--text-secondary);
  margin: 0.25rem 0 0;
}

/* ===================================
   Presets Section
   =================================== */

.presets-section {
  background: var(--bg-surface);
  border: 1px solid var(--border-default);
  border-radius: 1rem;
  padding: 1.5rem;
  margin-bottom: 2rem;
}

.section-title {
  font-size: 1.375rem;
  font-weight: 600;
  color: var(--text-primary);
  margin: 0 0 0.5rem;
}

.section-description {
  font-size: 0.9375rem;
  color: var(--text-secondary);
  margin: 0 0 1.25rem;
}

.presets-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 1rem;
}

/* Preset Card */
.preset-card {
  background: var(--bg-surface);
  border: 2px solid var(--border-default);
  border-radius: 0.75rem;
  padding: 1rem;
  text-align: center;
  cursor: pointer;
  transition: all 0.2s ease;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.75rem;
  position: relative;
}

.preset-card:hover {
  border-color: var(--accent);
  transform: translateY(-2px);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.08);
}

.preset-card.active {
  border-color: var(--accent);
  background: var(--accent-10);
}

.preset-icon {
  font-size: 1.625rem;
  position: absolute;
  top: 0.5rem;
  right: 0.5rem;
}

.preset-name {
  font-size: 0.9375rem;
  font-weight: 600;
  color: var(--text-primary);
}

/* Preview Mini (inside preset card) */
.preview-mini {
  width: 80px;
  height: 100px;
  border: 1px solid var(--border-default);
  border-radius: 0.375rem;
  overflow: hidden;
  background: white;
}

.preview-mini .mini-header {
  height: 20px;
  background: var(--preset-header, #1A3C6B);
}

.preview-mini .mini-body {
  padding: 6px;
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.preview-mini .mini-line {
  height: 3px;
  background: #E2E8F0;
  border-radius: 2px;
}

.preview-mini .mini-line.accent {
  background: var(--preset-accent, #FF7B54);
  width: 60%;
}

.preview-mini .mini-line.short {
  width: 70%;
}

.preview-mini .mini-table {
  margin-top: 6px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.preview-mini .mini-row {
  height: 4px;
  background: #F7FAFC;
  border-radius: 1px;
}

.preview-mini .mini-row.header {
  background: var(--preset-accent, #FF7B54);
  opacity: 0.3;
}

.preview-mini .mini-row.stripe {
  background: #EDF2F7;
}

/* ===================================
   Accordion Sections
   =================================== */

.accordion-sections {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  margin-bottom: 2rem;
}

.accordion {
  border: 1px solid var(--border-default);
  border-radius: 0.875rem;
  background: var(--bg-surface);
  overflow: hidden;
  transition: all 0.2s ease;
}

.accordion[open] {
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
}

.accordion summary {
  padding: 1.25rem 1.5rem;
  font-weight: 600;
  font-size: 1.0625rem;
  color: var(--text-primary);
  cursor: pointer;
  user-select: none;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  list-style: none;
  transition: background 0.15s ease;
}

.accordion summary::-webkit-details-marker {
  display: none;
}

.accordion summary:hover {
  background: var(--bg-surface-hover);
}

.accordion[open] summary {
  border-bottom: 1px solid var(--border-default);
  background: var(--bg-surface-hover);
}

.accordion-icon {
  font-size: 1.375rem;
  flex-shrink: 0;
}

.accordion-title {
  flex: 1;
}

.accordion-chevron {
  width: 1.25rem;
  height: 1.25rem;
  color: var(--text-secondary);
  transition: transform 0.2s ease;
  flex-shrink: 0;
}

.accordion[open] .accordion-chevron {
  transform: rotate(180deg);
}

.accordion-content {
  padding: 1.75rem 1.5rem;
}

/* ===================================
   Form Elements
   =================================== */

.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 1.5rem;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.form-group.span-full {
  grid-column: 1 / -1;
}

.form-label {
  font-size: 0.9375rem;
  font-weight: 600;
  color: var(--text-primary);
  margin: 0;
}

.form-hint {
  font-size: 0.875rem;
  color: var(--text-secondary);
  margin: 0.25rem 0 0;
}

/* Color Input Wrapper */
.color-input-wrapper {
  display: flex;
  gap: 0.5rem;
  align-items: center;
}

.color-picker {
  width: 60px;
  height: 42px;
  padding: 4px;
  border: 1px solid var(--border-default);
  border-radius: 0.5rem;
  cursor: pointer;
}

.hex-input {
  flex: 1;
  font-family: 'Monaco', 'Courier New', monospace;
  text-transform: uppercase;
}

/* Radio Groups */
.radio-group {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.radio-group.horizontal {
  flex-direction: row;
  flex-wrap: wrap;
}

.radio-option {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.75rem;
  border: 1px solid var(--border-default);
  border-radius: 0.5rem;
  cursor: pointer;
  transition: all 0.15s ease;
}

.radio-option:hover {
  border-color: var(--accent);
  background: var(--accent-10);
}

.radio-option:has(input:checked) {
  border-color: var(--accent);
  background: var(--accent-20);
}

/* Checkbox Labels */
.checkbox-label {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem;
  border-radius: 0.5rem;
  cursor: pointer;
  transition: background 0.15s ease;
}

.checkbox-label:hover {
  background: var(--bg-surface-hover);
}

/* Range Input */
.form-range {
  width: 100%;
  height: 6px;
  border-radius: 3px;
  background: var(--border-default);
  outline: none;
  appearance: none;
}

.form-range::-webkit-slider-thumb {
  appearance: none;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--accent);
  cursor: pointer;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.15);
}

.form-range::-moz-range-thumb {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--accent);
  cursor: pointer;
  border: none;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.15);
}

.range-labels {
  display: flex;
  justify-content: space-between;
  font-size: 0.8125rem;
  color: var(--text-secondary);
  margin-top: 0.25rem;
}

/* ===================================
   Templates Grid
   =================================== */

.templates-options-wrapper {
  display: flex;
  flex-direction: column;
  gap: 2rem;
}

.form-section {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.section-subtitle {
  font-size: 1.0625rem;
  font-weight: 600;
  color: var(--text-primary);
  margin: 0;
}

.templates-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 1rem;
}

.template-card {
  position: relative;
  border: 2px solid var(--border-default);
  border-radius: 0.75rem;
  padding: 1rem;
  cursor: pointer;
  transition: all 0.2s ease;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.75rem;
  background: var(--bg-surface);
}

.template-card:hover {
  border-color: var(--accent);
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
}

.template-card:has(.template-radio:checked) {
  border-color: var(--accent);
  background: var(--accent-10);
}

.template-radio {
  position: absolute;
  top: 0.5rem;
  right: 0.5rem;
}

.template-name {
  font-size: 0.9375rem;
  font-weight: 600;
  color: var(--text-primary);
}

/* Template Thumbnail */
.template-thumbnail {
  width: 100px;
  height: 130px;
  border: 1px solid var(--border-default);
  border-radius: 0.375rem;
  overflow: hidden;
  background: white;
}

.template-thumbnail .thumb-header {
  height: 25px;
  background: var(--thumb-header, #1A3C6B);
}

.template-thumbnail .thumb-body {
  padding: 8px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.template-thumbnail .thumb-line {
  height: 3px;
  background: var(--thumb-border, #E2E8F0);
  border-radius: 2px;
}

.template-thumbnail .thumb-line.accent {
  background: var(--thumb-accent, #FF7B54);
  width: 60%;
}

.template-thumbnail .thumb-line.short {
  width: 75%;
}

.template-thumbnail .thumb-table {
  margin-top: 8px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.template-thumbnail .thumb-row {
  height: 5px;
  background: #F7FAFC;
  border-radius: 1px;
}

.template-thumbnail .thumb-row.header {
  background: var(--thumb-table-header, #F7FAFC);
}

.template-thumbnail .thumb-row.stripe {
  background: #EDF2F7;
  opacity: 0.5;
}

/* Options Grid */
.options-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: 0.75rem;
}

/* ===================================
   Actions Bar
   =================================== */

.actions-bar {
  display: flex;
  gap: 1rem;
  align-items: center;
  padding: 1.5rem;
  border: 1px solid var(--border-default);
  border-radius: 0.875rem;
  margin-bottom: 2rem;
  flex-wrap: wrap;
  position: sticky;
  bottom: 1rem;
  z-index: 10;
  backdrop-filter: blur(8px);
  background: color-mix(in srgb, var(--bg-surface) 85%, transparent);
  box-shadow: 0 -2px 12px rgba(0, 0, 0, 0.08);
}

.actions-bar .btn {
  min-width: 200px;
}

/* ===================================
   Preview Section
   =================================== */

.preview-section {
  border: 1px solid var(--border-default);
  border-radius: 0.875rem;
  background: var(--bg-surface);
  overflow: hidden;
}

.preview-section summary {
  padding: 1.25rem 1.5rem;
  font-weight: 600;
  font-size: 1.0625rem;
  color: var(--text-primary);
  cursor: pointer;
  user-select: none;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  list-style: none;
  transition: background 0.15s ease;
}

.preview-section summary::-webkit-details-marker {
  display: none;
}

.preview-section summary:hover {
  background: var(--bg-surface-hover);
}

.preview-section[open] summary {
  border-bottom: 1px solid var(--border-default);
}

.preview-icon {
  font-size: 1.375rem;
}

.preview-title {
  flex: 1;
}

.preview-content {
  padding: 2rem;
  background: linear-gradient(135deg, #f5f7fa 0%, #c3cfe2 100%);
}

.preview-document {
  max-width: 400px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1rem;
}

/* A4 Preview */
.a4-preview {
  width: 300px;
  height: 400px;
  background: white;
  border: 1px solid var(--border-default);
  border-radius: 0.5rem;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
  overflow: hidden;
}

.a4-preview .preview-header {
  height: 60px;
  background: var(--preview-header, #1A3C6B);
}

.a4-preview .preview-body {
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.a4-preview .preview-line {
  height: 6px;
  background: var(--preview-border, #E2E8F0);
  border-radius: 3px;
}

.a4-preview .preview-line.accent {
  background: var(--preview-accent, #FF7B54);
  width: 60%;
}

.a4-preview .preview-line.short {
  width: 75%;
}

.a4-preview .preview-table {
  margin-top: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.375rem;
}

.a4-preview .preview-row {
  height: 10px;
  background: #F7FAFC;
  border-radius: 2px;
}

.a4-preview .preview-row.header {
  background: var(--preview-table-header, #F7FAFC);
}

.a4-preview .preview-row.stripe {
  background: #EDF2F7;
  opacity: 0.6;
}

.preview-caption {
  font-size: 0.9375rem;
  color: var(--text-secondary);
  text-align: center;
  margin: 0;
}

/* Font Preview */
.font-preview {
  padding: 1.5rem;
  background: var(--bg-surface);
  border: 1px solid var(--border-default);
  border-radius: 0.75rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.preview-heading {
  font-size: 1.625rem;
  font-weight: 600;
  color: var(--text-primary);
}

.preview-body {
  font-size: 1.0625rem;
  color: var(--text-secondary);
  line-height: 1.6;
}

/* Logo Upload */
.logo-upload-wrapper {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.current-logo {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 1rem;
  background: var(--bg-surface);
  border: 1px solid var(--border-default);
  border-radius: 0.75rem;
}

.logo-preview {
  max-width: 150px;
  max-height: 80px;
  object-fit: contain;
}

/* ===================================
   Unified Style Toggle
   =================================== */

.unified-toggle-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 1rem 1.25rem;
  border: 1px solid var(--border-default);
  border-radius: 0.75rem;
  background: var(--bg-surface-hover);
  margin-bottom: 1.5rem;
}

.unified-toggle-info {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.unified-toggle-title {
  font-size: 0.9375rem;
  font-weight: 600;
  color: var(--text-primary);
}

.unified-toggle-desc {
  font-size: 0.8125rem;
  color: var(--text-secondary);
}

/* Toggle switch */
.toggle-switch {
  position: relative;
  display: inline-block;
  width: 44px;
  height: 24px;
  flex-shrink: 0;
}

.toggle-input {
  opacity: 0;
  width: 0;
  height: 0;
  position: absolute;
}

.toggle-slider {
  position: absolute;
  cursor: pointer;
  inset: 0;
  background: var(--border-default);
  border-radius: 24px;
  transition: background 0.2s ease;
}

.toggle-slider::before {
  content: "";
  position: absolute;
  left: 2px;
  bottom: 2px;
  width: 20px;
  height: 20px;
  background: white;
  border-radius: 50%;
  transition: transform 0.2s ease;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.15);
}

.toggle-input:checked + .toggle-slider {
  background: var(--accent);
}

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

/* Unified templates grid */
.unified-templates-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 1rem;
}

.unified-template-card {
  position: relative;
  border: 2px solid var(--border-default);
  border-radius: 0.75rem;
  padding: 1.25rem 1rem;
  cursor: pointer;
  transition: all 0.2s ease;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.75rem;
  background: var(--bg-surface);
  text-align: center;
}

.unified-template-card:hover {
  border-color: var(--accent);
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
}

.unified-template-card:has(.template-radio:checked) {
  border-color: var(--accent);
  background: var(--accent-10);
}

.unified-template-preview {
  width: 100%;
}

.unified-mini-docs {
  display: flex;
  flex-direction: column;
  gap: 0.375rem;
}

.unified-mini-doc {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.375rem 0.625rem;
  background: var(--bg-surface-hover);
  border-radius: 0.375rem;
  font-size: 0.75rem;
}

.mini-doc-label {
  color: var(--text-secondary);
  font-weight: 500;
}

.mini-doc-name {
  color: var(--text-primary);
  font-weight: 600;
}

.unified-template-desc {
  font-size: 0.75rem;
  color: var(--text-secondary);
  line-height: 1.3;
}

/* Responsive */
@media (max-width: 768px) {
  .documents-customization {
    padding: 1rem;
  }

  .header-section {
    margin-bottom: 1.5rem;
  }

  .page-title {
    font-size: 1.625rem;
  }

  .presets-grid {
    grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  }

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

  .templates-grid {
    grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  }

  .unified-templates-grid {
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  }

  .unified-toggle-bar {
    flex-direction: column;
    align-items: flex-start;
  }

  .actions-bar {
    flex-direction: column;
  }

  .actions-bar .btn {
    width: 100%;
  }
}
