/* ==========================================================================
   Mr. Gillz Study Corner - Multi-Course Interactive Textbook Theme
   ========================================================================== */
:root {
  --primary: #1e3a8a;
  --primary-light: #eff6ff;
  --accent: #0284c7;
  --bg-page: #f8fafc;
  --bg-card: #ffffff;
  --text-main: #1e293b;
  --text-muted: #64748b;
  --border: #e2e8f0;
  --success: #059669;
  --warning: #d97706;
  --sidebar-width: 290px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
body { font-family: 'Inter', -apple-system, sans-serif; background-color: var(--bg-page); color: var(--text-main); line-height: 1.65; display: flex; min-height: 100vh; }

#auth-gate {
  position: fixed; inset: 0; background: linear-gradient(135deg, #0f172a 0%, #1e3a8a 100%);
  z-index: 9999; display: flex; align-items: center; justify-content: center; padding: 1rem;
}
.auth-card { background: #ffffff; width: 100%; max-width: 420px; border-radius: 16px; padding: 2.25rem; box-shadow: 0 25px 50px -12px rgba(0,0,0,0.45); }
.auth-brand { text-align: center; margin-bottom: 1.5rem; }
.auth-brand h1 { font-size: 1.45rem; color: var(--primary); font-weight: 800; }
.auth-brand p { font-size: 0.9rem; color: var(--text-muted); margin-top: 0.25rem; }
.auth-tabs { display: flex; border-bottom: 2px solid var(--border); margin-bottom: 1.25rem; }
.auth-tab { flex: 1; background: none; border: none; padding: 0.65rem; font-weight: 600; font-size: 0.95rem; color: var(--text-muted); cursor: pointer; border-bottom: 2px solid transparent; margin-bottom: -2px; }
.auth-tab.active { color: var(--primary); border-bottom-color: var(--primary); }
.form-group { margin-bottom: 1rem; }
.form-group label { display: block; font-size: 0.85rem; font-weight: 600; margin-bottom: 0.35rem; color: var(--text-main); }
.form-group input { width: 100%; padding: 0.65rem 0.85rem; border: 1px solid #cbd5e1; border-radius: 8px; font-size: 0.95rem; }
.form-group input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(2,132,199,0.15); }
.btn-primary { width: 100%; background: var(--primary); color: #ffffff; border: none; padding: 0.75rem 1rem; border-radius: 8px; font-size: 0.95rem; font-weight: 600; cursor: pointer; transition: background 0.2s; }
.btn-primary:hover { background: #172554; }
.auth-error { color: #dc2626; font-size: 0.85rem; margin-bottom: 0.75rem; display: none; }

#sidebar { width: var(--sidebar-width); background: #ffffff; border-right: 1px solid var(--border); display: flex; flex-direction: column; position: fixed; top: 0; bottom: 0; left: 0; z-index: 100; overflow-y: auto; transition: transform 0.25s ease; }
.sidebar-header { padding: 1.25rem; border-bottom: 1px solid var(--border); background: var(--primary); color: #ffffff; }
.sidebar-header a { color: #ffffff; text-decoration: none; font-weight: 800; font-size: 1.15rem; display: block; }
.sidebar-header span { font-size: 0.78rem; opacity: 0.85; display: block; margin-top: 0.2rem; }

.course-selector-box { padding: 0.85rem 1rem; border-bottom: 1px solid var(--border); background: #f1f5f9; }
.course-selector-box label { font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.05em; font-weight: 700; color: var(--text-muted); display: block; margin-bottom: 0.35rem; }
.course-selector-box select { width: 100%; padding: 0.45rem 0.6rem; border-radius: 6px; border: 1px solid #cbd5e1; font-weight: 600; font-size: 0.88rem; background: #ffffff; color: var(--text-main); }

.nav-menu { padding: 0.75rem 0.65rem; flex: 1; }
.chapter-group { margin-bottom: 0.5rem; }
.chapter-toggle { width: 100%; text-align: left; background: none; border: none; padding: 0.6rem 0.75rem; border-radius: 8px; font-weight: 700; font-size: 0.9rem; color: var(--text-main); cursor: pointer; display: flex; align-items: center; justify-content: space-between; transition: background 0.15s; }
.chapter-toggle:hover { background: #f1f5f9; }
.chapter-toggle .chevron { font-size: 0.75rem; transition: transform 0.2s; }
.chapter-group.open .chevron { transform: rotate(90deg); }
.subtopic-list { list-style: none; padding-left: 0.75rem; margin-top: 0.2rem; display: none; }
.chapter-group.open .subtopic-list { display: block; }
.subtopic-list li a { display: block; padding: 0.48rem 0.75rem; margin-bottom: 0.15rem; border-radius: 6px; font-size: 0.85rem; color: #475569; text-decoration: none; border-left: 2px solid transparent; transition: all 0.15s; }
.subtopic-list li a:hover { background: var(--primary-light); color: var(--primary); }
.subtopic-list li a.active { background: var(--primary-light); color: var(--primary); font-weight: 700; border-left-color: var(--primary); }
.subtopic-list li a.coming-soon { opacity: 0.55; pointer-events: none; }

.sidebar-footer { padding: 0.9rem 1rem; border-top: 1px solid var(--border); font-size: 0.82rem; background: #f8fafc; }
.user-pill { display: flex; align-items: center; justify-content: space-between; gap: 0.5rem; }
.logout-btn { background: #fee2e2; color: #b91c1c; border: none; padding: 0.3rem 0.6rem; border-radius: 6px; font-size: 0.78rem; font-weight: 600; cursor: pointer; }
.admin-badge { background: #dbeafe; color: #1e40af; padding: 0.2rem 0.5rem; border-radius: 4px; font-weight: 700; font-size: 0.72rem; margin-bottom: 0.3rem; display: inline-block; }

.main-wrapper { margin-left: var(--sidebar-width); flex: 1; display: flex; flex-direction: column; min-width: 0; }
.topbar { background: #ffffff; border-bottom: 1px solid var(--border); padding: 0.75rem 2rem; display: flex; align-items: center; justify-content: space-between; position: sticky; top: 0; z-index: 50; }
.mobile-menu-btn { display: none; background: none; border: 1px solid var(--border); padding: 0.4rem 0.7rem; border-radius: 6px; font-size: 1.1rem; cursor: pointer; }
.breadcrumb { font-size: 0.85rem; color: var(--text-muted); }
.breadcrumb strong { color: var(--primary); }
.content-container { max-width: 920px; width: 100%; margin: 0 auto; padding: 2.25rem 2rem 4rem; }

.chapter-badge { display: inline-block; background: var(--primary-light); color: var(--primary); font-weight: 700; font-size: 0.8rem; padding: 0.25rem 0.7rem; border-radius: 999px; margin-bottom: 0.65rem; letter-spacing: 0.03em; }
.page-title { font-size: 2rem; font-weight: 800; color: #0f172a; line-height: 1.25; margin-bottom: 0.5rem; }
.page-meta { font-size: 0.9rem; color: var(--text-muted); padding-bottom: 1.5rem; border-bottom: 2px solid var(--border); margin-bottom: 2rem; }
.section-heading { font-size: 1.4rem; font-weight: 800; color: var(--primary); margin: 2.25rem 0 1rem; padding-bottom: 0.4rem; border-bottom: 1px solid var(--border); }
.sub-heading { font-size: 1.12rem; font-weight: 700; color: #0f172a; margin: 1.5rem 0 0.65rem; }

.concept-card { background: var(--bg-card); border: 1px solid var(--border); border-left: 4px solid var(--accent); border-radius: 10px; padding: 1.35rem 1.5rem; margin-bottom: 1.25rem; box-shadow: 0 1px 3px rgba(0,0,0,0.03); }
.concept-card h4 { font-size: 1.05rem; color: #0f172a; margin-bottom: 0.6rem; }
.concept-card ul, .concept-card ol { padding-left: 1.35rem; margin-top: 0.4rem; }
.concept-card li { margin-bottom: 0.45rem; }
.formula-box { background: #f1f5f9; border: 1px solid #cbd5e1; border-radius: 8px; padding: 0.9rem 1.25rem; margin: 1rem 0; text-align: center; font-size: 1.08rem; }
.exam-tip { background: #fffbeb; border: 1px solid #fde68a; border-left: 4px solid var(--warning); border-radius: 8px; padding: 1rem 1.25rem; margin: 1.15rem 0; font-size: 0.94rem; }
.exam-tip strong { color: #92400e; }

.table-wrapper { overflow-x: auto; margin: 1.25rem 0; border-radius: 10px; border: 1px solid var(--border); }
table { width: 100%; border-collapse: collapse; background: #ffffff; font-size: 0.92rem; }
th { background: var(--primary); color: #ffffff; text-align: left; padding: 0.75rem 1rem; font-weight: 600; }
td { padding: 0.75rem 1rem; border-bottom: 1px solid var(--border); vertical-align: top; }
tr:nth-child(even) td { background: #f8fafc; }

.qtype-card { background: #ffffff; border: 1px solid var(--border); border-radius: 10px; margin-bottom: 1rem; overflow: hidden; box-shadow: 0 1px 2px rgba(0,0,0,0.03); }
.qtype-header { padding: 1.1rem 1.35rem; background: #ffffff; cursor: pointer; display: flex; justify-content: space-between; align-items: center; gap: 1rem; }
.qtype-header:hover { background: #f8fafc; }
.qtype-title { font-weight: 700; font-size: 1.02rem; color: var(--primary); }
.qtype-clue { font-size: 0.88rem; color: var(--text-muted); margin-top: 0.25rem; }
.qtype-btn { background: var(--primary-light); color: var(--primary); border: 1px solid #bfdbfe; padding: 0.35rem 0.75rem; border-radius: 6px; font-size: 0.8rem; font-weight: 600; white-space: nowrap; }
.qtype-body { padding: 1.25rem 1.35rem; border-top: 1px solid var(--border); background: #f8fafc; display: none; }
.qtype-card.open .qtype-body { display: block; }
.qtype-body ol { padding-left: 1.35rem; }
.qtype-body li { margin-bottom: 0.55rem; }

.course-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 1.25rem; margin-top: 1.5rem; }
.course-card { background: #ffffff; border: 1px solid var(--border); border-radius: 12px; padding: 1.5rem; transition: transform 0.15s, box-shadow 0.15s; }
.course-card:hover { transform: translateY(-2px); box-shadow: 0 10px 25px -5px rgba(0,0,0,0.08); }
.course-card h3 { color: var(--primary); margin: 0.5rem 0; }
.course-card p { font-size: 0.9rem; color: var(--text-muted); margin-bottom: 1.15rem; }
.course-link-btn { display: inline-block; background: var(--primary); color: #ffffff; text-decoration: none; padding: 0.55rem 1rem; border-radius: 8px; font-size: 0.88rem; font-weight: 600; }

.page-nav-footer { display: flex; justify-content: space-between; gap: 1rem; margin-top: 3rem; padding-top: 1.5rem; border-top: 1px solid var(--border); }
.nav-btn { display: inline-flex; flex-direction: column; padding: 0.85rem 1.2rem; border: 1px solid var(--border); border-radius: 10px; background: #ffffff; text-decoration: none; color: var(--text-main); max-width: 48%; transition: border-color 0.15s; }
.nav-btn:hover { border-color: var(--primary); }
.nav-btn span { font-size: 0.75rem; color: var(--text-muted); text-transform: uppercase; font-weight: 700; }
.nav-btn strong { font-size: 0.92rem; color: var(--primary); margin-top: 0.2rem; }

.site-copyright { text-align: center; padding: 1.5rem; font-size: 0.82rem; color: var(--text-muted); border-top: 1px solid var(--border); background: #ffffff; }

@media (max-width: 860px) {
  #sidebar { transform: translateX(-100%); }
  #sidebar.mobile-open { transform: translateX(0); }
  .main-wrapper { margin-left: 0; }
  .mobile-menu-btn { display: inline-block; }
  .content-container { padding: 1.5rem 1.15rem 3rem; }
}
