/* ==========================================================================
   FRANCHISE COOKBOOK GENERATOR — DESIGN SYSTEM & STYLESHEET
   ========================================================================== */

:root {
  /* Color Palette */
  --bg-main: #F8FAFC;
  --bg-surface: #FFFFFF;
  --bg-surface-subtle: #F1F5F9;
  --bg-dark: #0F172A;
  --bg-dark-surface: #1E293B;

  --text-primary: #0F172A;
  --text-secondary: #475569;
  --text-muted: #94A3B8;
  --text-inverse: #F8FAFC;

  --brand-crimson: #B91C1C;
  --brand-crimson-hover: #991B1B;
  --brand-crimson-light: #FEF2F2;
  --brand-amber: #D97706;
  --brand-amber-light: #FFFBEB;
  --brand-emerald: #059669;
  --brand-emerald-light: #ECFDF5;

  --border-color: #E2E8F0;
  --border-color-hover: #CBD5E1;
  --border-focus: #B91C1C;

  /* Typography */
  --font-serif: 'Cinzel', Georgia, serif;
  --font-sans: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;

  /* Elevation & Shadows */
  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.07), 0 2px 4px -2px rgba(0, 0, 0, 0.05);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.08), 0 4px 6px -4px rgba(0, 0, 0, 0.04);
  --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 8px 10px -6px rgba(0, 0, 0, 0.05);

  /* Radii */
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
  --radius-full: 9999px;

  /* Transitions */
  --transition-fast: 0.15s ease;
  --transition-normal: 0.25s ease;
}

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

[hidden] {
  display: none !important;
}

body {
  font-family: var(--font-sans);
  background-color: var(--bg-main);
  color: var(--text-primary);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ==========================================================================
   TOP HEADER & NAVIGATION
   ========================================================================== */

.site-header {
  background-color: var(--bg-dark);
  color: var(--text-inverse);
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  position: sticky;
  top: 0;
  z-index: 50;
  backdrop-filter: blur(12px);
}

.header-container {
  max-width: 1280px;
  margin: 0 auto;
  padding: 1rem 1.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1.5rem;
  flex-wrap: wrap;
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  text-decoration: none;
}

.brand-icon {
  font-size: 1.75rem;
  line-height: 1;
  background: rgba(255, 255, 255, 0.1);
  padding: 0.5rem;
  border-radius: var(--radius-md);
  border: 1px solid rgba(255, 255, 255, 0.15);
}

.brand-text {
  display: flex;
  flex-direction: column;
}

.brand-title {
  font-family: var(--font-serif);
  font-size: 1.15rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  color: #FFFFFF;
}

.brand-tagline {
  font-size: 0.75rem;
  color: var(--text-muted);
  font-weight: 500;
  letter-spacing: 0.02em;
}

.nav-tabs {
  display: flex;
  gap: 0.5rem;
  background: rgba(255, 255, 255, 0.06);
  padding: 0.35rem;
  border-radius: var(--radius-lg);
  border: 1px solid rgba(255, 255, 255, 0.1);
}

.nav-tab {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 1.1rem;
  border-radius: var(--radius-md);
  border: none;
  background: transparent;
  color: var(--text-muted);
  font-family: var(--font-sans);
  font-size: 0.875rem;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.nav-tab:hover {
  color: #FFFFFF;
  background: rgba(255, 255, 255, 0.08);
}

.nav-tab.active {
  background: var(--brand-crimson);
  color: #FFFFFF;
  box-shadow: 0 2px 8px rgba(185, 28, 28, 0.4);
}

.badge-free {
  font-size: 0.7rem;
  background: rgba(16, 185, 129, 0.2);
  color: #6EE7B7;
  padding: 0.15rem 0.45rem;
  border-radius: var(--radius-full);
  font-weight: 700;
  letter-spacing: 0.02em;
}

/* ==========================================================================
   MAIN CONTENT & HERO SECTIONS
   ========================================================================== */

.main-content {
  flex: 1;
  max-width: 1280px;
  width: 100%;
  margin: 0 auto;
  padding: 2.5rem 1.5rem 4rem;
}

.view-section {
  display: block;
}

.view-section[hidden] {
  display: none !important;
}

.section-hero {
  text-align: center;
  max-width: 760px;
  margin: 0 auto 2.5rem;
}

.hero-badge {
  display: inline-block;
  font-family: var(--font-sans);
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--brand-crimson);
  background: var(--brand-crimson-light);
  padding: 0.25rem 0.85rem;
  border-radius: var(--radius-full);
  margin-bottom: 0.75rem;
  border: 1px solid rgba(185, 28, 28, 0.15);
}

.hero-title {
  font-family: var(--font-serif);
  font-size: 2.25rem;
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1.2;
  margin-bottom: 0.85rem;
  letter-spacing: -0.01em;
}

.hero-desc {
  font-size: 1rem;
  color: var(--text-secondary);
  line-height: 1.6;
}

/* ==========================================================================
   VIEW 1: CURATED SHOWCASE LIBRARY
   ========================================================================== */

.filter-wrapper {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-top: 1.75rem;
  flex-wrap: wrap;
}

.search-box {
  flex: 1;
  min-width: 280px;
  position: relative;
  display: flex;
  align-items: center;
}

.search-icon {
  position: absolute;
  left: 1rem;
  font-size: 0.95rem;
  color: var(--text-muted);
  pointer-events: none;
}

.search-box input {
  width: 100%;
  padding: 0.75rem 1rem 0.75rem 2.6rem;
  font-family: var(--font-sans);
  font-size: 0.95rem;
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  color: var(--text-primary);
  box-shadow: var(--shadow-sm);
  outline: none;
  transition: all var(--transition-fast);
}

.search-box input:focus {
  border-color: var(--brand-crimson);
  box-shadow: 0 0 0 3px rgba(185, 28, 28, 0.12);
}

.library-stats {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-secondary);
  background: var(--bg-surface-subtle);
  padding: 0.5rem 1rem;
  border-radius: var(--radius-full);
  border: 1px solid var(--border-color);
}

