/* === Shared Settings — Dialog, Toast, Icon Buttons ======================== */

/* --- Utility -------------------------------------------------------------- */

.hidden { display: none !important; }

/* --- Icon button (gear, close, back) -------------------------------------- */

.icon-btn {
  background: none;
  border: none;
  color: inherit;
  cursor: pointer;
  padding: 4px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  transition: background 0.15s;
}

.icon-btn:hover {
  background: rgba(0,0,0,0.06);
}

/* --- Badge dot (settings attention indicator) ----------------------------- */

.badge-dot {
  position: absolute;
  top: 2px;
  right: 2px;
  width: 8px;
  height: 8px;
  background: #ff5252;
  border-radius: 50%;
}

/* --- Header email chip ---------------------------------------------------- */

.header-email-chip {
  display: inline-block;
  max-width: 200px;
  padding: 4px 12px;
  border-radius: 9999px;
  background: var(--brand-primary-light);
  color: var(--brand-primary);
  font-size: 0.8rem;
  font-weight: 500;
  cursor: pointer;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  transition: background 0.15s;
}

.header-email-chip:hover {
  background: #e1bee7;
}

/* --- Dialog overlay & shell ----------------------------------------------- */

.dialog-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 300;
  padding: 16px;
}

.dialog {
  background: white;
  border-radius: 16px;
  width: 100%;
  max-width: 480px;
  max-height: 85vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 8px 32px rgba(0,0,0,0.2);
}

.dialog-header {
  display: flex;
  align-items: center;
  padding: 16px 20px;
  border-bottom: 1px solid #eee;
  flex-shrink: 0;
}

.dialog-header h2 {
  flex: 1;
  font-size: 1.1rem;
  font-weight: 600;
}

.dialog-body {
  overflow-y: auto;
  padding: 16px 20px;
  flex: 1;
}

/* --- Settings dialog ------------------------------------------------------ */

.dialog-settings {
  max-width: 420px;
}

.setting-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 0;
  border-bottom: 1px solid #f0f0f0;
  gap: 12px;
}

.setting-item label {
  font-weight: 500;
  font-size: 0.9rem;
  white-space: nowrap;
}

.setting-item input[type="email"] {
  flex: 1;
  padding: 8px 12px;
  border: 1px solid #ddd;
  border-radius: 6px;
  font-size: 0.9rem;
  font-family: var(--font-family);
  outline: none;
  min-width: 0;
}

.setting-item input[type="email"]:focus {
  border-color: var(--brand-primary);
}

.setting-item select {
  padding: 8px 12px;
  border: 1px solid #ddd;
  border-radius: 6px;
  font-size: 0.9rem;
  outline: none;
  background: white;
}

.setting-item.clickable {
  cursor: pointer;
  transition: background 0.15s;
  margin: 0 -20px;
  padding: 14px 20px;
}

.setting-item.clickable:hover {
  background: #f8f8f8;
}

.setting-item.clickable span {
  font-weight: 500;
  font-size: 0.9rem;
  flex: 1;
}

/* --- Segmented control (duration buttons) --------------------------------- */

.seg-control {
  display: inline-flex;
  border: 1px solid #ddd;
  border-radius: 8px;
  overflow: hidden;
}

.seg-btn {
  padding: 6px 14px;
  border: none;
  background: white;
  font-size: 0.85rem;
  font-weight: 500;
  cursor: pointer;
  color: #666;
  transition: all 0.15s;
  border-right: 1px solid #eee;
}

.seg-btn:last-child { border-right: none; }

.seg-btn.active {
  background: var(--brand-primary);
  color: white;
}

.seg-btn:hover:not(.active) {
  background: #f0f0f0;
}

/* --- Seg-input (editable segment button for custom Quick Mix) ------------ */

input.seg-input {
  width: 42px;
  text-align: center;
  font-family: var(--font-family);
  -moz-appearance: textfield;
  outline: none;
}

input.seg-input::-webkit-outer-spin-button,
input.seg-input::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

input.seg-input::placeholder {
  color: #666;
}

input.seg-input.active {
  background: var(--brand-primary);
  color: white;
}

input.seg-input.active::placeholder {
  color: rgba(255,255,255,0.7);
}

/* --- Pack groups (grouped by type, card grid) ----------------------------- */

.packs-group {
  margin-bottom: 16px;
}

.packs-group-title {
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: #999;
  margin: 0 0 8px;
}

.packs-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

