/* ==========================================================================
   FormatFox - Production Shared Stylesheet
   No external frameworks, no external font requests, pure vanilla CSS.
   ========================================================================== */

:root {
  --font-sans: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Nirmala UI", "Mangal", "Noto Sans Devanagari", sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, Consolas, "Liberation Mono", Menlo, monospace;
  
  /* Light Theme */
  --bg-primary: #f8fafc;
  --bg-surface: #ffffff;
  --bg-surface-alt: #f1f5f9;
  --text-main: #0f172a;
  --text-muted: #475569;
  --text-subtle: #64748b;
  --border-color: #e2e8f0;
  --border-focus: #2563eb;
  
  --primary: #1d4ed8;
  --primary-hover: #1e40af;
  --primary-subtle: #eff6ff;
  --primary-text: #1e3a8a;

  --accent: #0f766e;
  --accent-subtle: #f0fdfa;
  
  --success: #166534;
  --success-bg: #dcfce7;
  
  --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
  --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
  --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
  
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
  
  --max-width: 1200px;
  --container-padding: 1.25rem;
}

[data-theme="dark"] {
  --bg-primary: #090d16;
  --bg-surface: #111827;
  --bg-surface-alt: #1f2937;
  --text-main: #f9fafb;
  --text-muted: #cbd5e1;
  --text-subtle: #94a3b8;
  --border-color: #334155;
  --border-focus: #60a5fa;
  
  --primary: #3b82f6;
  --primary-hover: #60a5fa;
  --primary-subtle: #1e293b;
  --primary-text: #93c5fd;

  --accent: #14b8a6;
  --accent-subtle: #134e4a;
  
  --success: #4ade80;
  --success-bg: #064e3b;
  
  --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.5);
  --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.4);
  --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.4);
}

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

html {
  font-family: var(--font-sans);
  line-height: 1.6;
  color: var(--text-main);
  background-color: var(--bg-primary);
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
  scroll-behavior: smooth;
}

body {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

a {
  color: var(--primary);
  text-decoration: none;
  transition: color 0.15s ease;
}

a:hover {
  text-decoration: underline;
  color: var(--primary-hover);
}

img, svg {
  vertical-align: middle;
  max-width: 100%;
}

button, input, select, textarea {
  font: inherit;
  color: inherit;
}

/* Layout Containers */
.container {
  width: 100%;
  max-width: var(--max-width);
  margin-left: auto;
  margin-right: auto;
  padding-left: var(--container-padding);
  padding-right: var(--container-padding);
}

/* Header & Navigation */
.site-header {
  background-color: var(--bg-surface);
  border-bottom: 1px solid var(--border-color);
  position: sticky;
  top: 0;
  z-index: 40;
  box-shadow: var(--shadow-sm);
}

.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 68px;
  gap: 1rem;
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  font-size: 1.35rem;
  font-weight: 700;
  color: var(--text-main);
  text-decoration: none;
}

.brand:hover {
  text-decoration: none;
}

.brand-icon {
  width: 32px;
  height: 32px;
  background: linear-gradient(135deg, #1d4ed8, #0f766e);
  color: #ffffff;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 1.1rem;
}

.brand-badge {
  font-size: 0.72rem;
  font-weight: 600;
  background: var(--accent-subtle);
  color: var(--accent);
  padding: 0.15rem 0.45rem;
  border-radius: var(--radius-sm);
  letter-spacing: 0.02em;
}

.nav-links {
  display: flex;
  align-items: center;
  gap: 1.25rem;
  list-style: none;
}

.nav-link {
  font-size: 0.95rem;
  font-weight: 500;
  color: var(--text-muted);
  padding: 0.4rem 0.2rem;
}

.nav-link:hover, .nav-link.active {
  color: var(--primary);
  text-decoration: none;
}

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

.theme-toggle {
  background: var(--bg-surface-alt);
  border: 1px solid var(--border-color);
  color: var(--text-main);
  width: 38px;
  height: 38px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s ease;
}

.theme-toggle:hover {
  border-color: var(--border-focus);
}

.mobile-menu-btn {
  display: none;
  background: var(--bg-surface-alt);
  border: 1px solid var(--border-color);
  width: 38px;
  height: 38px;
  border-radius: var(--radius-md);
  cursor: pointer;
  align-items: center;
  justify-content: center;
}

/* Breadcrumbs */
.breadcrumbs {
  padding: 1rem 0;
  font-size: 0.88rem;
  color: var(--text-subtle);
}

.breadcrumbs ol {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
  list-style: none;
}

.breadcrumbs li:not(:last-child)::after {
  content: "/";
  margin-left: 0.5rem;
  color: var(--border-color);
}

.breadcrumbs a {
  color: var(--text-muted);
}

.breadcrumbs li:last-child {
  color: var(--text-main);
  font-weight: 500;
}

/* Page Hero */
.hero {
  padding: 2.5rem 0 1.5rem;
  text-align: center;
}

.hero h1 {
  font-size: 2.25rem;
  font-weight: 800;
  line-height: 1.25;
  color: var(--text-main);
  margin-bottom: 0.75rem;
}

.hero p {
  font-size: 1.15rem;
  color: var(--text-muted);
  max-width: 760px;
  margin: 0 auto;
}

/* Search Bar Component */
.search-container {
  max-width: 650px;
  margin: 1.5rem auto 2.5rem;
  position: relative;
}

.search-input-wrapper {
  position: relative;
  display: flex;
  align-items: center;
}

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

.search-input {
  width: 100%;
  padding: 0.85rem 1rem 0.85rem 2.75rem;
  font-size: 1.05rem;
  border: 2px solid var(--border-color);
  border-radius: var(--radius-md);
  background-color: var(--bg-surface);
  color: var(--text-main);
  outline: none;
  transition: all 0.2s ease;
  box-shadow: var(--shadow-sm);
}

.search-input:focus {
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
}

.search-results-dropdown {
  display: none;
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  right: 0;
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  max-height: 380px;
  overflow-y: auto;
  z-index: 50;
}

.search-result-item {
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--border-color);
  display: block;
}

