/* ==========================================================================
   Embassy Graphic Generator - Clean, Plain & Minimal Style
   ========================================================================== */

:root {
  --bg: #ffffff;
  --bg-subtle: #f8f9fa;
  --border: #e2e8f0;
  --border-focus: #475569;
  --text-main: #0f172a;
  --text-muted: #64748b;
  --radius: 6px;
}

*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 13px;
  line-height: 1.5;
  color: var(--text-main);
  background: #f1f5f9;
  min-height: 100vh;
}

/* Header */
.app-header {
  background: #ffffff;
  border-bottom: 1px solid var(--border);
  padding: 12px 24px;
}

.header-content {
  max-width: 1400px;
  margin: 0 auto;
  display: flex;
  align-items: center;
}

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

.header-logo {
  width: 38px;
  height: 38px;
  object-fit: contain;
}

.brand-titles h1 {
  font-size: 15px;
  font-weight: 600;
  color: #0f172a;
}

.brand-titles p {
  font-size: 11px;
  color: var(--text-muted);
}

/* Layout */
.app-main {
  display: flex;
  max-width: 1400px;
  margin: 0 auto;
  padding: 20px 24px;
  gap: 24px;
  align-items: flex-start;
}

/* Sidebar */
.editor-sidebar {
  width: 410px;
  flex-shrink: 0;
  background: #ffffff;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  max-height: calc(100vh - 100px);
  overflow-y: auto;
  overflow-x: hidden;
  position: sticky;
  top: 20px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  scrollbar-width: thin;
  scrollbar-color: #cbd5e1 #f8fafc;
}

.editor-sidebar::-webkit-scrollbar {
  width: 6px;
}

.editor-sidebar::-webkit-scrollbar-track {
  background: #f8fafc;
  border-radius: 4px;
}

.editor-sidebar::-webkit-scrollbar-thumb {
  background: #cbd5e1;
  border-radius: 4px;
}

.editor-sidebar::-webkit-scrollbar-thumb:hover {
  background: #94a3b8;
}

/* Primary Card Sections for Non-Technical Ease of Use */
.primary-card {
  background: #ffffff;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 14px 15px;
  transition: box-shadow 0.2s ease, border-color 0.2s ease;
}

.primary-card.active-card {
  border-color: #cbd5e1;
  background: #ffffff;
  box-shadow: 0 2px 8px rgba(15, 23, 42, 0.04);
}

.primary-label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px !important;
  font-weight: 700 !important;
  color: #0f172a !important;
  margin-bottom: 10px;
  padding-bottom: 8px;
  border-bottom: 1px solid #f1f5f9;
}

.step-num {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  background: #0f172a;
  color: #ffffff;
  font-size: 11px;
  font-weight: 700;
  border-radius: 50%;
}

.label-with-hint {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 4px;
}

.strong-label {
  font-size: 12.5px !important;
  font-weight: 600 !important;
  color: #0f172a !important;
}

.sub-label {
  font-size: 11.5px !important;
  font-weight: 500 !important;
  color: #475569 !important;
}

.hint-text {
  font-size: 11px;
  color: #94a3b8;
}

/* Badge Input Special Styling */
.badge-input {
  font-size: 15px !important;
  font-weight: 700 !important;
  letter-spacing: 0.5px;
  color: #0f172a !important;
  background: #f8fafc !important;
  border: 1.5px solid #cbd5e1 !important;
  border-radius: 6px !important;
  padding: 9px 12px !important;
}

.badge-input:focus {
  background: #ffffff !important;
  border-color: #0f172a !important;
  box-shadow: 0 0 0 3px rgba(15, 23, 42, 0.08);
}

/* Badge Quick Pills */
.badge-quick-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  margin-top: 7px;
}

.pill-btn {
  background: #f1f5f9;
  border: 1px solid #e2e8f0;
  color: #334155;
  font-size: 11px;
  font-weight: 500;
  padding: 4px 9px;
  border-radius: 20px;
  cursor: pointer;
  transition: all 0.15s ease;
}

.pill-btn:hover {
  background: #e2e8f0;
  color: #0f172a;
}

.pill-btn.active-pill {
  background: #0f172a;
  color: #ffffff;
  border-color: #0f172a;
}

/* Main Body Textarea Special Prominent Styling */
.main-body-textarea {
  font-size: 13.5px !important;
  line-height: 1.65 !important;
  font-family: system-ui, -apple-system, sans-serif !important;
  color: #0f172a !important;
  background: #fdfdfd !important;
  border: 1.5px solid #cbd5e1 !important;
  border-radius: 6px !important;
  padding: 10px 12px !important;
  min-height: 150px;
  text-align: justify;
}

.main-body-textarea:focus {
  background: #ffffff !important;
  border-color: #0f172a !important;
  box-shadow: 0 0 0 3px rgba(15, 23, 42, 0.08);
}

.highlight-select {
  font-weight: 600 !important;
  background-color: #f8fafc !important;
  border-color: #cbd5e1 !important;
}

.sub-fields-box {
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 6px;
  padding: 10px 12px;
}

/* Collapsible Accordion Sections for Advanced Options */
.accordion-section {
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #ffffff;
  overflow: hidden;
}

.accordion-header {
  list-style: none;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 14px;
  font-size: 12px;
  font-weight: 600;
  color: #475569;
  background: #f8fafc;
  cursor: pointer;
  user-select: none;
  transition: background-color 0.15s ease;
}

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

.accordion-header:hover {
  background: #f1f5f9;
  color: #0f172a;
}

