/* ============================================================
   CAMPBELL FAMILY MASTER BIBLICAL STUDY GUIDE
   Shared Stylesheet — v3.0 Mobile-Responsive
   ============================================================ */

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

body {
  font-family: Georgia, serif;
  background: #f8f6f0;
  color: #222;
}

/* ── LAYOUT ─────────────────────────────────────────────── */

#app { display: flex; min-height: 100vh; }

#main {
  margin-left: 260px;
  flex: 1;
  padding: 40px 48px;
  max-width: 960px;
}

/* ── SIDEBAR ─────────────────────────────────────────────── */

#sidebar {
  width: 260px;
  min-width: 260px;
  background: #1F3864;
  color: #fff;
  position: fixed;
  top: 0;
  left: 0;
  height: 100vh;
  height: 100dvh; /* iOS Safari: accounts for bottom browser toolbar */
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  z-index: 100;
  display: flex;
  flex-direction: column;
  transition: transform 0.3s ease;
}

#sidebar-header {
  padding: 20px 16px 14px;
  border-bottom: 1px solid rgba(255,255,255,0.15);
}

#sidebar-header h1 {
  font-size: 14px;
  font-weight: bold;
  line-height: 1.5;
  color: #FFD700;
}

#sidebar-header p {
  font-size: 11px;
  color: rgba(255,255,255,0.5);
  margin-top: 4px;
  font-style: italic;
}

#sidebar-nav {
  padding-bottom: 120px; /* extra space so last items clear iOS Safari bottom toolbar */
  padding-bottom: calc(24px + env(safe-area-inset-bottom, 0px) + 80px);
}

.nav-section {
  padding: 12px 16px 4px;
  font-size: 9px;
  font-weight: bold;
  color: rgba(255,255,255,0.4);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  font-family: Arial, sans-serif;
}

.nav-item {
  display: block;
  padding: 8px 16px;
  font-size: 12px;
  color: rgba(255,255,255,0.8);
  cursor: pointer;
  border-left: 3px solid transparent;
  line-height: 1.4;
  transition: all 0.15s;
  font-family: Arial, sans-serif;
  text-decoration: none;
}

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

.nav-item.active {
  background: rgba(255,255,255,0.12);
  color: #FFD700;
  border-left-color: #FFD700;
  font-weight: bold;
}

.nav-item.sub {
  padding-left: 28px;
  font-size: 11px;
  color: rgba(255,255,255,0.65);
}

.nav-item.sub:hover { color: #fff; }
.nav-item.sub.active { color: #FFD700; }

/* ── SIDEBAR OVERLAY (mobile) ───────────────────────────── */
#sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 99;
  opacity: 0;
  transition: opacity 0.3s ease;
}
#sidebar-overlay.visible {
  opacity: 1;
}

/* ── HAMBURGER BUTTON ────────────────────────────────── */
#hamburger-btn {
  display: none;
  background: transparent;
  border: none;
  color: #FFD700;
  font-size: 22px;
  cursor: pointer;
  padding: 2px 6px;
  line-height: 1;
  margin-right: 2px;
  flex-shrink: 0;
}

/* ── GITHUB BAR ──────────────────────────────────────────── */

#github-bar {
  position: fixed;
  top: 0; left: 0; right: 0;
  background: #1F3864;
  color: white;
  z-index: 200;
  padding: 4px 12px;
  display: flex;
  align-items: center;
  gap: 8px;
  font-family: Arial, sans-serif;
  font-size: 11px;
  border-bottom: 2px solid #FFD700;
  flex-wrap: nowrap;
  overflow: hidden;
  height: 40px;
  box-sizing: border-box;
  white-space: nowrap;
}

#github-bar .bar-title {
  font-weight: bold;
  color: #FFD700;
  white-space: nowrap;
}

#github-bar .bar-sep {
  color: rgba(255,255,255,0.3);
}

#gh-token {
  padding: 4px 8px;
  border-radius: 4px;
  border: 1px solid rgba(255,255,255,0.3);
  font-size: 10px;
  width: 180px;
  background: rgba(255,255,255,0.1);
  color: white;
}

#gh-token::placeholder { color: rgba(255,255,255,0.5); }

.btn-save {
  background: #FFD700;
  color: #1F3864;
  border: none;
  border-radius: 4px;
  padding: 4px 10px;
  font-size: 10px;
  font-weight: bold;
  cursor: pointer;
  white-space: nowrap;
  flex-shrink: 0;
}