/* Library Card Grid */
.library-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
  gap: 1.75rem;
  margin-top: 2rem;
}

.cookbook-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-md);
  transition: transform var(--transition-normal), box-shadow var(--transition-normal), border-color var(--transition-normal);
  position: relative;
  overflow: hidden;
}

.cookbook-card:hover {
  transform: translateY(-5px);
  box-shadow: var(--shadow-xl);
  border-color: var(--border-color-hover);
}

.card-cover-header {
  position: relative;
  min-height: 200px;
  background-color: #1E293B;
  background-size: cover;
  background-position: center top;
  background-repeat: no-repeat;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border-bottom: 1px solid var(--border-color);
  cursor: pointer;
  transition: opacity var(--transition-fast);
}

.card-cover-header:hover .card-title {
  color: #FEF08A;
}

.card-cover-overlay {
  background: linear-gradient(180deg, rgba(15, 23, 42, 0.45) 0%, rgba(15, 23, 42, 0.75) 55%, rgba(15, 23, 42, 0.96) 100%);
  padding: 1.2rem;
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  backdrop-filter: blur(1px);
}

.card-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 1.25rem;
}

.faction-tag {
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 0.25rem 0.65rem;
  border-radius: var(--radius-sm);
  color: #FFFFFF;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
}

.card-page-badge {
  font-size: 0.72rem;
  font-weight: 700;
  color: #FFFFFF;
  background: rgba(255, 255, 255, 0.2);
  padding: 0.2rem 0.55rem;
  border-radius: var(--radius-sm);
  backdrop-filter: blur(4px);
  border: 1px solid rgba(255, 255, 255, 0.25);
}

.card-title {
  font-family: var(--font-serif);
  font-size: 1.28rem;
  font-weight: 700;
  color: #FFFFFF;
  line-height: 1.3;
  margin-bottom: 0.25rem;
  text-shadow: 0 2px 4px rgba(0, 0, 0, 0.6);
}

.card-subtitle {
  font-size: 0.82rem;
  font-weight: 600;
  color: #FBBF24;
  line-height: 1.4;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.6);
}

.card-body {
  padding: 1.25rem;
  display: flex;
  flex-direction: column;
  flex: 1;
  background: var(--bg-surface);
}

.card-desc {
  font-size: 0.875rem;
  color: var(--text-secondary);
  line-height: 1.55;
  margin-bottom: 1.15rem;
  flex: 1;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
  min-height: 4.1em;
}

.card-meta-list {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 1.25rem;
}

.meta-pill {
  font-size: 0.75rem;
  font-weight: 600;
  background: var(--bg-surface-subtle);
  color: var(--text-secondary);
  padding: 0.2rem 0.6rem;
  border-radius: var(--radius-full);
  border: 1px solid var(--border-color);
}

.card-actions {
  display: flex;
  gap: 0.75rem;
  margin-top: auto;
}

