/* ============================================================
   RGUHS Checklist — style.css
   To re-brand: change --purple and --teal in :root only.
   BREAKPOINTS: <400px Mobile S | <600px Mobile M | <768px Tablet
   ============================================================ */

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --purple: #6a1b9a; --teal: #00897b;
  --purple-light: #f3e5f5; --purple-mid: #ce93d8;
  --teal-light: #e0f2f1; --teal-mid: #80cbc4;
  --danger: #e53935; --warn: #f57c00; --success: #2e7d32;
  --bg: #f6f5fb; --card-bg: #ffffff; --input-bg: #f9f6ff;
  --border-soft: #ece7f5; --border-focus: var(--purple);
  --text-main: #1a1a2e; --text-muted: #5f6368; --text-inverse: #ffffff;
  --shadow-sm: 0 2px 6px rgba(0,0,0,0.10);
  --shadow-md: 0 6px 20px rgba(64,0,128,0.12);
  --shadow-lg: 0 12px 32px rgba(64,0,128,0.18);
  --ticker-bg: linear-gradient(90deg, var(--purple), var(--teal));
  --transition: 0.2s ease;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-left: env(safe-area-inset-left, 0px);
  --safe-right: env(safe-area-inset-right, 0px);
}

[data-theme="dark"] {
  --bg: #0f0e17; --card-bg: #1a1a2e; --input-bg: #16213e;
  --border-soft: #2a2a4a; --border-focus: var(--purple-mid);
  --text-main: #e0dff5; --text-muted: #9e9bbf; --text-inverse: #e0dff5;
  --shadow-sm: 0 2px 6px rgba(0,0,0,0.40);
  --shadow-md: 0 6px 20px rgba(0,0,0,0.50);
  --shadow-lg: 0 12px 32px rgba(0,0,0,0.60);
  --purple-light: #2d1b45; --teal-light: #0d2b27;
}

html { scroll-behavior: smooth; scrollbar-gutter: stable; }

body {
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg); color: var(--text-main); line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  padding-left: var(--safe-left); padding-right: var(--safe-right);
  transition: background var(--transition), color var(--transition);
}

.page {
  min-height: 100vh; display: flex; flex-direction: column;
  padding-bottom: calc(80px + var(--safe-bottom));
}

