/* ══════════════════════════════════════════════════════
   GEN2K PROPOSAL GENERATOR — MASTER STYLESHEET
   ══════════════════════════════════════════════════════ */

/* ─── CSS Variables ─── */
:root {
  --color-accent:       #c0392b;
  --color-accent-dark:  #922b21;
  --color-accent-light: #e74c3c;
  --color-bg:           #0d0f1a;
  --color-surface:      #141828;
  --color-surface2:     #1c2236;
  --color-border:       rgba(255,255,255,0.07);
  --color-text:         #e8eaf6;
  --color-text-muted:   #8892b0;
  --color-text-dim:     #4a5568;
  --color-white:        #ffffff;
  --color-success:      #27ae60;
  --sidebar-w:          280px;
  --radius-sm:          8px;
  --radius-md:          12px;
  --radius-lg:          20px;
  --radius-xl:          28px;
  --shadow-soft:        0 4px 24px rgba(0,0,0,0.4);
  --shadow-glow:        0 0 32px rgba(192,57,43,0.2);
  --transition:         all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  --font-body:          'Inter', system-ui, -apple-system, sans-serif;
}

/* ─── Reset & Base ─── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html {
  font-size: 16px;
  scroll-behavior: smooth;
}

body {
  font-family: var(--font-body);
  background: var(--color-bg);
  color: var(--color-text);
  display: flex;
  min-height: 100vh;
  overflow-x: hidden;
}

/* ══════════════════════════════════════════════════════
   SIDEBAR
   ══════════════════════════════════════════════════════ */
.sidebar {
  width: var(--sidebar-w);
  min-height: 100vh;
  background: linear-gradient(180deg, #0a0c16 0%, #111523 100%);
  border-right: 1px solid var(--color-border);
  display: flex;
  flex-direction: column;
  gap: 32px;
  padding: 28px 20px;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
  flex-shrink: 0;
}

.sidebar-logo {
  display: flex;
  align-items: center;
  gap: 12px;
  padding-bottom: 24px;
  border-bottom: 1px solid var(--color-border);
}

.logo-icon {
  width: 44px;
  height: 44px;
  background: linear-gradient(135deg, var(--color-accent), var(--color-accent-dark));
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 13px;
  color: white;
  letter-spacing: 0.5px;
  box-shadow: 0 4px 16px rgba(192,57,43,0.4);
  flex-shrink: 0;
}

.logo-text {
  font-size: 13px;
  color: var(--color-text-muted);
  line-height: 1.4;
}
.logo-text strong { color: var(--color-text); font-weight: 700; }

/* Step Navigation */
.step-nav {
  display: flex;
  flex-direction: column;
  gap: 0;
}

.step-item {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 12px 14px;
  border-radius: var(--radius-md);
  cursor: default;
  transition: var(--transition);
}

.step-item.active {
  background: rgba(192,57,43,0.12);
}

.step-item.clickable {
  cursor: pointer;
}
.step-item.clickable:hover {
  background: rgba(255,255,255,0.05);
}

.step-dot {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: 2px solid var(--color-text-dim);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 700;
  color: var(--color-text-dim);
  flex-shrink: 0;
  transition: var(--transition);
}

.step-item.active .step-dot {
  border-color: var(--color-accent);
  background: var(--color-accent);
  color: white;
  box-shadow: 0 0 16px rgba(192,57,43,0.5);
}

.step-item.completed .step-dot {
  border-color: var(--color-success);
  background: var(--color-success);
  color: white;
}
.step-item.completed .step-dot::after {
  content: '✓';
  font-size: 14px;
}

.step-label {
  display: flex;
  flex-direction: column;
}

.step-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--color-text-muted);
  transition: var(--transition);
}

.step-sub {
  font-size: 11px;
  color: var(--color-text-dim);
  margin-top: 1px;
}

.step-item.active .step-title { color: var(--color-text); }
.step-item.completed .step-title { color: var(--color-success); }

.step-connector {
  width: 2px;
  height: 20px;
  background: var(--color-border);
  margin-left: 30px;
}