.btn-save:hover { background: #e6c200; }

#gh-status {
  font-size: 10px;
  color: rgba(255,255,255,0.6);
}

.bar-right {
  margin-left: auto;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 0;
  flex-shrink: 0;
  line-height: 1.3;
}

.bar-right .bar-sep { display: none; }

#gh-bar-version {
  font-size: 9px;
  color: rgba(255,255,255,0.4);
  white-space: normal;
  text-align: right;
  line-height: 1.3;
}

/* Shift main content below fixed bar */
#app { margin-top: 40px; }

/* ── TYPOGRAPHY ─────────────────────────────────────────── */

.page-tag {
  display: inline-block;
  background: #1F3864;
  color: #FFD700;
  font-size: 10px;
  font-weight: bold;
  padding: 3px 10px;
  border-radius: 20px;
  margin-bottom: 10px;
  font-family: Arial, sans-serif;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

h1.page-title {
  font-size: 28px;
  color: #1F3864;
  margin-bottom: 6px;
  font-weight: bold;
}

.page-subtitle {
  font-size: 13px;
  color: #888;
  margin-bottom: 20px;
  font-style: italic;
  font-family: Arial, sans-serif;
}

h2.section-title {
  font-size: 18px;
  color: #1F3864;
  margin: 28px 0 10px;
  font-weight: bold;
  border-bottom: 2px solid #2E75B6;
  padding-bottom: 6px;
}

h3.sub-title {
  font-size: 15px;
  color: #2E75B6;
  margin: 18px 0 8px;
  font-weight: bold;
  font-family: Arial, sans-serif;
}

p.body {
  font-size: 14px;
  color: #444;
  line-height: 1.8;
  margin-bottom: 12px;
}

.divider {
  height: 1px;
  background: #ddd;
  margin: 28px 0;
}

/* ── BOXES ───────────────────────────────────────────────── */

.scripture-box {
  background: #FFFDF0;
  border: 1px solid #C8A800;
  border-left: 4px solid #C8A800;
  border-radius: 6px;
  padding: 14px 16px;
  margin: 12px 0;
}

.scripture-box .ref {
  font-size: 12px;
  font-weight: bold;
  color: #7A6600;
  margin-bottom: 6px;
  font-family: Arial, sans-serif;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.scripture-box .text {
  font-size: 14px;
  color: #444;
  font-style: italic;
  line-height: 1.8;
}

.info-box {
  background: #EBF4FC;
  border: 1px solid #2E75B6;
  border-radius: 6px;
  padding: 14px 16px;
  margin: 12px 0;
}

.info-box .title {
  font-size: 12px;
  font-weight: bold;
  color: #1F3864;
  margin-bottom: 8px;
  font-family: Arial, sans-serif;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.info-box .line {
  font-size: 13px;
  color: #333;
  line-height: 1.7;
  padding: 3px 0;
  font-family: Arial, sans-serif;
}

.reflection-box {
  background: #F4F8EE;
  border: 1px solid #6B8E3A;
  border-radius: 6px;
  padding: 14px 16px;
  margin: 12px 0;
}

.reflection-box .title {
  font-size: 12px;
  font-weight: bold;
  color: #3B5E1A;
  margin-bottom: 10px;
  font-family: Arial, sans-serif;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.reflection-item {
  font-size: 13px;
  color: #444;
  line-height: 1.7;
  padding: 6px 0;
  border-bottom: 1px solid #C8DBA8;
  font-family: Arial, sans-serif;
}

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

.notes-box {
  background: #FFFBF0;
  border: 1px solid #C8A800;
  border-radius: 6px;
  padding: 14px 16px;
  margin: 14px 0;
}

.notes-box .label {
  font-size: 12px;
  font-weight: bold;
  color: #7A6600;
  margin-bottom: 8px;
  font-family: Arial, sans-serif;
}

textarea.notes-input {
  width: 100%;
  border: 1px solid #ddd;
  border-radius: 4px;
  padding: 10px 12px;
  font-size: 13px;
  color: #333;
  background: #fff;
  font-family: Georgia, serif;
  resize: vertical;
  min-height: 100px;
  line-height: 1.7;
  margin-top: 4px;
}

textarea.notes-input:focus {
  outline: none;
  border-color: #1F3864;
  box-shadow: 0 0 0 2px rgba(31,56,100,0.1);
}

.cross-ref-box {
  background: #EBF4FC;
  border: 1px solid #2E75B6;
  border-radius: 6px;
  padding: 14px 16px;
  margin: 12px 0;
}

.cross-ref-box .title {
  font-size: 12px;
  font-weight: bold;
  color: #1F3864;
  margin-bottom: 8px;
  font-family: Arial, sans-serif;
  text-transform: uppercase;
}

.cross-ref-box .line {
  font-size: 13px;
  color: #333;
  line-height: 1.7;
  padding: 3px 0;
  font-family: Arial, sans-serif;
}

.views-box {
  border: 1px solid #ccc;
  border-radius: 6px;
  overflow: hidden;
  margin: 12px 0;
}

.view-item {
  padding: 12px 16px;
  border-bottom: 1px solid #eee;
}

.view-item:last-child { border-bottom: none; }
.view-item:nth-child(even) { background: #fafafa; }

.view-title {
  font-size: 14px;
  font-weight: bold;
  color: #1F3864;
  margin-bottom: 4px;
  font-family: Arial, sans-serif;
}

.view-body {
  font-size: 13px;
  color: #555;
  line-height: 1.7;
}

.view-key {
  font-size: 12px;
  color: #2E75B6;
  margin-top: 4px;
  font-style: italic;
  font-family: Arial, sans-serif;
}

/* ── TABLES ──────────────────────────────────────────────── */

.checklist-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
  margin: 12px 0;
  font-family: Arial, sans-serif;
}

.checklist-table th {
  background: #1F3864;
  color: #fff;
  padding: 10px 12px;
  text-align: left;
  font-weight: bold;
  font-size: 12px;
}

.checklist-table td {
  padding: 9px 12px;
  border-bottom: 1px solid #eee;
  color: #444;
  vertical-align: top;
}

.checklist-table tr:nth-child(even) td { background: #f9f9f9; }

.status-fulfilled { color: #2E6B0E; font-weight: bold; }
.status-progress  { color: #7A4F00; font-weight: bold; }
.status-notyet    { color: #999; }

.sermon-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
  margin: 12px 0;
  font-family: Arial, sans-serif;
}

.sermon-table th {
  background: #1F3864;
  color: #fff;
  padding: 10px 12px;
  text-align: left;
  font-weight: bold;
  font-size: 12px;
}

.sermon-table td {
  padding: 9px 12px;
  border-bottom: 1px solid #eee;
  color: #444;
  vertical-align: top;
}

.sermon-table tr:nth-child(even) td { background: #f9f9f9; }

/* ── JOURNAL ────────────────────────────────────────────── */

.journal-box {
  background: #FFF8EE;
  border: 1px solid #C8A800;
  border-radius: 8px;
  padding: 20px;
  margin: 16px 0;
}

.journal-date  { font-size: 16px; font-weight: bold; color: #1F3864; margin-bottom: 3px; }
.journal-topic { font-size: 13px; color: #7A6600; font-weight: bold; margin-bottom: 2px; font-family: Arial, sans-serif; }
.journal-cat   { font-size: 12px; color: #3B5E1A; font-style: italic; margin-bottom: 14px; font-family: Arial, sans-serif; }
.journal-p     { font-size: 14px; color: #444; line-height: 1.8; margin-bottom: 10px; }

.journal-qs { margin-top: 12px; padding-top: 12px; border-top: 1px solid #E5C875; }

.journal-qs-title {
  font-size: 12px;
  font-weight: bold;
  color: #1F3864;
  margin-bottom: 8px;
  font-family: Arial, sans-serif;
  text-transform: uppercase;
}

.journal-q {
  font-size: 13px;
  color: #555;
  line-height: 1.7;
  padding: 4px 0 4px 12px;
  border-left: 3px solid #C8A800;
  margin-bottom: 6px;
  font-family: Arial, sans-serif;
}

/* ── BULLET LISTS ───────────────────────────────────────── */

ul.bullet-list { margin: 8px 0 12px 20px; }

ul.bullet-list li {
  font-size: 14px;
  color: #444;
  line-height: 1.8;
  margin-bottom: 4px;
  font-family: Arial, sans-serif;
}

/* ── BUTTONS ────────────────────────────────────────────── */

.btn-primary {
  background: #1F3864;
  color: #fff;
  border: none;
  border-radius: 6px;
  padding: 10px 20px;
  font-size: 13px;
  cursor: pointer;
  font-family: Arial, sans-serif;
  font-weight: bold;
  display: inline-block;
  margin-top: 16px;
  text-decoration: none;
}

.btn-primary:hover { background: #2E4F8A; }

.btn-print {
  background: #fff;
  color: #1F3864;
  border: 1px solid #1F3864;
  border-radius: 6px;
  padding: 8px 16px;
  font-size: 12px;
  cursor: pointer;
  font-family: Arial, sans-serif;
  margin-left: 10px;
}

.btn-print:hover { background: #f0f4ff; }

/* ── COMING SOON ─────────────────────────────────────────── */

.coming-soon {
  background: #f9f9f9;
  border: 2px dashed #ccc;
  border-radius: 8px;
  padding: 48px 24px;
  text-align: center;
  margin: 20px 0;
}

.coming-soon p {
  font-size: 15px;
  color: #999;
  font-family: Arial, sans-serif;
}

/* ── PRINT ───────────────────────────────────────────────── */

@media print {
  #sidebar, #github-bar, #hamburger-btn, #sidebar-overlay { display: none; }
  #main { margin-left: 0; padding: 20px; }
  .btn-primary, .btn-print { display: none; }
  textarea.notes-input { border: 1px solid #ccc; min-height: 60px; }
}

/* ── ORIGINATED DATE ─────────────────────────────────────── */
.bar-originated {
  font-size: 9px;
  color: rgba(255,255,255,0.4);
  font-style: italic;
  text-align: right;
  line-height: 1.3;
}

/* ── AI BUTTON & RESPONSE ────────────────────────────────── */
.ai-btn {
  background: linear-gradient(135deg, #2E75B6, #1F3864);
  color: #FFD700;
  border: 1px solid rgba(255,215,0,0.4);
  border-radius: 6px;
  padding: 10px 20px;
  font-size: 13px;
  font-weight: bold;
  font-family: Arial, sans-serif;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-top: 8px;
  transition: all 0.2s;
}
.ai-btn:hover { background: linear-gradient(135deg, #3A8ACA, #2E4F8A); }
.ai-btn:disabled { opacity: 0.6; cursor: not-allowed; }

.ai-response-box {
  background: #F0F4FF;
  border: 1px solid #2E75B6;
  border-left: 4px solid #2E75B6;
  border-radius: 6px;
  padding: 16px 18px;
  margin: 14px 0;
  font-size: 14px;
  color: #333;
  line-height: 1.8;
  font-family: Georgia, serif;
  display: none;
}
.ai-response-box.visible { display: block; }
.ai-response-box .ai-label {
  font-size: 11px;
  font-weight: bold;
  color: #1F3864;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: 10px;
  font-family: Arial, sans-serif;
}

.ai-input-row {
  display: flex;
  gap: 8px;
  margin-top: 10px;
  align-items: flex-start;
}
.ai-prompt-input {
  flex: 1;
  border: 1px solid #2E75B6;
  border-radius: 4px;
  padding: 8px 12px;
  font-size: 13px;
  font-family: Georgia, serif;
  color: #333;
  resize: vertical;
  min-height: 44px;
}
.ai-prompt-input:focus { outline: none; border-color: #1F3864; box-shadow: 0 0 0 2px rgba(31,56,100,0.1); }

/* ── COLLAPSIBLE NAV SECTIONS ────────────────────────────── */
.nav-section-collapsible {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 16px 4px;
  font-size: 9px;
  font-weight: bold;
  color: rgba(255,255,255,0.55);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  font-family: Arial, sans-serif;
  cursor: pointer;
  user-select: none;
  transition: color 0.15s;
}

.nav-section-collapsible:hover {
  color: rgba(255,255,255,0.85);
}

.nav-arrow {
  font-size: 8px;
  color: rgba(255,255,255,0.4);
  transition: transform 0.2s ease, color 0.15s;
  display: inline-block;
  transform: rotate(0deg);
}

.nav-arrow.open {
  transform: rotate(90deg);
  color: #FFD700;
}

.nav-section-items {
  overflow: hidden;
  max-height: 600px;
  transition: max-height 0.25s ease, opacity 0.2s ease;
  opacity: 1;
}

.nav-section-items.collapsed {
  max-height: 0;
  opacity: 0;
}

/* ── LOAD BUTTON ─────────────────────────────────────────── */
.btn-load {
  background: transparent;
  color: #FFD700;
  border: 1px solid rgba(255,215,0,0.5);
  border-radius: 4px;
  padding: 6px 14px;
  font-size: 12px;
  font-weight: bold;
  cursor: pointer;
  font-family: Arial, sans-serif;
  transition: background 0.15s;
  white-space: nowrap;
}
.btn-load:hover { background: rgba(255,215,0,0.12); }

/* ── TIMESTAMP BUTTON ────────────────────────────────────── */
.btn-timestamp {
  background: transparent;
  color: rgba(255,255,255,0.75);
  border: 1px solid rgba(255,255,255,0.3);
  border-radius: 4px;
  padding: 6px 14px;
  font-size: 12px;
  font-family: Arial, sans-serif;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
  margin-left: 4px;
}
.btn-timestamp:hover {
  background: rgba(255,255,255,0.12);
  color: #fff;
}

/* ── STUDY TIMER DISPLAY ─────────────────────────────────── */
.study-timer-display {
  font-size: 11px;
  color: rgba(255,255,255,0.55);
  font-family: Arial, sans-serif;
  margin-left: 8px;
  white-space: nowrap;
  align-self: center;
}

/* ══════════════════════════════════════════════════════════
   MOBILE RESPONSIVE — breakpoint 768px
   ══════════════════════════════════════════════════════════ */

@media (max-width: 768px) {

  /* ── Show hamburger, hide token input and bar extras ── */
  #hamburger-btn { display: block; }

  #gh-token { display: none; }

  /* Show a compact token button instead on mobile */
  #mobile-token-btn {
    display: inline-block !important;
  }

  /* Hide bar extras (session/total timers) on small screens */
  #bar-extras { display: none !important; }

  /* Hide bar separator and originated text on mobile */
  .bar-originated,
  #github-bar .bar-sep:not(:first-of-type) { display: none; }

  /* Compact bar right */
  .bar-right { gap: 6px; }

  #gh-bar-version { font-size: 10px; }

  /* ── Sidebar: hidden off-screen by default ── */
  #sidebar {
    transform: translateX(-100%);
    z-index: 300;
    width: 280px;
    min-width: 280px;
    /* Slightly wider on mobile for easier tapping */
    top: 0;
    bottom: 0;              /* iOS reliable: anchor to visible bottom */
    height: auto;           /* let top+bottom govern height */
    max-height: none;
    padding-bottom: env(safe-area-inset-bottom, 0px);
  }

  #sidebar.open {
    transform: translateX(0);
  }

  /* Overlay shown when sidebar open */
  #sidebar-overlay {
    display: block;
    pointer-events: none;
  }
  #sidebar-overlay.visible {
    pointer-events: auto;
  }

  /* ── Main content: full width, no left margin ── */
  #main {
    margin-left: 0 !important;
    padding: 20px 16px 40px;
    max-width: 100%;
  }

  /* ── Typography adjustments ── */
  h1.page-title { font-size: 22px; }
  h2.section-title { font-size: 16px; }
  h3.sub-title { font-size: 14px; }
  p.body { font-size: 14px; }

  /* ── Tables: make scrollable horizontally ── */
  .checklist-table,
  .sermon-table {
    display: block;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    white-space: nowrap;
  }

  /* ── Nav items: bigger tap targets on mobile ── */
  .nav-item {
    padding: 11px 16px;
    font-size: 13px;
  }

  .nav-item.sub {
    padding: 10px 16px 10px 28px;
    font-size: 12px;
  }

  /* ── Github bar: tighter on mobile ── */
  #github-bar {
    padding: 8px 12px;
    gap: 8px;
  }

  /* ── AI input row: stack on mobile ── */
  .ai-input-row {
    flex-direction: column;
  }

  .ai-btn { width: 100%; justify-content: center; }

  /* ── Notes textarea: taller on mobile for comfort ── */
  textarea.notes-input { min-height: 120px; font-size: 15px; }

  /* ── Journal boxes ── */
  .journal-box { padding: 14px; }
  .journal-p { font-size: 14px; }

  /* ── Scripture/info boxes ── */
  .scripture-box, .info-box, .reflection-box,
  .notes-box, .cross-ref-box { padding: 12px 14px; }

  /* ── Save/load buttons: slightly smaller ── */
  .btn-save, .btn-load {
    padding: 6px 10px;
    font-size: 11px;
  }

  /* ── Bar title: shorter on very small screens ── */
  #github-bar .bar-title { font-size: 12px; }

  /* ── Module nav prev/next: stack if needed ── */
  #main > div[style*="justify-content:space-between"] {
    flex-wrap: wrap;
    gap: 10px;
  }
}

@media (max-width: 400px) {
  #github-bar .bar-title { display: none; }
  #github-bar .bar-sep:first-of-type { display: none; }
  #gh-bar-version { font-size: 9px; }
  #main { padding: 16px 12px 40px; }
  h1.page-title { font-size: 20px; }
}