.pack-card {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 10px 12px;
  border: 1px solid #eee;
  border-radius: 10px;
  background: white;
  cursor: pointer;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.pack-card:hover {
  border-color: var(--brand-primary-light);
  box-shadow: 0 2px 8px rgba(0,0,0,0.06);
}

.pack-card input[type="checkbox"] {
  accent-color: var(--brand-primary);
  width: 16px;
  height: 16px;
  flex-shrink: 0;
  margin-top: 2px;
}

.pack-card .pack-info {
  flex: 1;
  min-width: 0;
}

.pack-card .pack-name {
  display: block;
  font-weight: 600;
  font-size: 0.85rem;
  text-transform: capitalize;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.pack-card .pack-count {
  display: block;
  font-size: 0.75rem;
  color: #999;
}

.pack-apply {
  padding: 16px 0 4px;
  text-align: center;
}

/* --- Toast ---------------------------------------------------------------- */

.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  padding: 12px 24px;
  border-radius: 8px;
  font-size: 0.9rem;
  font-weight: 500;
  z-index: 400;
  box-shadow: 0 4px 12px rgba(0,0,0,0.2);
  transition: opacity 0.3s;
  color: white;
}

.toast-success { background: #2e7d32; }
.toast-error   { background: #c62828; }
.toast-info    { background: #1565c0; }

/* --- Responsive (dialog) -------------------------------------------------- */

@media (max-width: 480px) {
  .dialog { max-height: 90vh; }
}

/* === Profile Page (full-screen with sidebar) ============================== */

.profile-overlay {
  position: fixed;
  inset: 0;
  background: white;
  z-index: 300;
  display: flex;
}

.profile-overlay.busy { cursor: wait; }
.profile-overlay.busy * { cursor: wait !important; }

.profile-sidebar {
  width: 220px;
  background: #f8f8fa;
  border-right: 1px solid #eee;
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
}

.profile-sidebar-header {
  display: flex;
  align-items: center;
  padding: 20px 16px;
  gap: 8px;
}

.profile-sidebar-header h2 {
  flex: 1;
  font-size: 1.1rem;
  font-weight: 700;
  margin: 0;
}

.profile-nav {
  display: flex;
  flex-direction: column;
  padding: 0 8px;
  gap: 2px;
}

.profile-nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border: none;
  background: transparent;
  border-radius: 8px;
  font-size: 0.9rem;
  font-weight: 500;
  color: #555;
  cursor: pointer;
  transition: background 0.15s;
  text-align: left;
  font-family: var(--font-family);
}

.profile-nav-item:hover { background: rgba(0,0,0,0.04); }

.profile-nav-item.active {
  background: var(--brand-primary-light, #f3e5f5);
  color: var(--brand-primary, #9245E3);
}

.profile-content {
  flex: 1;
  overflow-y: auto;
  padding: 24px 32px;
}

.profile-content-inner {
  max-width: 600px;
}

.profile-content h3 {
  font-size: 1rem;
  font-weight: 700;
  color: var(--text-heading, #222);
  margin: 0 0 12px;
}

.profile-section-divider {
  border: none;
  border-top: 1px solid #eee;
  margin: 20px 0;
}

/* --- Progress info panel (mastery explainer) ------------------------------ */

.progress-header-row {
  display: flex;
  justify-content: flex-end;
  margin-bottom: 8px;
}

.progress-info-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 8px;
  font-size: 0.78rem;
  color: #999;
  border-radius: 6px;
}

.progress-info-btn:hover {
  color: var(--brand-primary);
  background: rgba(0,0,0,0.03);
}

.progress-info-panel {
  background: #f8f8fa;
  border: 1px solid #eee;
  border-radius: 10px;
  padding: 14px 18px;
  margin-bottom: 16px;
  font-size: 0.82rem;
  color: #555;
  line-height: 1.5;
}

.progress-info-panel p {
  margin: 0 0 8px;
  font-weight: 600;
  color: #444;
}

.progress-info-panel ul {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.progress-info-panel li {
  display: flex;
  align-items: center;
  gap: 8px;
}

.progress-info-panel li strong {
  min-width: 80px;
}

/* --- Progress tab --------------------------------------------------------- */

.progress-overview {
  background: #f8f8fa;
  border-radius: 12px;
  padding: 20px;
  margin-bottom: 20px;
}

.progress-score-row {
  display: flex;
  align-items: baseline;
  gap: 10px;
}

.progress-score-value {
  font-size: 2rem;
  font-weight: 800;
  color: var(--brand-primary);
}

.progress-score-label {
  font-size: 0.82rem;
  color: #999;
}

.progress-status-section {
  margin-bottom: 8px;
  border: 1px solid #eee;
  border-radius: 10px;
  overflow: hidden;
}

.progress-status-heading {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.82rem;
  font-weight: 700;
  cursor: pointer;
  padding: 10px 14px;
  margin: 0;
  background: #fafafa;
  transition: background 0.15s;
  user-select: none;
  color: #555;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

.progress-status-heading:hover { background: #f0f0f2; }

.progress-status-heading::after {
  content: '';
  margin-left: auto;
  border: solid #999;
  border-width: 0 2px 2px 0;
  padding: 3px;
  transform: rotate(45deg);
  transition: transform 0.2s;
}

.progress-status-section.open .progress-status-heading::after {
  transform: rotate(-135deg);
}

.progress-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

.progress-dot.progress-green  { background: #4caf50; }
.progress-dot.progress-orange { background: #ff9800; }
.progress-dot.progress-red    { background: #f44336; }
.progress-dot.progress-blue   { background: #42a5f5; }
.progress-dot.progress-gray   { background: #ccc; }

.progress-pack-list {
  display: none;
  flex-direction: column;
  gap: 10px;
  padding: 10px 12px;
}

.progress-status-section.open .progress-pack-list {
  display: flex;
}

/* --- Pack progress cards (clickable, colored left border) ---------------- */

.progress-pack-card {
  padding: 12px 14px;
  background: white;
  border-radius: 8px;
  border: 1px solid #eee;
  border-left: 4px solid #ccc;
  cursor: pointer;
  transition: box-shadow 0.15s;
}

.progress-pack-card:hover {
  box-shadow: 0 2px 8px rgba(0,0,0,0.08);
}

.progress-pack-card .pack-label {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.progress-pack-card .pack-label strong {
  font-size: 0.85rem;
  font-weight: 600;
}

.progress-pack-card .pack-label span {
  font-size: 0.75rem;
  color: #999;
}

.progress-pack-summary {
  font-size: 0.78rem;
  color: #888;
}

.prg-border-green  { border-left-color: #4caf50; }
.prg-border-orange { border-left-color: #ff9800; }
.prg-border-red    { border-left-color: #f44336; }
.prg-border-blue   { border-left-color: #42a5f5; }
.prg-border-gray   { border-left-color: #ccc; }

/* --- Pack drill-down view ------------------------------------------------ */

.progress-back-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: none;
  border: none;
  color: var(--brand-primary);
  font-size: 0.85rem;
  font-weight: 600;
  font-family: var(--font-family);
  cursor: pointer;
  padding: 4px 0;
  margin-bottom: 8px;
}

.progress-back-btn:hover { text-decoration: underline; }

.progress-sign-group {
  margin-bottom: 16px;
}

.progress-sign-group h4 {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.82rem;
  font-weight: 600;
  color: #555;
  margin: 0 0 8px;
}

.progress-sign-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.progress-sign-chip {
  padding: 4px 12px;
  border-radius: 9999px;
  font-size: 0.8rem;
  font-weight: 500;
  text-transform: capitalize;
  border: 1px solid;
  cursor: pointer;
  transition: filter 0.15s;
}
.progress-sign-chip:hover { filter: brightness(0.92); }

.progress-sign-chip.progress-green  { color: #2e7d32; background: #e8f5e9; border-color: #c8e6c9; }
.progress-sign-chip.progress-orange { color: #e65100; background: #fff3e0; border-color: #ffe0b2; }
.progress-sign-chip.progress-red    { color: #c62828; background: #ffebee; border-color: #ffcdd2; }
.progress-sign-chip.progress-blue   { color: #1565c0; background: #e3f2fd; border-color: #bbdefb; }
.progress-sign-chip.progress-gray   { color: #555; background: #f5f5f5; border-color: #ddd; }

.progress-not-started-note {
  font-size: 0.82rem;
  color: #999;
  font-style: italic;
  margin: 0;
}

.progress-pack-stats {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 12px;
  font-size: 0.78rem;
  color: #888;
}

.progress-pack-stats .progress-green  { color: #2e7d32; }
.progress-pack-stats .progress-orange { color: #e65100; }
.progress-pack-stats .progress-red    { color: #c62828; }
.progress-pack-stats .progress-blue   { color: #1565c0; }
.progress-pack-stats .progress-gray   { color: #757575; }

.progress-empty {
  color: #999;
  font-size: 0.9rem;
  text-align: center;
  padding: 32px 0;
}

/* --- Progress histogram bar (stacked segments) --------------------------- */

.progress-bar {
  display: flex;
  height: 8px;
  border-radius: 4px;
  background: #eee;
  overflow: hidden;
}

.progress-bar.progress-bar-small {
  height: 6px;
  border-radius: 3px;
}

.progress-bar-seg {
  height: 100%;
  transition: width 0.3s ease;
}

.progress-bar-seg.seg-green  { background: #4caf50; }
.progress-bar-seg.seg-orange { background: #ff9800; }
.progress-bar-seg.seg-red    { background: #f44336; }
.progress-bar-seg.seg-blue   { background: #42a5f5; }
.progress-bar-seg.seg-gray   { background: #ccc; }

.progress-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 12px;
  font-size: 0.75rem;
  color: #888;
  margin-top: 6px;
}

.progress-legend-item {
  display: flex;
  align-items: center;
  gap: 4px;
}

.progress-legend-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

/* --- Profile responsive --------------------------------------------------- */

@media (max-width: 768px) {
  .profile-overlay {
    flex-direction: column;
  }
  .profile-sidebar {
    width: 100%;
    border-right: none;
    border-bottom: 1px solid #eee;
  }
  .profile-sidebar-header {
    padding: 12px 16px;
  }
  .profile-nav {
    flex-direction: row;
    padding: 0 8px 8px;
  }
  .profile-nav-item {
    flex: 1;
    justify-content: center;
    padding: 8px;
    font-size: 0.82rem;
  }
  .profile-nav-item svg { display: none; }
  .profile-content {
    padding: 16px;
  }
  .packs-grid {
    grid-template-columns: 1fr;
  }
}

/* --- Streak stats (F30) -------------------------------------------------- */

.streak-stats {
  display:flex; gap:24px; padding:18px 16px; justify-content:center;
  background:#f8f8fa; border-radius:12px; margin-bottom:12px;
}
.streak-stat {
  display:flex; align-items:baseline; gap:6px;
  padding:8px 14px; border-radius:10px;
  transition: background 0.15s;
}
.streak-stat[onclick] { cursor:pointer; }
.streak-stat[onclick]:hover { background:rgba(0,0,0,0.06); }
.streak-stat.active { background:var(--brand-primary-light, #e8f5e9); }
.streak-value { font-size:1.5rem; font-weight:700; color:var(--brand-primary); }
.streak-label { font-size:0.85rem; color:#666; }

/* --- Drill-down panel ---------------------------------------------------- */

.streak-drilldown {
  padding:0 4px 12px;
  animation: drilldown-in 0.2s ease;
}
@keyframes drilldown-in {
  from { opacity:0; transform:translateY(-8px); }
  to   { opacity:1; transform:translateY(0); }
}

/* --- Heatmap (activity calendar) ----------------------------------------- */

.heatmap-wrap { overflow-x:auto; padding:4px 0 8px; }
.heatmap-months { display:flex; gap:0; padding-left:28px; margin-bottom:2px; }
.heatmap-month { font-size:11px; color:#888; }
.heatmap-grid {
  display:grid;
  grid-template-rows:repeat(7, 13px);
  grid-auto-columns:13px;
  grid-auto-flow:column;
  gap:2px;
}
.heatmap-day-label {
  font-size:10px; color:#888; width:24px;
  display:flex; align-items:center; justify-content:flex-end;
  padding-right:4px;
}
.heatmap-cell {
  width:11px; height:11px; border-radius:2px;
  background:#ebedf0;
}
.heatmap-cell[data-level="1"] { background:#9be9a8; }
.heatmap-cell[data-level="2"] { background:#40c463; }
.heatmap-cell[data-level="3"] { background:#30a14e; }
.heatmap-cell[data-level="4"] { background:#216e39; }
.heatmap-cell:hover { outline:1px solid #333; outline-offset:0; }
.heatmap-legend { display:flex; align-items:center; gap:4px; justify-content:flex-end; padding-top:6px; font-size:11px; color:#888; }
.heatmap-legend .heatmap-cell { cursor:default; }
.heatmap-tooltip {
  font-size:12px; color:#555; text-align:center; padding:6px 0 2px;
  min-height:22px;
}

/* --- Signs mastery list -------------------------------------------------- */

.signs-list { max-height:280px; overflow-y:auto; }
.signs-list-header {
  display:grid; grid-template-columns:1fr 64px 64px 72px;
  gap:8px; padding:6px 8px; font-size:11px; font-weight:600;
  color:#888; text-transform:uppercase; letter-spacing:0.5px;
  border-bottom:1px solid #eee; position:sticky; top:0; background:#fff; z-index:1;
}
.sign-row {
  display:grid; grid-template-columns:1fr 64px 64px 72px;
  gap:8px; padding:6px 8px; font-size:13px;
  border-bottom:1px solid #f5f5f5;
  transition: background 0.1s;
}
.sign-row:hover { background:#fafafa; }
.sign-name { font-weight:500; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
.sign-count { text-align:center; color:#666; }
.sign-mastery {
  text-align:center; font-weight:600; font-size:12px;
  padding:2px 6px; border-radius:8px;
}
.sign-mastery.mastered { background:#e8f5e9; color:#2e7d32; }
.sign-mastery.learning { background:#fff3e0; color:#e65100; }
.sign-mastery.new      { background:#f5f5f5; color:#999; }