/* Info Cards */
.sidebar-info {
  margin-top: auto;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.info-card {
  background: var(--color-surface2);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: 14px 16px;
  display: flex;
  align-items: center;
  gap: 12px;
}

.info-icon { font-size: 20px; }

.info-title {
  font-size: 11px;
  color: var(--color-text-dim);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.info-value {
  font-size: 20px;
  font-weight: 700;
  color: var(--color-text);
  line-height: 1;
  margin-top: 2px;
}

/* ══════════════════════════════════════════════════════
   MAIN CONTENT
   ══════════════════════════════════════════════════════ */
.main-content {
  flex: 1;
  min-width: 0;
  padding: 40px 48px;
  max-width: calc(100vw - var(--sidebar-w));
}

/* Step section visibility */
.step-section {
  display: none;
  animation: fadeInUp 0.4s ease forwards;
}
.step-section.active { display: block; }

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

/* Section Header */
.section-header {
  margin-bottom: 36px;
}

.section-title {
  font-family: 'Playfair Display', serif;
  font-size: 2.2rem;
  font-weight: 700;
  background: linear-gradient(135deg, #ffffff 0%, #c8d0e8 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  line-height: 1.2;
}

.section-subtitle {
  margin-top: 10px;
  font-size: 0.95rem;
  color: var(--color-text-muted);
  max-width: 600px;
}

/* ══════════════════════════════════════════════════════
   STEP 1 — TEMPLATE SELECTION
   ══════════════════════════════════════════════════════ */
.template-grid {
  display: flex;
  gap: 24px;
  flex-wrap: wrap;
  margin-bottom: 48px;
}

.template-card {
  background: var(--color-surface);
  border: 2px solid var(--color-border);
  border-radius: var(--radius-xl);
  padding: 24px;
  max-width: 440px;
  width: 100%;
  cursor: pointer;
  transition: var(--transition);
  position: relative;
  overflow: hidden;
}

.template-card:hover {
  border-color: rgba(192,57,43,0.4);
  transform: translateY(-2px);
  box-shadow: var(--shadow-glow);
}

.template-card.selected {
  border-color: var(--color-accent);
  box-shadow: 0 0 0 1px var(--color-accent), var(--shadow-glow);
}

.template-badge {
  display: inline-block;
  padding: 4px 12px;
  background: linear-gradient(135deg, var(--color-accent), var(--color-accent-dark));
  color: white;
  font-size: 11px;
  font-weight: 700;
  border-radius: 20px;
  margin-bottom: 16px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.template-preview-wrap {
  background: #f5f5f5;
  border-radius: var(--radius-md);
  padding: 12px;
  margin-bottom: 20px;
}

.template-pages-mini {
  display: flex;
  gap: 8px;
  justify-content: center;
}

.mini-page {
  width: calc(33% - 4px);
  height: auto;
  border-radius: 4px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.15);
  object-fit: cover;
  aspect-ratio: 0.707;
}

.template-info { margin-bottom: 16px; }

.template-name {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--color-text);
  margin-bottom: 8px;
}

.template-desc {
  font-size: 0.875rem;
  color: var(--color-text-muted);
  line-height: 1.6;
}

.template-features {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 12px;
}

.feat-tag {
  padding: 4px 10px;
  background: rgba(192,57,43,0.1);
  border: 1px solid rgba(192,57,43,0.25);
  border-radius: 20px;
  font-size: 11px;
  color: #e88;
}

.template-select-indicator {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  font-weight: 600;
  color: var(--color-accent-light);
  opacity: 0;
  transition: var(--transition);
}

.template-card.selected .template-select-indicator { opacity: 1; }
.check-icon { font-style: normal; }

/* Template Roles Section */
.template-roles {
  margin-bottom: 40px;
}

.roles-title {
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--color-text);
  margin-bottom: 20px;
  padding-top: 12px;
  border-top: 1px solid var(--color-border);
}

.roles-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 20px;
}

.role-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  transition: var(--transition);
}