.search-result-item:last-child {
  border-bottom: none;
}

.search-result-item:hover {
  background: var(--bg-surface-alt);
  text-decoration: none;
}

.search-result-title {
  font-weight: 600;
  font-size: 0.95rem;
  color: var(--text-main);
}

.search-result-meta {
  font-size: 0.8rem;
  color: var(--text-subtle);
  margin-top: 0.2rem;
}

/* Category Grid on Homepage */
.category-section {
  margin-bottom: 3.5rem;
}

.section-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 1.25rem;
  border-bottom: 2px solid var(--border-color);
  padding-bottom: 0.5rem;
}

.section-title {
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--text-main);
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.view-all-link {
  font-size: 0.92rem;
  font-weight: 600;
}

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

.template-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 1.25rem;
  display: flex;
  flex-direction: column;
  transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease;
  box-shadow: var(--shadow-sm);
}

.template-card:hover {
  transform: translateY(-2px);
  border-color: var(--primary);
  box-shadow: var(--shadow-md);
}

.template-card-category {
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--accent);
  letter-spacing: 0.05em;
  margin-bottom: 0.35rem;
}

.template-card-title {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text-main);
  margin-bottom: 0.5rem;
  line-height: 1.35;
}

.template-card-desc {
  font-size: 0.9rem;
  color: var(--text-muted);
  line-height: 1.5;
  margin-bottom: 1rem;
  flex-grow: 1;
}

.template-card-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--primary);
  padding-top: 0.75rem;
  border-top: 1px solid var(--border-color);
}

/* Template Page Tool Architecture */
.tool-wrapper {
  margin: 1.5rem 0 2.5rem;
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  overflow: hidden;
}

.tool-header-banner {
  background: linear-gradient(135deg, var(--bg-surface-alt), var(--bg-surface));
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
}

.tool-privacy-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  background: var(--success-bg);
  color: var(--success);
  font-size: 0.82rem;
  font-weight: 600;
  padding: 0.3rem 0.65rem;
  border-radius: 999px;
}

.tool-controls-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.75rem;
}

.toggle-group {
  display: inline-flex;
  background: var(--bg-surface-alt);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 2px;
}

.toggle-btn {
  background: transparent;
  border: none;
  padding: 0.35rem 0.75rem;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-muted);
  border-radius: calc(var(--radius-md) - 2px);
  cursor: pointer;
  transition: all 0.15s ease;
}

.toggle-btn.active {
  background: var(--bg-surface);
  color: var(--text-main);
  box-shadow: var(--shadow-sm);
}

.tool-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0;
  min-height: 520px;
}

.tool-form-col {
  padding: 1.5rem;
  background: var(--bg-surface);
  border-right: 1px solid var(--border-color);
  overflow-y: auto;
  max-height: 750px;
}

.form-group {
  margin-bottom: 1rem;
}

.form-group label {
  display: block;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-main);
  margin-bottom: 0.35rem;
}

.form-control {
  width: 100%;
  padding: 0.55rem 0.75rem;
  font-size: 0.92rem;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  background-color: var(--bg-surface-alt);
  color: var(--text-main);
  outline: none;
  transition: border-color 0.15s ease;
}

