/* ══════════════════════════════════════════════════════════════════════════
   HEADER POPOVERS (Settings / Tools) + SETTINGS DIALOG + TOOLS DIALOG + GUIDE
   ══════════════════════════════════════════════════════════════════════════ */

.hdr-popover-wrap {
  position: relative;
}

.hdr-popover {
  display: none;
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  min-width: 280px;
  max-width: 320px;
  max-height: 70vh;
  overflow-y: auto;
  background: rgba(8, 12, 24, 0.96);
  border: 1px solid var(--glass-border-focus);
  border-radius: 12px;
  padding: 0.75rem;
  z-index: 999;
  backdrop-filter: blur(14px);
  box-shadow: 0 12px 36px rgba(0, 0, 0, 0.55), 0 0 24px rgba(0, 242, 254, 0.12);
}

.hdr-popover.show { display: block; animation: hdrPopFade 0.15s ease-out; }

@keyframes hdrPopFade {
  from { opacity: 0; transform: translateY(-6px); }
  to   { opacity: 1; transform: translateY(0); }
}

.hdr-popover-section {
  margin-bottom: 0.75rem;
}

.hdr-popover-section:last-child { margin-bottom: 0; }

.hdr-popover-label {
  display: block;
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: var(--text-muted);
  margin-bottom: 0.3rem;
  font-weight: 600;
}

.hdr-popover .sleep-select {
  width: 100%;
  font-size: 0.82rem;
}

.hdr-popover-item {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  width: 100%;
  background: transparent;
  border: 1px solid transparent;
  color: var(--text-main);
  padding: 0.55rem 0.75rem;
  border-radius: 8px;
  font-size: 0.85rem;
  cursor: pointer;
  text-align: left;
  font-family: inherit;
  transition: var(--transition);
}

.hdr-popover-item:hover {
  background: rgba(0, 242, 254, 0.08);
  border-color: rgba(0, 242, 254, 0.3);
  color: var(--neon-cyan);
}

.hdr-popover-item i {
  width: 18px;
  text-align: center;
  flex: 0 0 auto;
}

.hdr-popover-sep {
  border: none;
  border-top: 1px solid var(--glass-border);
  margin: 0.4rem 0;
}

/* Header tools — luôn cuộn ngang nếu vẫn tràn (không xuống dòng vô tận).
   Override .hdr-tools defined in 02-layout.css. */
.hdr-tools {
  flex-wrap: nowrap;
  overflow-x: auto;
  overflow-y: visible;
  scrollbar-width: thin;
}

.hdr-tools::-webkit-scrollbar { height: 4px; }

/* ══════════════════════════════════════════
   SETTINGS DIALOG
   ══════════════════════════════════════════ */
.settings-grid {
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
}

.settings-row {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.settings-label {
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: var(--text-muted);
  font-weight: 600;
}

.settings-hint {
  text-transform: none;
  letter-spacing: 0;
  font-size: 0.7rem;
  color: var(--text-muted);
  font-weight: 400;
  font-style: italic;
  margin-left: 0.4rem;
}

.settings-row .sleep-select {
  width: 100%;
}

/* ══════════════════════════════════════════
   TOOLS DIALOG
   ══════════════════════════════════════════ */
.tools-section {
  margin-bottom: 1rem;
}

.tools-section:last-child { margin-bottom: 0; }

.tools-section-label {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--text-muted);
  font-weight: 700;
  margin-bottom: 0.5rem;
  padding-left: 0.25rem;
}

.tools-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
  gap: 0.5rem;
}

.tools-tile {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  color: var(--text-main);
  border-radius: 12px;
  padding: 0.85rem 0.5rem;
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
  transition: var(--transition);
  text-align: center;
  min-height: 70px;
}

.tools-tile i {
  font-size: 1.3rem;
  color: var(--neon-cyan);
}

.tools-tile:hover {
  border-color: var(--neon-cyan);
  background: rgba(0, 242, 254, 0.08);
  transform: translateY(-1px);
}

/* ══════════════════════════════════════════
   FEATURE GUIDE MODAL
   ══════════════════════════════════════════ */
.guide-list {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  max-height: 64vh;
  overflow-y: auto;
  padding-right: 0.4rem;
}

.guide-item {
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  border-radius: 10px;
  padding: 0;
  transition: var(--transition);
}

.guide-item[open] {
  border-color: var(--neon-cyan);
  background: rgba(0, 242, 254, 0.04);
}

.guide-item summary {
  cursor: pointer;
  padding: 0.7rem 0.95rem;
  font-weight: 600;
  font-size: 0.86rem;
  color: var(--text-main);
  list-style: none;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.guide-item summary::-webkit-details-marker { display: none; }

.guide-item summary::after {
  content: "›";
  margin-left: auto;
  color: var(--text-muted);
  font-size: 1.2rem;
  transition: transform 0.2s;
}

.guide-item[open] summary::after { transform: rotate(90deg); color: var(--neon-cyan); }

.guide-body {
  padding: 0 0.95rem 0.85rem 2rem;
  font-size: 0.82rem;
  color: var(--text-muted);
  line-height: 1.55;
}

.guide-body strong { color: var(--text-main); }

.guide-key {
  display: inline-block;
  font-family: 'Fira Code', monospace;
  font-size: 0.7rem;
  background: rgba(0, 242, 254, 0.1);
  border: 1px solid rgba(0, 242, 254, 0.3);
  color: var(--neon-cyan);
  padding: 1px 6px;
  border-radius: 4px;
  margin-left: 0.3rem;
  font-weight: 500;
}

/* Toggle "Tự mở bảng hướng dẫn mỗi khi vào app" */
.guide-autoshow-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-top: 1.25rem;
  padding: 0.85rem 1rem;
  background: rgba(0, 242, 254, 0.05);
  border: 1px solid rgba(0, 242, 254, 0.18);
  border-radius: 12px;
}

.guide-autoshow-label {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  font-size: 0.85rem;
  color: var(--text-main);
  font-weight: 500;
  margin: 0;
  cursor: pointer;
  user-select: none;
  flex: 1;
}

.guide-switch {
  position: relative;
  display: inline-block;
  width: 44px;
  height: 24px;
  flex: 0 0 auto;
}

.guide-switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.guide-switch-slider {
  position: absolute;
  inset: 0;
  cursor: pointer;
  background: rgba(255, 255, 255, 0.12);
  border: 1px solid var(--glass-border);
  border-radius: 999px;
  transition: background 0.2s, border-color 0.2s;
}

.guide-switch-slider::before {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 18px;
  height: 18px;
  background: #cbd5e1;
  border-radius: 50%;
  transition: transform 0.2s, background 0.2s;
}

.guide-switch input:checked + .guide-switch-slider {
  background: rgba(0, 242, 254, 0.25);
  border-color: rgba(0, 242, 254, 0.55);
}

.guide-switch input:checked + .guide-switch-slider::before {
  transform: translateX(20px);
  background: var(--neon-cyan);
  box-shadow: 0 0 10px rgba(0, 242, 254, 0.6);
}