.role-card:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow-soft);
  border-color: rgba(255,255,255,0.12);
}

.role-page-preview {
  background: #e8e8e8;
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 10px;
  height: 200px;
  overflow: hidden;
}

.role-page-preview img {
  max-height: 100%;
  max-width: 100%;
  object-fit: contain;
  border-radius: 4px;
  box-shadow: 0 2px 12px rgba(0,0,0,0.15);
}

.role-info {
  padding: 16px;
}

.role-badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 8px;
}

.role-badge.initial  { background: rgba(39,174,96,0.15);  color: #6fcc97; border: 1px solid rgba(39,174,96,0.3); }
.role-badge.middle   { background: rgba(52,152,219,0.15); color: #74b9e0; border: 1px solid rgba(52,152,219,0.3); }
.role-badge.final    { background: rgba(192,57,43,0.15);  color: #e07070; border: 1px solid rgba(192,57,43,0.3); }

.role-info h3 {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--color-text);
  margin-bottom: 6px;
}

.role-info p {
  font-size: 0.8rem;
  color: var(--color-text-muted);
  line-height: 1.6;
}

/* ══════════════════════════════════════════════════════
   STEP 2 — CONTENT EDITOR
   ══════════════════════════════════════════════════════ */

/* Meta Fields */
.meta-fields {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: 24px;
  margin-bottom: 24px;
}

.meta-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
  margin-bottom: 16px;
}
.meta-row:last-child { margin-bottom: 0; }

.meta-field {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.field-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--color-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.field-input {
  background: var(--color-surface2);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  padding: 11px 14px;
  color: var(--color-text);
  font-size: 14px;
  font-family: var(--font-body);
  transition: var(--transition);
  outline: none;
}

.field-input:focus {
  border-color: var(--color-accent);
  box-shadow: 0 0 0 3px rgba(192,57,43,0.12);
}

.field-input::placeholder { color: var(--color-text-dim); }

.field-input[type="date"]::-webkit-calendar-picker-indicator {
  filter: invert(0.7);
  cursor: pointer;
}

/* Editor Container */
.editor-container {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  margin-bottom: 28px;
}

/* Toolbar */
.editor-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 2px;
  padding: 10px 12px;
  background: var(--color-surface2);
  border-bottom: 1px solid var(--color-border);
}

.toolbar-group {
  display: flex;
  align-items: center;
  gap: 2px;
}

.toolbar-divider {
  width: 1px;
  height: 24px;
  background: var(--color-border);
  margin: 0 6px;
}

.tb-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 32px;
  height: 32px;
  padding: 0 6px;
  background: transparent;
  border: none;
  border-radius: 6px;
  color: var(--color-text-muted);
  font-size: 14px;
  cursor: pointer;
  transition: var(--transition);
  font-family: var(--font-body);
}

.tb-btn:hover {
  background: rgba(255,255,255,0.07);
  color: var(--color-text);
}

.tb-btn.active {
  background: rgba(192,57,43,0.2);
  color: var(--color-accent-light);
}

.color-btn {
  cursor: pointer;
  font-style: normal;
  font-weight: 700;
  font-size: 16px;
}

.toolbar-select {
  background: transparent;
  border: 1px solid var(--color-border);
  border-radius: 6px;
  color: var(--color-text-muted);
  font-size: 13px;
  padding: 4px 8px;
  cursor: pointer;
  font-family: var(--font-body);
  outline: none;
}
.toolbar-select option { background: var(--color-surface2); color: var(--color-text); }

/* Rich Editor */
.rich-editor {
  min-height: 420px;
  max-height: 600px;
  padding: 28px 32px;
  overflow-y: auto;
  outline: none;
  font-size: 15px;
  line-height: 1.8;
  color: #1a1a2e;
  background: #ffffff;
  caret-color: var(--color-accent);
}

.rich-editor:empty::before {
  content: attr(data-placeholder);
  color: #9ca3af;
  pointer-events: none;
  white-space: pre-line;
  font-size: 14px;
  line-height: 1.8;
}