.form-control:focus {
  border-color: var(--border-focus);
  background-color: var(--bg-surface);
}

.tool-preview-col {
  padding: 1.5rem;
  background: var(--bg-surface-alt);
  display: flex;
  flex-direction: column;
}

.preview-actions-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
  gap: 0.6rem;
  margin-bottom: 1rem;
}

.action-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.5rem 0.85rem;
  font-size: 0.88rem;
  font-weight: 600;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-color);
  background: var(--bg-surface);
  color: var(--text-main);
  cursor: pointer;
  transition: all 0.15s ease;
  box-shadow: var(--shadow-sm);
}

.action-btn:hover {
  background: var(--bg-surface-alt);
  border-color: var(--text-subtle);
}

.action-btn.primary {
  background: var(--primary);
  color: #ffffff;
  border-color: var(--primary);
}

.action-btn.primary:hover {
  background: var(--primary-hover);
}

.preview-paper {
  background: #ffffff;
  color: #0f172a;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 2rem 2.25rem;
  box-shadow: var(--shadow-sm);
  font-size: 0.95rem;
  line-height: 1.7;
  white-space: pre-wrap;
  word-break: break-word;
  min-height: 480px;
  flex-grow: 1;
  font-family: inherit;
}

[data-theme="dark"] .preview-paper {
  background: #1e293b;
  color: #f8fafc;
  border-color: #334155;
}

.bilingual-preview-wrapper {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
  flex-grow: 1;
}

.bilingual-pane {
  background: #ffffff;
  color: #0f172a;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 1.25rem;
  font-size: 0.88rem;
  line-height: 1.65;
  white-space: pre-wrap;
  overflow-y: auto;
  max-height: 600px;
}

[data-theme="dark"] .bilingual-pane {
  background: #1e293b;
  color: #f8fafc;
  border-color: #334155;
}

.pane-label {
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--primary);
  margin-bottom: 0.5rem;
  padding-bottom: 0.25rem;
  border-bottom: 1px dashed var(--border-color);
}

/* Toast Notification */
.toast {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  background: var(--text-main);
  color: var(--bg-surface);
  padding: 0.65rem 1.25rem;
  border-radius: var(--radius-md);
  font-size: 0.9rem;
  font-weight: 600;
  box-shadow: var(--shadow-lg);
  z-index: 100;
  display: none;
  animation: slideUp 0.2s ease-out;
}

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

/* Content Columns & Guides */
.template-guide-content {
  margin: 3rem 0;
  max-width: 820px;
}

.template-guide-content h2 {
  font-size: 1.6rem;
  font-weight: 700;
  margin: 2rem 0 0.75rem;
  color: var(--text-main);
}

.template-guide-content h3 {
  font-size: 1.25rem;
  font-weight: 600;
  margin: 1.5rem 0 0.5rem;
  color: var(--text-main);
}

.template-guide-content p {
  font-size: 1.02rem;
  line-height: 1.7;
  color: var(--text-muted);
  margin-bottom: 1rem;
}

.info-box {
  background: var(--bg-surface);
  border-left: 4px solid var(--primary);
  border-radius: 0 var(--radius-md) var(--radius-md) 0;
  padding: 1.25rem;
  margin: 1.5rem 0;
  box-shadow: var(--shadow-sm);
}

.info-box-title {
  font-weight: 700;
  font-size: 1.05rem;
  margin-bottom: 0.5rem;
  color: var(--text-main);
}

.checklist {
  list-style: none;
  margin: 1rem 0;
}

.checklist li {
  position: relative;
  padding-left: 1.75rem;
  margin-bottom: 0.6rem;
  font-size: 0.98rem;
  color: var(--text-muted);
}

.checklist li::before {
  content: "✓";
  position: absolute;
  left: 0;
  color: var(--success);
  font-weight: bold;
}

.mistake-list li::before {
  content: "✕";
  color: #dc2626;
}

/* FAQ Accordion */
.faq-section {
  margin: 3rem 0;
}

.faq-item {
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  margin-bottom: 0.75rem;
  background: var(--bg-surface);
  overflow: hidden;
}

.faq-question {
  width: 100%;
  text-align: left;
  padding: 1rem 1.25rem;
  background: transparent;
  border: none;
  font-size: 1.02rem;
  font-weight: 600;
  color: var(--text-main);
  display: flex;
  justify-content: space-between;
  align-items: center;
  cursor: pointer;
}

.faq-answer {
  padding: 0 1.25rem 1.25rem;
  color: var(--text-muted);
  font-size: 0.95rem;
  line-height: 1.65;
  display: none;
}

.faq-item.open .faq-answer {
  display: block;
}

.faq-item.open .faq-question {
  color: var(--primary);
}