.accordion-header .chevron {
  font-size: 9px;
  color: #94a3b8;
  transition: transform 0.2s ease;
}

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

.accordion-section[open] .accordion-header {
  border-bottom: 1px solid var(--border);
}

.accordion-body {
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

/* Headings */
.section-title h2 {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--border);
}

/* Form Controls */
.control-group {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.control-group label {
  font-size: 12px;
  font-weight: 500;
  color: #334155;
}

.control-row {
  display: flex;
  gap: 10px;
}

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

.highlight-box {
  background: var(--bg-subtle);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px 12px;
}

/* Inputs & Selects */
input[type="text"],
select,
textarea {
  width: 100%;
  padding: 7px 10px;
  font-size: 13px;
  font-family: inherit;
  color: #0f172a;
  background: #ffffff;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  outline: none;
}

input[type="text"]:focus,
select:focus,
textarea:focus {
  border-color: var(--border-focus);
}

textarea {
  resize: vertical;
  line-height: 1.5;
}

/* Template Selector */
.template-selector {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
}

.tpl-btn {
  padding: 8px 10px;
  background: #ffffff;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: #334155;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  text-align: center;
}

.tpl-btn:hover {
  background: var(--bg-subtle);
}

.tpl-btn.active {
  background: #0f172a;
  color: #ffffff;
  border-color: #0f172a;
}

/* Social Toggles */
.social-toggles {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
}

.toggle-item {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  background: var(--bg-subtle);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 11px;
  color: #334155;
  cursor: pointer;
}

.toggle-item input[type="checkbox"],
.toggle-item input[type="radio"] {
  accent-color: #0f172a;
  cursor: pointer;
}

/* Upload Box */
.file-upload-box {
  position: relative;
  border: 1px dashed #cbd5e1;
  border-radius: var(--radius);
  background: var(--bg-subtle);
  padding: 14px;
  text-align: center;
  cursor: pointer;
}

.file-upload-box input[type="file"] {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
  width: 100%;
  height: 100%;
}

.upload-prompt {
  font-size: 12px;
  color: var(--text-muted);
}

.upload-prompt svg {
  display: block;
  margin: 0 auto 4px;
  color: #94a3b8;
}

.btn-text-danger {
  background: none;
  border: none;
  color: #dc2626;
  font-size: 11px;
  cursor: pointer;
  padding: 2px 0;
}

.btn-text-danger:hover {
  text-decoration: underline;
}

/* Range Input */
input[type="range"] {
  width: 100%;
  accent-color: #0f172a;
}

/* Buttons */
.btn-primary, .btn-secondary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 14px;
  font-size: 12px;
  font-weight: 500;
  border-radius: var(--radius);
  cursor: pointer;
  white-space: nowrap;
  transition: background-color 0.15s ease, border-color 0.15s ease;
}

.btn-primary {
  background: #0f172a;
  color: #ffffff;
  border: 1px solid #0f172a;
}

.btn-primary:hover {
  background: #1e293b;
}

.btn-secondary {
  background: #ffffff;
  color: #334155;
  border: 1px solid var(--border);
}

.btn-secondary:hover {
  background: var(--bg-subtle);
}

/* Preview Area */
.preview-area {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.preview-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px;
  background: #ffffff;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px 16px;
}

.preview-header h3 {
  font-size: 13px;
  font-weight: 600;
  color: #334155;
}

.export-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

/* Canvas Viewport */
.canvas-wrapper {
  background: #e2e8f0;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 380px;
  overflow: hidden;
}

.canvas-wrapper canvas {
  display: block;
  max-width: 100%;
  max-height: calc(100vh - 160px);
  width: auto;
  height: auto;
  background: #ffffff;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
  object-fit: contain;
}

/* Responsive Breakpoints */
@media (max-width: 1024px) {
  .app-main {
    flex-direction: column;
    padding: 14px;
    gap: 16px;
  }
  .editor-sidebar {
    width: 100%;
    max-height: none;
    order: 2; /* On tablet/mobile, controls appear right below preview or ordered cleanly */
  }
  .preview-area {
    width: 100%;
    order: 1; /* On smaller devices, seeing the preview first makes editing intuitive */
  }
  .canvas-wrapper {
    padding: 14px;
    min-height: 340px;
  }
  .canvas-wrapper canvas {
    max-height: 60vh;
  }
}

@media (max-width: 640px) {
  .app-header {
    padding: 10px 14px;
  }

  .header-logo {
    width: 32px;
    height: 32px;
  }

  .brand-titles h1 {
    font-size: 13px;
  }

  .brand-titles p {
    font-size: 10px;
  }

  .app-main {
    padding: 10px;
    gap: 12px;
  }

  .preview-header {
    flex-direction: column;
    align-items: stretch;
    padding: 10px 12px;
  }

  .preview-title-group {
    flex-direction: column;
    align-items: stretch !important;
    gap: 8px !important;
  }

  #pageNavControls {
    justify-content: space-between;
  }

  .export-buttons {
    flex-direction: column;
    width: 100%;
  }

  .export-buttons button {
    width: 100%;
    justify-content: center;
    padding: 10px 12px;
    font-size: 13px;
  }

  .editor-sidebar {
    padding: 14px 12px;
  }

  .control-row {
    flex-direction: column;
    gap: 10px;
  }

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

  .social-toggles {
    grid-template-columns: 1fr;
  }

  .canvas-wrapper {
    padding: 10px;
    min-height: 260px;
  }

  .canvas-wrapper canvas {
    max-height: 52vh;
  }
}