/* Editor typography */
.rich-editor h1 { font-size: 1.6rem; font-weight: 800; margin: 20px 0 8px; color: #1a1a2e; }
.rich-editor h2 { font-size: 1.3rem; font-weight: 700; margin: 16px 0 6px; color: #1a1a2e; }
.rich-editor h3 { font-size: 1.1rem; font-weight: 700; margin: 14px 0 4px; color: #2d2d3e; }
.rich-editor h4 { font-size: 1rem;   font-weight: 600; margin: 12px 0 4px; color: #2d2d3e; }
.rich-editor p  { margin: 0 0 12px; }
.rich-editor ul, .rich-editor ol { margin: 8px 0 12px 24px; }
.rich-editor li { margin: 4px 0; line-height: 1.7; }
.rich-editor blockquote {
  border-left: 3px solid var(--color-accent);
  padding: 8px 16px;
  margin: 12px 0;
  color: #555;
  font-style: italic;
  background: #f9f9f9;
}
.rich-editor a { color: var(--color-accent); }

.editor-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 20px;
  background: var(--color-surface2);
  border-top: 1px solid var(--color-border);
  font-size: 12px;
  color: var(--color-text-dim);
}

.editor-hint { font-size: 11.5px; }

/* ══════════════════════════════════════════════════════
   STEP 3 — PREVIEW
   ══════════════════════════════════════════════════════ */
.preview-actions {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 28px;
  flex-wrap: wrap;
  gap: 12px;
}

.pages-preview-container {
  display: flex;
  flex-direction: column;
  gap: 20px;
  padding-bottom: 12px; /* reduced bottom gap to use all viewport space */
}

.preview-action-group {
  display: flex;
  gap: 12px;
  align-items: center;
}

.pages-preview-container {
  display: flex;
  flex-direction: column;
  gap: 40px;
  padding-bottom: 48px;
}

.pdf-note {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  background: rgba(52,152,219,0.08);
  border: 1px solid rgba(52,152,219,0.2);
  border-radius: var(--radius-md);
  padding: 14px 18px;
  font-size: 13px;
  color: var(--color-text-muted);
  max-width: 794px;
  margin: 0 auto;
}
.note-icon { font-size: 16px; flex-shrink: 0; }

/* ══════════════════════════════════════════════════════
   BUTTONS
   ══════════════════════════════════════════════════════ */
.step-actions {
  display: flex;
  gap: 14px;
  align-items: center;
  flex-wrap: wrap;
}

.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 13px 26px;
  border-radius: 12px;
  border: none;
  font-size: 14px;
  font-weight: 600;
  font-family: var(--font-body);
  cursor: pointer;
  transition: var(--transition);
  text-decoration: none;
  white-space: nowrap;
}

.btn-primary {
  background: linear-gradient(135deg, var(--color-accent), var(--color-accent-dark));
  color: white;
  box-shadow: 0 4px 16px rgba(192,57,43,0.35);
}

.btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 28px rgba(192,57,43,0.5);
}

.btn-primary:active { transform: translateY(0); }

.btn-secondary {
  background: var(--color-surface2);
  border: 1px solid var(--color-border);
  color: var(--color-text);
}

.btn-secondary:hover {
  background: rgba(255,255,255,0.06);
  border-color: rgba(255,255,255,0.15);
}

.btn-outline {
  background: transparent;
  border: 1px solid var(--color-border);
  color: var(--color-text-muted);
}

.btn-outline:hover {
  background: rgba(255,255,255,0.05);
  color: var(--color-text);
  border-color: rgba(255,255,255,0.2);
}

.btn-arrow { font-style: normal; }
.btn-icon { font-style: normal; }

/* ══════════════════════════════════════════════════════
   LOADING OVERLAY
   ══════════════════════════════════════════════════════ */
.loading-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(13,15,26,0.85);
  backdrop-filter: blur(10px);
  z-index: 1000;
  align-items: center;
  justify-content: center;
}

.loading-overlay.active {
  display: flex;
  animation: fadeIn 0.2s ease;
}

