/* ==========================================================================
   👥 SMALL GROUP & FAMILY LEADER HANDOUT GENERATOR STYLES
   ========================================================================== */

/* Modal Backdrop */
.handout-modal-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 10000;
  background: rgba(15, 23, 42, 0.75);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  align-items: center;
  justify-content: center;
  padding: 1.25rem;
  overflow-y: auto;
}

.handout-modal-backdrop.open,
body.handout-modal-open .handout-modal-backdrop {
  display: flex !important;
}

body.handout-modal-open {
  overflow: hidden !important;
}

/* Modal Content Container */
.handout-modal-content {
  background: var(--bg-card, #ffffff);
  color: var(--text-main, #0f172a);
  border: 1px solid var(--border-color, #cbd5e1);
  border-radius: var(--radius-lg, 12px);
  box-shadow: 0 20px 45px rgba(0, 0, 0, 0.35);
  width: 100%;
  max-width: 940px;
  max-height: 92vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  animation: handoutModalFadeIn 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes handoutModalFadeIn {
  from { opacity: 0; transform: scale(0.97) translateY(8px); }
  to { opacity: 1; transform: scale(1) translateY(0); }
}

/* Modal Header */
.handout-modal-header {
  padding: 1.25rem 1.5rem;
  background: var(--bg-subtle, #f8fafc);
  border-bottom: 1px solid var(--border-color, #e2e8f0);
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1rem;
}

.handout-header-left {
  flex: 1;
}

.handout-modal-pill {
  display: inline-block;
  font-size: 0.72rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 0.2rem 0.55rem;
  border-radius: 999px;
  background: var(--brand-primary, #047857);
  color: #ffffff;
  margin-bottom: 0.4rem;
}

.handout-modal-title {
  margin: 0 0 0.25rem;
  font-size: 1.35rem;
  font-weight: 800;
  color: var(--text-main, #0f172a);
  letter-spacing: -0.01em;
}

.handout-modal-sub {
  margin: 0;
  font-size: 0.88rem;
  color: var(--text-muted, #64748b);
  line-height: 1.4;
}

.handout-modal-close-btn {
  background: transparent;
  border: none;
  font-size: 1.3rem;
  line-height: 1;
  color: var(--text-muted, #94a3b8);
  cursor: pointer;
  padding: 0.35rem 0.5rem;
  border-radius: 6px;
  transition: all 0.15s ease;
}

.handout-modal-close-btn:hover {
  background: rgba(0, 0, 0, 0.08);
  color: var(--text-main, #0f172a);
}

/* Toolbar Controls */
.handout-toolbar {
  padding: 0.85rem 1.5rem;
  background: var(--bg-card, #ffffff);
  border-bottom: 1px solid var(--border-color, #e2e8f0);
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.85rem;
}

.handout-toolbar-group {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.handout-label {
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--text-muted, #475569);
  white-space: nowrap;
}

.handout-select {
  font-size: 0.85rem;
  font-weight: 600;
  padding: 0.4rem 0.75rem;
  border-radius: var(--radius-sm, 6px);
  border: 1px solid var(--border-color, #cbd5e1);
  background: var(--bg-card, #ffffff);
  color: var(--text-main, #0f172a);
  cursor: pointer;
  outline: none;
  transition: border-color 0.15s ease;
}

.handout-select:focus {
  border-color: var(--brand-primary, #047857);
}

.handout-toolbar-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-left: auto;
}

.handout-toolbar-actions .btn-primary,
.handout-toolbar-actions .btn-secondary {
  font-size: 0.82rem;
  padding: 0.45rem 0.85rem;
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  border-radius: var(--radius-sm, 6px);
  cursor: pointer;
  font-weight: 700;
  text-decoration: none;
  transition: all 0.15s ease;
}

.btn-success-toast {
  background: #10b981 !important;
  color: #ffffff !important;
  border-color: #059669 !important;
}

/* Preview Wrapper */
.handout-preview-wrapper {
  flex: 1;
  overflow-y: auto;
  background: #cbd5e1;
  padding: 1.5rem;
  display: flex;
  justify-content: center;
}

[data-theme="dark"] .handout-preview-wrapper {
  background: #1e293b;
}

/* The Printable Sheet */
.handout-sheet {
  width: 100%;
  max-width: 800px;
  background: #ffffff !important;
  color: #0f172a !important;
  border-radius: 6px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.18);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  line-height: 1.45;
  box-sizing: border-box;
}

.handout-page {
  padding: 2.25rem 2.25rem;
  box-sizing: border-box;
  background: #ffffff !important;
  color: #0f172a !important;
}

.handout-page.page-2 {
  border-top: 2px dashed #cbd5e1;
  margin-top: 1.5rem;
}

/* Sheet Typography & Header */
.handout-header {
  border-bottom: 2px solid #0f172a;
  padding-bottom: 0.75rem;
  margin-bottom: 1rem;
}

.handout-header-brand {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.35rem;
}

.handout-brand-pill {
  font-size: 0.7rem;
  font-weight: 900;
  background: #0f172a;
  color: #ffffff;
  padding: 0.18rem 0.5rem;
  border-radius: 4px;
  letter-spacing: 0.05em;
}

.handout-header-suite {
  font-size: 0.75rem;
  font-weight: 700;
  color: #64748b;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.handout-main-title {
  margin: 0.35rem 0 0.25rem;
  font-size: 1.45rem;
  font-weight: 900;
  color: #0f172a;
  line-height: 1.25;
}

.handout-meta-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.85rem;
  color: #475569;
  margin-bottom: 0.65rem;
}

.handout-meta-sep {
  color: #cbd5e1;
}

.handout-bible-link {
  color: #1e3a8a;
  font-weight: 700;
  text-decoration: underline;
}

.handout-attendance-strip {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 0.75rem;
  background: #f1f5f9;
  border: 1px solid #e2e8f0;
  border-radius: 4px;
  padding: 0.5rem 0.75rem;
  font-size: 0.8rem;
  color: #334155;
  margin-top: 0.5rem;
}

/* Sections */
.handout-section {
  margin-bottom: 1.15rem;
}

.handout-section-header {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  border-bottom: 1.5px solid #cbd5e1;
  padding-bottom: 0.25rem;
  margin-bottom: 0.65rem;
}

.handout-section-num {
  font-size: 0.65rem;
  font-weight: 900;
  background: #0f172a;
  color: #ffffff;
  padding: 0.15rem 0.4rem;
  border-radius: 3px;
  text-transform: uppercase;
}

.handout-section-header h4 {
  margin: 0;
  font-size: 0.95rem;
  font-weight: 800;
  color: #0f172a;
  letter-spacing: -0.01em;
}

/* Section 1: Icebreaker */
.handout-icebreaker-content {
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-left: 3.5px solid #0284c7;
  border-radius: 0 6px 6px 0;
  padding: 0.65rem 0.85rem;
  font-size: 0.88rem;
  line-height: 1.45;
  color: #1e293b;
}

.handout-icebreaker-content p {
  margin: 0;
}

/* Section 2: Scripture & Core Truth */
.handout-verse-box {
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-left: 3.5px solid #2563eb;
  border-radius: 0 6px 6px 0;
  padding: 0.65rem 0.85rem;
  margin-bottom: 0.55rem;
}

.handout-verse-ref {
  font-size: 0.82rem;
  font-weight: 800;
  color: #1e3a8a;
  text-transform: uppercase;
}

.handout-verse-text {
  margin: 0.25rem 0 0;
  font-style: italic;
  font-size: 0.9rem;
  line-height: 1.45;
  color: #0f172a;
}

.handout-key-truth {
  background: #f0fdf4;
  border: 1px solid #bbf7d0;
  border-left: 3.5px solid #16a34a;
  border-radius: 0 6px 6px 0;
  padding: 0.55rem 0.85rem;
  font-size: 0.86rem;
  margin-bottom: 0.55rem;
}

.handout-truth-label {
  font-size: 0.72rem;
  font-weight: 900;
  color: #15803d;
  text-transform: uppercase;
  margin-bottom: 0.2rem;
}

.handout-truth-text {
  margin: 0;
  color: #14532d;
  line-height: 1.4;
}

.handout-talking-points {
  background: #fefce8;
  border: 1px solid #fef08a;
  border-radius: 6px;
  padding: 0.55rem 0.85rem;
  margin-top: 0.45rem;
}

.handout-points-label {
  font-size: 0.72rem;
  font-weight: 900;
  color: #854d0e;
  text-transform: uppercase;
  margin-bottom: 0.25rem;
}

.handout-points-list {
  margin: 0 0 0 1.25rem;
  padding: 0;
  font-size: 0.84rem;
  color: #713f12;
  line-height: 1.4;
}

/* Section 3: Questions */
.handout-questions-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.55rem;
}

.handout-q-item {
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 6px;
  padding: 0.6rem 0.85rem;
}

.handout-q-tag {
  display: block;
  font-size: 0.72rem;
  font-weight: 900;
  color: #475569;
  text-transform: uppercase;
  margin-bottom: 0.25rem;
}

.handout-q-item p {
  margin: 0;
  font-size: 0.87rem;
  line-height: 1.42;
  color: #0f172a;
}

/* Section 4: Practice / Apologetics */
.handout-practice-grid,
.handout-apol-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
}

.handout-columbo-box,
.handout-answer-box,
.handout-apol-box {
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 6px;
  padding: 0.65rem 0.85rem;
}

.handout-box-title {
  font-size: 0.72rem;
  font-weight: 900;
  color: #334155;
  text-transform: uppercase;
  margin-bottom: 0.35rem;
}

.handout-quote {
  margin: 0 0 0.35rem;
  font-style: italic;
  font-weight: 700;
  color: #1e3a8a;
  font-size: 0.88rem;
}

.handout-subtext {
  font-size: 0.78rem;
  color: #64748b;
  line-height: 1.35;
}

.handout-scenario-box {
  background: #fffbeb;
  border: 1px solid #fde68a;
  border-radius: 6px;
  padding: 0.65rem 0.85rem;
  margin-top: 0.65rem;
  font-size: 0.85rem;
}

.handout-scenario-quote {
  margin: 0.25rem 0;
  font-style: italic;
  color: #92400e;
}

.handout-scenario-prompt {
  font-size: 0.8rem;
  color: #78350f;
  margin-top: 0.25rem;
}

/* Compact Bottom Row */
.handout-compact-bottom-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
  margin-top: 0.75rem;
}

.handout-action-box {
  background: #f0f9ff;
  border: 1px solid #bae6fd;
  border-radius: 6px;
  padding: 0.65rem 0.85rem;
  font-size: 0.84rem;
  color: #0369a1;
}

.handout-action-box p {
  margin: 0;
  line-height: 1.38;
}

.handout-prayer-box {
  background: #fdf4ff;
  border: 1px solid #f5d0fe;
  border-radius: 6px;
  padding: 0.65rem 0.85rem;
  font-size: 0.84rem;
  color: #86198f;
  font-style: italic;
}

.handout-prayer-box p {
  margin: 0;
  line-height: 1.38;
}

.handout-box-badge {
  display: block;
  font-size: 0.7rem;
  font-weight: 900;
  font-style: normal;
  text-transform: uppercase;
  margin-bottom: 0.25rem;
}

/* Notes & Prayer Requests Area */
.handout-notes-box {
  background: #f8fafc;
  border: 1px solid #cbd5e1;
  border-radius: 6px;
  padding: 0.65rem 0.85rem;
  margin-top: 0.75rem;
}

.notes-header {
  display: flex;
  justify-content: space-between;
  font-size: 0.78rem;
  font-weight: 800;
  color: #475569;
  text-transform: uppercase;
  margin-bottom: 0.4rem;
}

.notes-subhead {
  font-size: 0.75rem;
  font-weight: 800;
  color: #475569;
  text-transform: uppercase;
  margin-bottom: 0.35rem;
}

.note-line {
  font-family: monospace;
  font-size: 0.78rem;
  color: #94a3b8;
  letter-spacing: -0.05em;
  line-height: 1.6;
}

.handout-footer {
  border-top: 1.5px solid #cbd5e1;
  margin-top: 1rem;
  padding-top: 0.5rem;
  display: flex;
  justify-content: space-between;
  font-size: 0.72rem;
  color: #64748b;
}

/* Page 2 Header */
.handout-page2-header {
  border-bottom: 2px solid #0f172a;
  padding-bottom: 0.5rem;
  margin-bottom: 1rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.handout-page2-title {
  font-size: 1.15rem;
  font-weight: 800;
  color: #0f172a;
}

.handout-page2-meta {
  font-size: 0.8rem;
  color: #64748b;
  font-weight: 600;
}

/* Footer Modal Toolbar */
.handout-modal-footer {
  padding: 0.85rem 1.5rem;
  background: var(--bg-subtle, #f8fafc);
  border-top: 1px solid var(--border-color, #e2e8f0);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
}

.handout-footer-tip {
  font-size: 0.8rem;
  color: var(--text-muted, #64748b);
}

/* In-Page Quick Launch Row (in Family Prompts Card) */
.family-leader-export-row {
  margin-top: 1rem;
  padding: 0.85rem 1rem;
  background: var(--bg-subtle, #f8fafc);
  border: 1px solid var(--border-color, #e2e8f0);
  border-radius: var(--radius-md, 8px);
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
}

.leader-export-info {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.88rem;
  color: var(--text-main, #1e293b);
  font-weight: 600;
}

.leader-export-badge {
  font-size: 0.7rem;
  font-weight: 800;
  text-transform: uppercase;
  background: var(--brand-primary, #047857);
  color: #ffffff;
  padding: 0.2rem 0.5rem;
  border-radius: 999px;
}

/* ==========================================================================
   🖨️ HIGH-PRECISION PRINT STYLESHEET FOR 8.5x11 & A4 PAPER
   ========================================================================== */

@media print {
  /* Hide the rest of the web application entirely when printing handout */
  body.printing-handout * {
    visibility: hidden !important;
  }

  body.printing-handout #handoutModal,
  body.printing-handout #handoutModal * {
    visibility: visible !important;
  }

  body.printing-handout {
    background: #ffffff !important;
    margin: 0 !important;
    padding: 0 !important;
    width: 100% !important;
  }

  body.printing-handout #handoutModal {
    position: absolute !important;
    left: 0 !important;
    top: 0 !important;
    width: 100% !important;
    margin: 0 !important;
    padding: 0 !important;
    background: transparent !important;
    backdrop-filter: none !important;
    display: block !important;
    overflow: visible !important;
  }

  body.printing-handout .handout-modal-content {
    border: none !important;
    box-shadow: none !important;
    max-width: 100% !important;
    max-height: none !important;
    overflow: visible !important;
    background: #ffffff !important;
    border-radius: 0 !important;
    animation: none !important;
  }

  body.printing-handout .handout-modal-header,
  body.printing-handout .handout-toolbar,
  body.printing-handout .handout-modal-footer {
    display: none !important;
  }

  body.printing-handout .handout-preview-wrapper {
    background: #ffffff !important;
    padding: 0 !important;
    overflow: visible !important;
    display: block !important;
  }

  body.printing-handout .handout-sheet {
    box-shadow: none !important;
    border-radius: 0 !important;
    max-width: 100% !important;
    width: 100% !important;
    padding: 0 !important;
  }

  body.printing-handout .handout-page {
    padding: 0.4in 0.4in !important;
    page-break-after: always;
  }

  body.printing-handout .layout-compact-single {
    page-break-after: avoid !important;
    font-size: 9.5pt !important;
    padding: 0.35in 0.35in !important;
  }

  body.printing-handout .layout-compact-single .handout-main-title {
    font-size: 15pt !important;
  }

  body.printing-handout .layout-compact-single .handout-section {
    margin-bottom: 0.75rem !important;
  }

  body.printing-handout .handout-bible-link {
    text-decoration: none !important;
    color: #0f172a !important;
  }
}

@media (max-width: 680px) {
  .handout-modal-backdrop {
    padding: 0.5rem;
  }
  .handout-modal-content {
    max-height: 96vh;
    border-radius: 12px;
  }
  .handout-modal-header {
    padding: 1rem;
    flex-direction: column;
    gap: 0.5rem;
  }
  .handout-modal-close {
    position: absolute;
    top: 0.75rem;
    right: 0.75rem;
  }
  .handout-modal-footer {
    flex-direction: column;
    gap: 0.5rem;
    padding: 0.85rem;
  }
  .handout-footer-actions {
    flex-direction: column;
    width: 100%;
  }
  .handout-footer-actions button {
    width: 100%;
    justify-content: center;
    min-height: 42px;
  }
  .handout-settings-bar {
    flex-direction: column;
    align-items: stretch;
    gap: 0.5rem;
  }
}