/* Related Templates */
.related-section {
  margin: 3.5rem 0;
  border-top: 1px solid var(--border-color);
  padding-top: 2rem;
}

/* Policy / Institutional Pages */
.legal-page-content {
  max-width: 820px;
  margin: 2rem auto 4rem;
}

.legal-page-content h1 {
  font-size: 2.2rem;
  font-weight: 800;
  margin-bottom: 0.5rem;
}

.legal-meta {
  font-size: 0.9rem;
  color: var(--text-subtle);
  margin-bottom: 2rem;
  border-bottom: 1px solid var(--border-color);
  padding-bottom: 0.75rem;
}

.legal-page-content h2 {
  font-size: 1.45rem;
  font-weight: 700;
  margin: 1.75rem 0 0.5rem;
}

.legal-page-content p {
  font-size: 1rem;
  line-height: 1.7;
  color: var(--text-muted);
  margin-bottom: 1rem;
}

.legal-page-content ul {
  margin: 1rem 0 1.5rem 1.75rem;
  color: var(--text-muted);
}

.legal-page-content li {
  margin-bottom: 0.45rem;
}

/* Ad Containers (Rendered only when ADS_ENABLED is true) */
.ad-slot-below-tool {
  min-height: 280px;
  margin: 2rem 0;
  background: var(--bg-surface-alt);
  border: 1px dashed var(--border-color);
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
}

.ad-slot-in-content {
  min-height: 250px;
  margin: 2.5rem 0;
  background: var(--bg-surface-alt);
  border: 1px dashed var(--border-color);
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Footer */
.site-footer {
  margin-top: auto;
  background-color: var(--bg-surface);
  border-top: 1px solid var(--border-color);
  padding: 3rem 0 1.5rem;
  font-size: 0.92rem;
}

.footer-grid {
  display: grid;
  grid-template-columns: 2fr 1fr 1fr 1.5fr;
  gap: 2rem;
  margin-bottom: 2.5rem;
}

.footer-col h4 {
  font-size: 0.95rem;
  font-weight: 700;
  margin-bottom: 1rem;
  color: var(--text-main);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.footer-links {
  list-style: none;
}

.footer-links li {
  margin-bottom: 0.55rem;
}

.footer-links a {
  color: var(--text-muted);
}

.footer-links a:hover {
  color: var(--primary);
}

.footer-bottom {
  border-top: 1px solid var(--border-color);
  padding-top: 1.5rem;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  color: var(--text-subtle);
  font-size: 0.85rem;
}

/* Print Stylesheet */
@media print {
  /* Hide non-printable elements */
  .site-header,
  .breadcrumbs,
  .tool-header-banner,
  .tool-form-col,
  .preview-actions-bar,
  .template-guide-content,
  .faq-section,
  .related-section,
  .ad-slot-below-tool,
  .ad-slot-in-content,
  .site-footer,
  .toast,
  .search-container {
    display: none !important;
  }
  
  body, html {
    background: #ffffff !important;
    color: #000000 !important;
    font-size: 12pt !important;
  }
  
  .container {
    max-width: 100% !important;
    padding: 0 !important;
    margin: 0 !important;
  }

  .tool-wrapper {
    border: none !important;
    box-shadow: none !important;
    margin: 0 !important;
  }

  .tool-grid {
    display: block !important;
  }

  .tool-preview-col {
    background: #ffffff !important;
    padding: 0 !important;
  }

  .preview-paper {
    border: none !important;
    padding: 0 !important;
    font-size: 12pt !important;
    line-height: 1.6 !important;
    color: #000000 !important;
    background: transparent !important;
  }

  .bilingual-preview-wrapper {
    display: block !important;
  }

  .bilingual-pane {
    border: none !important;
    padding: 0 !important;
    margin-bottom: 20mm !important;
    page-break-after: always;
  }

  @page {
    margin: 20mm 15mm;
  }
}

/* Responsive Breakpoints */
@media (max-width: 900px) {
  .tool-grid {
    grid-template-columns: 1fr;
  }
  .tool-form-col {
    border-right: none;
    border-bottom: 1px solid var(--border-color);
  }
  .footer-grid {
    grid-template-columns: 1fr 1fr;
  }
}

@media (max-width: 640px) {
  .header-inner {
    height: 60px;
  }
  .nav-links {
    display: none;
  }
  .mobile-menu-btn {
    display: flex;
  }
  .hero h1 {
    font-size: 1.75rem;
  }
  .cards-grid {
    grid-template-columns: 1fr;
  }
  .bilingual-preview-wrapper {
    grid-template-columns: 1fr;
  }
  .footer-grid {
    grid-template-columns: 1fr;
  }
}