.btn-read-card {
  flex: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
  background: var(--brand-crimson);
  color: #FFFFFF;
  border: none;
  padding: 0.65rem 1rem;
  border-radius: var(--radius-md);
  font-family: var(--font-sans);
  font-size: 0.875rem;
  font-weight: 600;
  cursor: pointer;
  transition: background var(--transition-fast), transform var(--transition-fast);
}

.btn-read-card:hover {
  background: var(--brand-crimson-hover);
  transform: scale(1.02);
}

.btn-download-card {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.65rem 0.95rem;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
  background: var(--bg-surface);
  color: var(--text-secondary);
  text-decoration: none;
  font-size: 0.875rem;
  font-weight: 600;
  transition: all var(--transition-fast);
}

.btn-download-card:hover {
  background: var(--bg-surface-subtle);
  color: var(--text-primary);
  border-color: var(--border-color-hover);
}

/* ==========================================================================
   VIEW 2: LIVE GENERATION STUDIO
   ========================================================================== */

.generator-layout {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 2rem;
  align-items: start;
}

@media (max-width: 960px) {
  .generator-layout {
    grid-template-columns: 1fr;
  }
}

.form-card, .status-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 2rem;
  box-shadow: var(--shadow-lg);
}

.card-heading {
  font-family: var(--font-serif);
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 1.25rem;
  border-bottom: 1px solid var(--border-color);
  padding-bottom: 0.75rem;
}

/* Preset Chips */
.presets-section {
  margin-bottom: 1.5rem;
}

.presets-label {
  display: block;
  font-size: 0.8rem;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--text-secondary);
  margin-bottom: 0.6rem;
  letter-spacing: 0.04em;
}

.preset-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
}

.chip {
  background: var(--bg-surface-subtle);
  border: 1px solid var(--border-color);
  color: var(--text-secondary);
  font-family: var(--font-sans);
  font-size: 0.78rem;
  font-weight: 600;
  padding: 0.35rem 0.75rem;
  border-radius: var(--radius-full);
  cursor: pointer;
  transition: all var(--transition-fast);
}

.chip:hover {
  background: #E2E8F0;
  color: var(--text-primary);
  border-color: var(--border-color-hover);
  transform: scale(1.02);
}

/* Generation Form Inputs */
.generation-form {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

.input-group {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.input-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.input-header label {
  font-size: 0.875rem;
  font-weight: 700;
  color: var(--text-primary);
}

.char-counter {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-muted);
}

.input-group input {
  padding: 0.75rem 1rem;
  font-family: var(--font-sans);
  font-size: 0.95rem;
  background: var(--bg-surface);
  border: 1.5px solid var(--border-color);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  outline: none;
  transition: all var(--transition-fast);
}

.input-group input:focus {
  border-color: var(--brand-crimson);
  box-shadow: 0 0 0 3px rgba(185, 28, 28, 0.12);
}

.security-note {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.78rem;
  color: var(--text-secondary);
  background: var(--bg-surface-subtle);
  padding: 0.65rem 0.85rem;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
  line-height: 1.4;
}

.btn-generate {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.6rem;
  background: var(--brand-crimson);
  color: #FFFFFF;
  border: none;
  padding: 0.9rem 1.5rem;
  border-radius: var(--radius-md);
  font-family: var(--font-sans);
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(185, 28, 28, 0.3);
  transition: all var(--transition-fast);
}

.btn-generate:hover:not(:disabled) {
  background: var(--brand-crimson-hover);
  transform: translateY(-2px);
  box-shadow: 0 6px 16px rgba(185, 28, 28, 0.4);
}

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

/* ==========================================================================
   STATUS CARD & REAL-TIME PROGRESS
   ========================================================================== */

.status-card {
  min-height: 480px;
  display: flex;
  flex-direction: column;
}

/* Idle State */
.status-idle {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  margin: auto;
  padding: 3rem 1.5rem;
  color: var(--text-muted);
}

.idle-icon {
  font-size: 3rem;
  margin-bottom: 1rem;
  opacity: 0.7;
}

.status-idle h3 {
  font-family: var(--font-serif);
  font-size: 1.35rem;
  color: var(--text-primary);
  margin-bottom: 0.5rem;
}

.status-idle p {
  font-size: 0.9rem;
  max-width: 340px;
  line-height: 1.5;
}

/* Live Progress Elements */
.live-progress-container {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
  flex: 1;
}

.progress-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.progress-title-wrap {
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

.pulsing-dot {
  width: 10px;
  height: 10px;
  background-color: var(--brand-crimson);
  border-radius: 50%;
  animation: pulse 1.5s infinite;
}

@keyframes pulse {
  0% { transform: scale(0.9); box-shadow: 0 0 0 0 rgba(185, 28, 28, 0.7); }
  70% { transform: scale(1.1); box-shadow: 0 0 0 8px rgba(185, 28, 28, 0); }
  100% { transform: scale(0.9); box-shadow: 0 0 0 0 rgba(185, 28, 28, 0); }
}

.progress-title {
  font-family: var(--font-sans);
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--text-primary);
}

.progress-pct-badge {
  font-size: 0.9rem;
  font-weight: 800;
  color: var(--brand-crimson);
  background: var(--brand-crimson-light);
  padding: 0.25rem 0.75rem;
  border-radius: var(--radius-full);
}

.progress-track {
  width: 100%;
  height: 10px;
  background: var(--bg-surface-subtle);
  border-radius: var(--radius-full);
  overflow: hidden;
  border: 1px solid var(--border-color);
}

.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, #B91C1C, #D97706);
  border-radius: var(--radius-full);
  transition: width 0.35s ease;
}