/* Ticker */
.ticker-bar {
  background: var(--ticker-bg); color: #fff; display: flex;
  align-items: center; gap: 8px; overflow: hidden;
  padding: 7px 12px 7px calc(12px + var(--safe-left));
  font-size: clamp(0.7rem, 2vw, 0.82rem); white-space: nowrap; z-index: 30;
}
.ticker-bar:hover .ticker-inner { animation-play-state: paused; }
.ticker-label {
  font-weight: 700; flex-shrink: 0;
  background: rgba(255,255,255,0.18); border-radius: 4px; padding: 1px 6px; font-size: 0.7rem;
}
.ticker-track { overflow: hidden; flex: 1; }
.ticker-inner { display: inline-block; padding-left: 100%; animation: ticker-scroll 40s linear infinite; }
.ticker-item { padding: 0 2rem; border-right: 1px solid rgba(255,255,255,0.35); }
.ticker-item.countdown { color: #ffe082; font-weight: 600; }
@keyframes ticker-scroll { 0% { transform: translateX(0); } 100% { transform: translateX(-50%); } }

/* Top nav */
.top-nav {
  position: sticky; top: 0; z-index: 20;
  background: linear-gradient(90deg, rgba(106,27,154,0.96), rgba(0,137,123,0.96));
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  padding: 8px 16px 8px calc(16px + var(--safe-left));
  box-shadow: 0 3px 14px rgba(0,0,0,0.22);
}
.nav-inner {
  max-width: 1100px; margin: 0 auto; display: flex;
  flex-wrap: wrap; gap: 8px; align-items: center; justify-content: space-between;
}
.nav-left { display: flex; flex-direction: column; gap: 2px; flex-shrink: 0; }
.nav-title { font-size: clamp(0.8rem, 2.5vw, 0.98rem); font-weight: 700; color: #fff; white-space: nowrap; }
.powered-badge {
  display: inline-block; font-size: 0.65rem; color: rgba(255,255,255,0.75);
  background: rgba(255,255,255,0.10); border: 1px solid rgba(255,255,255,0.22);
  border-radius: 20px; padding: 1px 8px; text-decoration: none; white-space: nowrap;
  transition: background var(--transition);
}
.powered-badge strong { color: #ffe082; font-weight: 700; }
.powered-badge:hover { background: rgba(255,255,255,0.20); }

.nav-buttons { display: flex; flex-wrap: wrap; gap: 4px; flex: 1; justify-content: center; min-width: 0; }
.nav-buttons button {
  border-radius: 999px; padding: 4px 10px; font-size: clamp(0.65rem, 1.8vw, 0.75rem);
  border: 1px solid rgba(255,255,255,0.25); background: rgba(255,255,255,0.12);
  color: #fff; display: inline-flex; align-items: center; gap: 4px;
  transition: background var(--transition), transform var(--transition); white-space: nowrap;
}
.nav-buttons button:hover { background: rgba(255,255,255,0.28); transform: translateY(-1px); }
.nav-buttons button .sec-pct {
  font-size: 0.6rem; background: rgba(255,255,255,0.22); border-radius: 999px; padding: 0 5px;
}

.nav-actions { display: flex; align-items: center; gap: 6px; flex-shrink: 0; }
.pin-wrap { display: flex; align-items: center; gap: 3px; }
.pin-input {
  background: rgba(255,255,255,0.15); border: 1px solid rgba(255,255,255,0.30);
  color: #fff; border-radius: 999px; padding: 4px 10px; font-size: 0.72rem;
  outline: none; width: 130px; transition: background var(--transition), border-color var(--transition);
}
.pin-input::placeholder { color: rgba(255,255,255,0.55); }
.pin-input:focus { background: rgba(255,255,255,0.25); border-color: #fff; }
.pin-input.full {
  width: 100%; background: var(--input-bg); color: var(--text-main);
  border-color: var(--border-soft); padding: 10px 14px; font-size: 0.9rem; border-radius: 8px;
}
.pin-input.full:focus { border-color: var(--border-focus); }
.pin-btn {
  background: rgba(255,255,255,0.18); border: 1px solid rgba(255,255,255,0.30);
  color: #fff; border-radius: 999px; padding: 4px 8px; font-size: 0.8rem; cursor: pointer;
}
.pin-btn:hover { background: rgba(255,255,255,0.30); }
.icon-btn {
  background: rgba(255,255,255,0.12); border: 1px solid rgba(255,255,255,0.25);
  color: #fff; border-radius: 999px; padding: 5px 9px; font-size: 1rem; cursor: pointer; line-height: 1;
}
.icon-btn:hover { background: rgba(255,255,255,0.28); }

/* Main card */
.container {
  max-width: 960px; width: calc(100% - 24px); margin: 16px auto 24px;
  background: var(--card-bg); border-radius: 16px; box-shadow: var(--shadow-md);
  padding: clamp(16px, 4vw, 32px); border: 1px solid var(--border-soft);
  animation: fadeUp 0.35s ease-out;
  transition: background var(--transition), border-color var(--transition);
}
@keyframes fadeUp { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }

h1 {
  font-size: clamp(1.3rem, 4vw, 1.8rem); text-align: center;
  background: linear-gradient(135deg, var(--purple), var(--teal));
  -webkit-background-clip: text; background-clip: text; color: transparent;
  margin-bottom: 8px; line-height: 1.2;
}
.subtitle { text-align: center; font-size: clamp(0.8rem, 2vw, 0.92rem); color: var(--text-muted); margin-bottom: 16px; }

/* Search */
.search-wrap { position: relative; margin-bottom: 14px; }
.search-input {
  width: 100%; padding: 9px 36px 9px 14px; border: 1px solid var(--border-soft);
  border-radius: 999px; font-size: 0.88rem; background: var(--input-bg); color: var(--text-main); outline: none;
  transition: border-color var(--transition), box-shadow var(--transition);
}
.search-input:focus { border-color: var(--border-focus); box-shadow: 0 0 0 3px rgba(106,27,154,0.12); }
.search-clear {
  position: absolute; right: 10px; top: 50%; transform: translateY(-50%);
  background: transparent; border: none; color: var(--text-muted);
  font-size: 0.85rem; cursor: pointer; padding: 4px; box-shadow: none; display: none;
}
.search-clear.visible { display: flex; }
.task.search-match { background: rgba(255,235,59,0.18); }
.task.search-hidden { display: none; }

/* Controls */
.controls { display: flex; flex-wrap: wrap; gap: 12px; align-items: flex-start; margin-bottom: 18px; justify-content: space-between; }
.progress-area { flex: 1; min-width: 200px; }
.progress-text { font-size: 0.88rem; color: var(--text-main); margin-bottom: 5px; }
.progress-bar-wrapper {
  width: 100%; background: var(--purple-light); border-radius: 999px;
  overflow: hidden; height: 12px; border: 1px solid var(--border-soft);
}
.progress-bar-fill {
  height: 100%; width: 0%;
  background: linear-gradient(90deg, var(--purple), var(--teal));
  border-radius: 999px; transition: width 0.3s ease;
}
.buttons { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }

/* Buttons */
button {
  border: none; border-radius: 999px; padding: 7px 14px;
  font-size: clamp(0.72rem, 1.8vw, 0.82rem); cursor: pointer;
  background: linear-gradient(135deg, var(--purple), var(--teal));
  color: #fff; box-shadow: var(--shadow-sm); display: inline-flex; align-items: center; gap: 5px;
  transition: transform var(--transition), box-shadow var(--transition);
  -webkit-tap-highlight-color: transparent; touch-action: manipulation; white-space: nowrap;
}
button:hover { transform: translateY(-1px); box-shadow: var(--shadow-md); }
button:active { transform: translateY(1px); box-shadow: none; }
button.secondary {
  background: var(--card-bg); color: var(--purple);
  box-shadow: none; border: 1px solid var(--border-soft);
}
[data-theme="dark"] button.secondary { color: var(--purple-mid); }
button.danger { background: var(--danger); box-shadow: 0 2px 8px rgba(229,57,53,0.35); }

/* Sections */
.list { margin-top: 8px; }
.section-block { scroll-margin-top: 100px; margin-bottom: 8px; border: 1px solid var(--border-soft); border-radius: 12px; overflow: hidden; }
.section-header {
  display: flex; align-items: center; gap: 10px; padding: 10px 14px;
  background: linear-gradient(to right, var(--purple-light), var(--teal-light));
  cursor: pointer; user-select: none; -webkit-user-select: none;
}
[data-theme="dark"] .section-header { background: linear-gradient(to right, rgba(106,27,154,0.22), rgba(0,137,123,0.18)); }
.group-title { font-weight: 700; font-size: clamp(0.85rem, 2.5vw, 1rem); color: var(--purple); flex: 1; }
[data-theme="dark"] .group-title { color: var(--purple-mid); }
.sec-progress-wrap { width: 80px; height: 6px; background: rgba(0,0,0,0.08); border-radius: 999px; overflow: hidden; flex-shrink: 0; }
[data-theme="dark"] .sec-progress-wrap { background: rgba(255,255,255,0.10); }
.sec-progress-fill { height: 100%; background: linear-gradient(90deg, var(--purple), var(--teal)); border-radius: 999px; width: 0%; transition: width 0.3s ease; }
.sec-pct-label { font-size: 0.7rem; color: var(--text-muted); flex-shrink: 0; min-width: 32px; text-align: right; }
.collapse-arrow { font-size: 0.75rem; color: var(--text-muted); transition: transform var(--transition); flex-shrink: 0; }
.section-block.collapsed .collapse-arrow { transform: rotate(-90deg); }
.section-body { padding: 6px 14px 10px; display: block; }
.section-block.collapsed .section-body { display: none; }
.group-caption { font-size: 0.78rem; color: var(--text-muted); margin: 4px 0 8px 2px; }

/* Tasks */
.task {
  display: flex; align-items: flex-start; gap: 8px;
  padding: 7px 4px; border-bottom: 1px solid var(--border-soft); border-radius: 4px;
  transition: background var(--transition), transform var(--transition); position: relative;
}
.task:last-child { border-bottom: none; }
.task:hover { background: rgba(0,137,123,0.06); transform: translateX(2px); }
[data-theme="dark"] .task:hover { background: rgba(0,137,123,0.10); }
.task input[type="checkbox"] { margin-top: 3px; min-width: 18px; min-height: 18px; cursor: pointer; accent-color: var(--teal); flex-shrink: 0; }
.task label { cursor: pointer; flex: 1; font-size: clamp(0.82rem, 2vw, 0.92rem); line-height: 1.4; color: var(--text-main); }
.task.completed { background: var(--teal-light); }
[data-theme="dark"] .task.completed { background: rgba(0,137,123,0.14); }
.task.completed label { text-decoration: line-through; color: var(--text-muted); }
.task.indeterminate label { font-style: italic; }
.task.not-applicable { opacity: 0.42; }
.task.not-applicable label { text-decoration: line-through; color: var(--text-muted); }

/* Badges */
.badge-urgent {
  display: inline-flex; align-items: center; font-size: 0.62rem; font-weight: 700;
  background: var(--danger); color: #fff; border-radius: 4px; padding: 1px 5px;
  margin-left: 4px; flex-shrink: 0;
}
.due-chip { font-size: 0.64rem; border-radius: 999px; padding: 1px 7px; border: 1px solid; flex-shrink: 0; margin-left: 2px; white-space: nowrap; }
.due-chip.ok { color: var(--success); border-color: var(--success); }
.due-chip.warn { color: var(--warn); border-color: var(--warn); }
.due-chip.overdue { color: var(--danger); border-color: var(--danger); background: rgba(229,57,53,0.08); font-weight: 700; }

/* Task buttons — visible pill style */
.subtoggle, .info-toggle, .na-toggle {
  cursor: pointer;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 0.70rem;
  font-weight: 600;
  flex-shrink: 0;
  white-space: nowrap;
  transition: background var(--transition), color var(--transition),
              border-color var(--transition), transform var(--transition);
  line-height: 1.4;
}

/* ▾ sub-steps button — purple outline pill */
.subtoggle {
  background: var(--purple-light);
  color: var(--purple);
  border: 1.5px solid var(--purple-mid);
  box-shadow: none;
}
.subtoggle:hover {
  background: var(--purple);
  color: #fff;
  transform: none;
  box-shadow: none;
}

/* info button — teal outline pill */
.info-toggle {
  background: var(--teal-light);
  color: var(--teal);
  border: 1.5px solid var(--teal-mid);
  box-shadow: none;
}
.info-toggle:hover {
  background: var(--teal);
  color: #fff;
  transform: none;
  box-shadow: none;
}

/* N/A button — amber outline pill */
.na-toggle {
  background: #fff8e1;
  color: var(--warn);
  border: 1.5px solid #ffcc02;
  box-shadow: none;
}
.na-toggle:hover {
  background: var(--warn);
  color: #fff;
  transform: none;
  box-shadow: none;
}

/* N/A active state — filled amber */
.na-toggle.active {
  background: var(--warn);
  color: #fff;
  border-color: var(--warn);
  font-weight: 700;
}

/* Dark mode adjustments */
[data-theme="dark"] .subtoggle {
  background: rgba(106,27,154,0.25);
  border-color: var(--purple-mid);
  color: var(--purple-mid);
}
[data-theme="dark"] .info-toggle {
  background: rgba(0,137,123,0.20);
  border-color: var(--teal-mid);
  color: var(--teal-mid);
}
[data-theme="dark"] .na-toggle {
  background: rgba(245,124,0,0.15);
  border-color: #ffcc02;
  color: #ffcc02;
}

/* Subtasks */
.subtasks { list-style: none; margin: 4px 0 4px 28px; padding-left: 12px; border-left: 2px solid var(--teal-light); display: none; }
.subtasks.visible { display: block; }
.subtasks li {
  display: flex; align-items: flex-start; gap: 6px; padding: 3px 0;
  font-size: clamp(0.78rem, 2vw, 0.86rem); color: var(--text-main);
  border-bottom: 1px dotted var(--border-soft);
}
.subtasks li:last-child { border-bottom: none; }
.subtasks input[type="checkbox"] { margin-top: 2px; min-width: 16px; min-height: 16px; accent-color: var(--teal); flex-shrink: 0; }

/* Info box */
.info-box {
  margin: 2px 0 8px 28px; padding: 8px 12px; border-radius: 8px;
  background: var(--purple-light); border-left: 3px solid var(--purple);
  font-size: 0.8rem; color: var(--text-muted); display: none; line-height: 1.5;
}
[data-theme="dark"] .info-box { background: rgba(106,27,154,0.18); }
.info-box.visible { display: block; }

/* Footer */
.footer-note { margin-top: 18px; font-size: 0.75rem; color: var(--text-muted); text-align: center; padding: 8px; border-top: 1px solid var(--border-soft); }

/* Floating Telegram FAB */
.fab-telegram {
  position: fixed; bottom: calc(24px + var(--safe-bottom)); right: calc(20px + var(--safe-right));
  z-index: 50; display: flex; align-items: center; gap: 7px;
  background: #2CA5E0; color: #fff; text-decoration: none;
  border-radius: 999px; padding: 11px 16px 11px 12px;
  box-shadow: 0 4px 18px rgba(44,165,224,0.45); font-size: 0.82rem; font-weight: 600;
  transition: transform var(--transition), box-shadow var(--transition);
  -webkit-tap-highlight-color: transparent;
}
.fab-telegram:hover { transform: translateY(-2px) scale(1.04); box-shadow: 0 8px 24px rgba(44,165,224,0.55); }
.fab-telegram:active { transform: scale(0.97); }
.fab-telegram svg { width: 20px; height: 20px; flex-shrink: 0; }
.fab-label { white-space: nowrap; }

/* Confetti canvas */
#confetti-canvas { position: fixed; inset: 0; width: 100%; height: 100%; pointer-events: none; z-index: 9999; display: none; }
#confetti-canvas.active { display: block; }

/* PIN modal */
.modal-overlay { position: fixed; inset: 0; background: rgba(0,0,0,0.55); z-index: 100; display: flex; align-items: center; justify-content: center; padding: 16px; backdrop-filter: blur(4px); }
.modal-overlay.hidden { display: none; }
.modal-card { background: var(--card-bg); border-radius: 16px; padding: clamp(20px, 5vw, 36px); max-width: 420px; width: 100%; box-shadow: var(--shadow-lg); border: 1px solid var(--border-soft); animation: fadeUp 0.25s ease-out; }
.modal-card h2 { font-size: 1.2rem; color: var(--purple); margin-bottom: 10px; }
[data-theme="dark"] .modal-card h2 { color: var(--purple-mid); }
.modal-card p { font-size: 0.88rem; color: var(--text-muted); margin-bottom: 16px; line-height: 1.55; }
.modal-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 14px; }
.modal-btn { flex: 1; min-width: 120px; justify-content: center; border-radius: 10px; padding: 10px 14px; font-size: 0.88rem; }
.modal-btn.primary { background: linear-gradient(135deg, var(--purple), var(--teal)); color: #fff; }
.modal-btn.secondary { background: var(--card-bg); color: var(--text-muted); border: 1px solid var(--border-soft); }

/* Responsive */
@media (max-width: 768px) {
  .nav-inner { gap: 6px; } .pin-input { width: 100px; }
  .container { width: calc(100% - 16px); margin: 12px auto; }
  .controls { flex-direction: column; align-items: stretch; }
  .buttons { justify-content: flex-start; }
}
@media (max-width: 600px) {
  .nav-inner { flex-direction: column; align-items: flex-start; }
  .nav-actions { width: 100%; justify-content: space-between; }
  .pin-input { width: 160px; } .nav-buttons { width: 100%; }
  h1 { font-size: 1.3rem; }
  .fab-label { display: none; }
  .fab-telegram { padding: 12px; border-radius: 50%; }
}
@media (max-width: 400px) {
  .ticker-label { display: none; }
  .buttons button { font-size: 0.68rem; padding: 6px 10px; }
  .pin-input { width: 120px; font-size: 0.68rem; }
  .modal-card { padding: 18px 14px; }
}
@media print {
  .top-nav, .ticker-bar, .controls .buttons, .fab-telegram,
  #confetti-canvas, .modal-overlay, .search-wrap,
  .subtoggle, .info-toggle, .na-toggle, .info-box, .subtasks { display: none !important; }
  body { background: #fff !important; color: #000 !important; }
  .container { box-shadow: none !important; border: none !important; padding: 0 !important; margin: 0 !important; width: 100% !important; max-width: 100% !important; }
  .section-block { border: 1px solid #ccc !important; page-break-inside: avoid; }
  .section-block.collapsed .section-body { display: block !important; }
  .task.completed label { text-decoration: line-through; color: #666; }
  .task.not-applicable { display: none !important; }
}