@keyframes fadeIn {
  from { opacity: 0; } to { opacity: 1; }
}

.loading-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-xl);
  padding: 48px 60px;
  text-align: center;
  box-shadow: 0 32px 80px rgba(0,0,0,0.5);
}

.loading-spinner {
  width: 52px;
  height: 52px;
  border: 3px solid rgba(192,57,43,0.2);
  border-top-color: var(--color-accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin: 0 auto 20px;
}

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

.loading-text {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--color-text);
  margin-bottom: 6px;
}

.loading-sub {
  font-size: 0.85rem;
  color: var(--color-text-muted);
}

/* ══════════════════════════════════════════════════════
   SCROLLBAR
   ══════════════════════════════════════════════════════ */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.1); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,0.2); }

/* ══════════════════════════════════════════════════════
   RESPONSIVE
   ══════════════════════════════════════════════════════ */
@media (max-width: 1024px) {
  .roles-grid { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 800px) {
  .sidebar { width: 220px; padding: 20px 14px; }
  .main-content { padding: 28px 24px; max-width: calc(100vw - 220px); }
  .meta-row { grid-template-columns: 1fr; }
  .roles-grid { grid-template-columns: 1fr; }
  .section-title { font-size: 1.7rem; }
}

@media (max-width: 620px) {
  body { flex-direction: column; }
  .sidebar { width: 100%; height: auto; min-height: unset; position: relative; flex-direction: row; flex-wrap: wrap; padding: 16px; gap: 16px; }
  .main-content { max-width: 100%; padding: 20px 16px; }
  .step-nav { flex-direction: row; flex-wrap: wrap; }
}

/* ══════════════════════════════════════════════════════
   PRINT STYLES (for Professional PDF generation)
   ══════════════════════════════════════════════════════ */
@media print {
  @page {
    size: A4;
    margin: 0;
  }
  body {
    background: white !important;
    color: black !important;
    display: block !important;
    padding: 0 !important;
    margin: 0 !important;
  }
  .sidebar, .main-content-header, .preview-actions, .step-nav, .loading-overlay, .editor-footer, .btn, .section-header {
    display: none !important;
  }
  .main-content {
    margin: 0 !important;
    padding: 0 !important;
    max-width: none !important;
    box-shadow: none !important;
    background: transparent !important;
  }
  #step-3 {
    margin: 0 !important;
    padding: 0 !important;
    display: block !important;
  }
  .pages-preview-container {
    display: block !important;
    padding: 0 !important;
    margin: 0 !important;
    gap: 0 !important;
    background: transparent !important;
  }
  /* Hide preview-only metadata in print */
  .pages-preview-container .role-badge, 
  .pages-preview-container span[style*="font-size:11px"] {
    display: none !important;
  }
  .pages-preview-container > div {
    margin: 0 !important;
    page-break-after: always !important;
    break-after: page !important;
  }
  /* Ensure the shell is full-size in print and not scaled */
  .pages-preview-container div[style*="transform"] {
    transform: none !important;
    width: 794px !important;
    height: 1123px !important;
    box-shadow: none !important;
    border-radius: 0 !important;
    position: relative !important;
    overflow: hidden !important;
    background: white !important;
  }
}

/* ─── Preview Stability Hardening ─── */
.pages-preview-container {
  display: flex;
  flex-direction: column;
  gap: 40px;
  align-items: center;
  padding: 40px 0;
  min-height: 200px;
  width: 100%;
}
.pages-preview-container > div {
  width: 100%;
  max-width: 794px;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.print-proposal-title {
  font-size: 16px !important;
  font-weight: 800 !important;
  color: #c0392b !important;
  text-transform: uppercase;
  margin: 0 0 3px !important;
}

.print-meta {
  font-size: 10.5px !important;
  color: #666 !important;
  margin: 2px 0 !important;
}

.print-header-sep {
  border: none;
  border-top: 1.5px solid rgba(0,0,0,0.12);
  margin: 8px 0 10px;
}