/* Stepper Pills */
.pipeline-stepper {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0.4rem;
}

.step-pill {
  text-align: center;
  font-size: 0.75rem;
  font-weight: 700;
  padding: 0.35rem 0.2rem;
  border-radius: var(--radius-sm);
  background: var(--bg-surface-subtle);
  color: var(--text-muted);
  border: 1px solid var(--border-color);
  transition: all var(--transition-fast);
}

.step-pill.active {
  background: var(--brand-crimson-light);
  color: var(--brand-crimson);
  border-color: rgba(185, 28, 28, 0.3);
}

.step-pill.complete {
  background: var(--brand-emerald-light);
  color: var(--brand-emerald);
  border-color: rgba(5, 150, 105, 0.3);
}

.step-num {
  display: inline-block;
  margin-right: 0.2rem;
}

/* Notice Banner */
.notice-banner {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.75rem 1rem;
  border-radius: var(--radius-md);
  font-size: 0.85rem;
  font-weight: 600;
}

.notice-banner[hidden],
.result-error-container[hidden],
.result-success-container[hidden],
.live-progress-container[hidden],
.status-idle[hidden] {
  display: none !important;
}

.warning-banner {
  background: var(--brand-amber-light);
  color: #92400E;
  border: 1px solid #FCD34D;
}

/* Granular Log Feed */
.log-feed-wrapper {
  background: #0F172A;
  border-radius: var(--radius-md);
  padding: 0.85rem;
  color: #E2E8F0;
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 200px;
  max-height: 240px;
}

.log-feed-header {
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  margin-bottom: 0.5rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  padding-bottom: 0.35rem;
}

.log-feed {
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  font-family: 'SFMono-Regular', Consolas, 'Liberation Mono', Menlo, monospace;
  font-size: 0.8rem;
  line-height: 1.4;
}

.log-item {
  display: flex;
  gap: 0.4rem;
  animation: fadeIn 0.2s ease;
}

.log-item.item_complete {
  color: #34D399;
}

.log-item.warning {
  color: #FBBF24;
}

.log-item.error {
  color: #F87171;
}

.log-item.countdown {
  color: #60A5FA;
  font-weight: 600;
  background: rgba(59, 130, 246, 0.12);
  padding: 0.2rem 0.5rem;
  border-radius: 4px;
  border-left: 3px solid #3B82F6;
}

.log-item.info {
  color: #94A3B8;
}

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

/* ==========================================================================
   SUCCESS RESULT CARD
   ========================================================================== */

.result-success-container {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
  margin: auto 0;
  animation: fadeIn 0.3s ease;
}

.success-header {
  display: flex;
  align-items: flex-start;
  gap: 1rem;
}

.success-check-icon {
  font-size: 2.25rem;
  background: var(--brand-emerald-light);
  padding: 0.6rem;
  border-radius: var(--radius-md);
  border: 1px solid rgba(5, 150, 105, 0.2);
}

.success-pill {
  font-size: 0.7rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  color: var(--brand-emerald);
  margin-bottom: 0.25rem;
}

.success-book-title {
  font-family: var(--font-serif);
  font-size: 1.45rem;
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1.3;
}

.success-book-subtitle {
  font-size: 0.9rem;
  color: var(--brand-amber);
  font-weight: 600;
}

.success-metrics {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0.75rem;
  background: var(--bg-surface-subtle);
  border: 1px solid var(--border-color);
  padding: 1rem;
  border-radius: var(--radius-md);
}

.metric-item {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}

.metric-label {
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--text-muted);
}

.metric-value {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text-primary);
}

.success-actions {
  display: flex;
  gap: 1rem;
  flex-wrap: wrap;
}

.btn-preview-pdf {
  flex: 1;
  min-width: 180px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  background: var(--brand-crimson);
  color: #FFFFFF;
  border: none;
  padding: 0.85rem 1.25rem;
  border-radius: var(--radius-md);
  font-family: var(--font-sans);
  font-size: 0.95rem;
  font-weight: 700;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.btn-preview-pdf:hover {
  background: var(--brand-crimson-hover);
  transform: translateY(-2px);
}

.btn-download-pdf {
  flex: 1;
  min-width: 180px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  background: var(--bg-surface);
  color: var(--text-primary);
  border: 1.5px solid var(--border-color);
  padding: 0.85rem 1.25rem;
  border-radius: var(--radius-md);
  font-family: var(--font-sans);
  font-size: 0.95rem;
  font-weight: 700;
  text-decoration: none;
  transition: all var(--transition-fast);
}

.btn-download-pdf:hover {
  background: var(--bg-surface-subtle);
  border-color: var(--border-color-hover);
}

/* Error Container */
.result-error-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  margin: auto;
  padding: 2rem;
  gap: 0.75rem;
}

.error-icon {
  font-size: 2.5rem;
}

.result-error-container h3 {
  font-family: var(--font-serif);
  font-size: 1.25rem;
  color: var(--brand-crimson);
}

.result-error-container p {
  font-size: 0.9rem;
  color: var(--text-secondary);
  max-width: 360px;
}

.btn-retry {
  margin-top: 0.5rem;
  background: var(--bg-dark);
  color: #FFFFFF;
  border: none;
  padding: 0.6rem 1.25rem;
  border-radius: var(--radius-md);
  font-weight: 600;
  cursor: pointer;
}

/* ==========================================================================
   IN-BROWSER PDF READER MODAL
   ========================================================================== */

.pdf-modal-backdrop {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(15, 23, 42, 0.85);
  backdrop-filter: blur(8px);
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
}

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

.pdf-modal-window {
  background: var(--bg-surface);
  width: 100%;
  max-width: 1080px;
  height: 90vh;
  border-radius: var(--radius-lg);
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.35);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.15);
  animation: scaleIn 0.2s ease;
}

@keyframes scaleIn {
  from { opacity: 0; transform: scale(0.96); }
  to { opacity: 1; transform: scale(1); }
}

.modal-header {
  background: var(--bg-dark);
  color: #FFFFFF;
  padding: 0.85rem 1.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.modal-title-group {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  overflow: hidden;
}

.modal-badge {
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  background: var(--brand-crimson);
  color: #FFFFFF;
  padding: 0.2rem 0.55rem;
  border-radius: var(--radius-sm);
  white-space: nowrap;
}

.modal-title {
  font-family: var(--font-serif);
  font-size: 1.15rem;
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.modal-header-actions {
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

.btn-modal-action {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.8rem;
  font-weight: 600;
  color: #FFFFFF;
  background: rgba(255, 255, 255, 0.1);
  padding: 0.45rem 0.85rem;
  border-radius: var(--radius-md);
  text-decoration: none;
  transition: background var(--transition-fast);
}

.btn-modal-action:hover {
  background: rgba(255, 255, 255, 0.2);
}

.btn-modal-download {
  background: var(--brand-crimson);
}

.btn-modal-download:hover {
  background: var(--brand-crimson-hover);
}

.btn-modal-close {
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 1.25rem;
  cursor: pointer;
  padding: 0.25rem 0.5rem;
  border-radius: var(--radius-sm);
  transition: color var(--transition-fast);
}

.btn-modal-close:hover {
  color: #FFFFFF;
}

.modal-body {
  flex: 1;
  background: #2D3748;
}

.pdf-viewer-frame {
  width: 100%;
  height: 100%;
  border: none;
}

/* Loading Spinner */
.loading-state {
  grid-column: 1 / -1;
  text-align: center;
  padding: 4rem 1rem;
  color: var(--text-secondary);
}

.spinner {
  width: 36px;
  height: 36px;
  border: 3px solid var(--border-color);
  border-top-color: var(--brand-crimson);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin: 0 auto 1rem;
}

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