/* ============================================
   COMPONENTS.CSS — Reusable UI Components
   Dịch Quẻ · I Ching Oracle
============================================ */

/* ── BUTTONS ── */
.btn-primary {
  padding: 11px 24px;
  background: linear-gradient(135deg, #f9d163 0%, #e8c96a 50%, #feca3d 100%);
  color: #1a1000;
  border: none;
  border-radius: var(--radius);
  font-family: var(--font-sans);
  font-size: 12px;
  letter-spacing: 0.05em;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: box-shadow var(--transition), transform var(--transition), filter var(--transition);
  display: flex;
  align-items: center;
  gap: 6px;
  box-shadow: 0 4px 20px rgba(201, 168, 76, 0.35);
}
.btn-primary:hover {
  box-shadow: 0 6px 28px rgba(201, 168, 76, 0.55);
  transform: translateY(-1px);
}
.btn-primary:active {
  transform: translateY(0);
  filter: brightness(0.96);
}

[data-theme="dark"] .btn-primary {
  box-shadow: 0 4px 22px rgba(201, 168, 76, 0.45);
}
[data-theme="dark"] .btn-primary:hover {
  box-shadow: 0 6px 32px rgba(201, 168, 76, 0.65);
}

.btn-secondary {
  padding: 9px 18px;
  background: transparent;
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 12px;
  cursor: pointer;
  transition: all var(--transition);
}
.btn-secondary:hover { background: var(--bg2); }

.btn-ai-ask {
  background: linear-gradient(135deg, #e8b85a 0%, #c8982a 100%);
  color: #1a1000;
  border: none;
  border-radius: 7px;
  padding: 10px 18px;
  font-size: 12px;
  font-family: var(--font-sans);
  font-weight: 500;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  box-shadow: 0 2px 10px rgba(232,184,90,0.22);
  white-space: nowrap;
  transition: opacity var(--transition);
}
.btn-ai-ask:hover { opacity: 0.9; }

/* ── CARDS (home) ── */
.card {
  background: var(--surface);
  border: 1px solid var(--border-light);
  border-radius: var(--radius);
  padding: 18px 20px;
  box-shadow: var(--shadow);
  transition: box-shadow var(--transition), transform var(--transition);
}
/* 👇 DÁN Ở ĐÂY */
.card,
.hex-build-area,
.question-input,
.confirm-panel,
.detail-panel {
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}
.card:hover { box-shadow: var(--shadow-md); transform: translateY(-1px); }

.card-label {
  font-size: 10px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text3);
  margin-bottom: 6px;
}

.card-value {
  font-family: var(--font-serif);
  font-size: 40px;
  font-weight: 300;
  color: var(--text);
  line-height: 1;
}

.card-action {
  background: var(--surface);
  border: 1px solid var(--border-light);
  border-radius: var(--radius);
  padding: 20px 24px;
  box-shadow: var(--shadow);
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
}

.card-action-text h3 {
  font-family: var(--font-serif);
  font-size: 18px;
  font-weight: 400;
  margin-bottom: 4px;
  display: flex;
  align-items: center;
  gap: 10px;
}

.card-action-text p {
  font-size: 13px;
  color: var(--text2);
  line-height: 1.5;
  max-width: 380px;
}

/* ── SECTION TITLE ── */
.section-title {
  font-size: 10px;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: var(--text3);
  margin-bottom: 10px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.section-title a {
  color: var(--gold);
  text-decoration: none;
  font-size: 10px;
  cursor: pointer;
}
.section-title a:hover { text-decoration: underline; }

/* ── HISTORY ITEMS ── */
.history-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.history-item {
  background: var(--surface);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  transition: all var(--transition);
  overflow: hidden;
}
.history-item:hover { background: var(--bg2); border-color: var(--border); }

.history-main {
  display: flex;
  align-items: center;
  gap: 12px;
  flex: 1;
  padding: 12px 16px;
  cursor: pointer;
  min-width: 0;
}

.history-delete-btn {
  flex-shrink: 0;
  width: 40px;
  align-self: stretch;
  display: flex;
  align-items: center;
  justify-content: center;
  background: none;
  border: none;
  color: var(--text3);
  font-size: 16px;
  cursor: pointer;
  transition: background var(--transition), color var(--transition);
}
.history-delete-btn:hover {
  color: var(--red);
}

.history-clear-all-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-left: auto;
  padding: 4px 2px;
  background: none;
  border: none;
  font-size: 11px;
  color: var(--text3);
  font-family: var(--font-sans);
  cursor: pointer;
  transition: color var(--transition);
}
.history-clear-all-btn:hover {
  border-color: var(--red);
  color: var(--red);
}

/* ── CONFIRM MODAL ── */
.confirm-overlay {
  position: fixed; inset: 0;
  background: rgba(26,24,20,0.55);
  z-index: 300;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s;
}
.confirm-overlay.open {
  opacity: 1;
  pointer-events: all;
}

.confirm-panel {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 32px 28px 24px;
  max-width: 340px;
  width: 100%;
  box-shadow: var(--shadow-lg);
  text-align: center;
  transform: translateY(12px) scale(0.97);
  transition: transform 0.2s;
}
.confirm-overlay.open .confirm-panel {
  transform: translateY(0) scale(1);
}

.confirm-icon {
  width: 44px; height: 44px;
  border-radius: 50%;
  background: rgba(139,32,32,0.08);
  color: var(--red);
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 16px;
}

.confirm-title {
  font-family: var(--font-serif);
  font-size: 18px;
  color: var(--text);
  margin-bottom: 8px;
}

.confirm-desc {
  font-size: 12px;
  color: var(--text3);
  line-height: 1.6;
  margin-bottom: 24px;
}

.confirm-actions {
  display: flex;
  gap: 8px;
}

.confirm-cancel {
  flex: 1;
  padding: 9px 0;
  background: none;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-family: var(--font-sans);
  color: var(--text2);
  cursor: pointer;
  transition: background var(--transition);
}
.confirm-cancel:hover { background: var(--bg2); }

.confirm-ok {
  flex: 1;
  padding: 9px 0;
  background: var(--red);
  border: none;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-family: var(--font-sans);
  color: #fff;
  cursor: pointer;
  transition: opacity var(--transition);
}
.confirm-ok:hover { opacity: 0.85; }

.history-hex {
  font-size: 22px;
  font-family: 'Noto Serif SC', serif;
  width: 32px;
  text-align: center;
  color: var(--gold);
  flex-shrink: 0;
}

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

.history-name {
  font-size: 13px;
  font-weight: 500;
  margin-bottom: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.history-question {
  font-size: 11px;
  color: var(--text2);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.history-time {
  font-size: 11px;
  color: var(--text3);
  flex-shrink: 0;
}

/* ── COINS (gieo quẻ) ── */
.coins-container {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 24px;
  margin: 40px 0;
  min-height: 100px;
}

.coin {
  width: 81px; height: 81px;
  border-radius: 50%;
  border: 2px solid var(--border);
  background: var(--bg2);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 28px;
  font-family: 'Noto Serif SC', serif;
  transition: all 0.4s ease;
  box-shadow: var(--shadow-md);
}

.coin.yang {
  border-color: #4a8860;
  background: #2a4e38;
  color: #90c8a8;
  box-shadow: 0 4px 16px rgba(42, 100, 70, 0.35);
}
.coin.yin     { border-color: rgba(201,168,76,0.5); color: rgba(201,168,76,0.65); }
.coin.spinning { animation: spin3d 0.6s ease; }

[data-theme="dark"] .coin.yang {
  border-color: #3d6b50;
  background: #1e3828;
  color: #70a888;
  box-shadow: 0 4px 16px rgba(30, 70, 48, 0.5);
}
[data-theme="dark"] .coin.yin {
  border-color: rgba(201,168,76,0.5);
  color: rgba(201,168,76,0.65);
}

/* ── HAO LINES (unified system) ── */
.hao-line {
  position: relative;
  border-radius: 2px;
  background: var(--gold-hao);
  flex-shrink: 0;
  display: block;
}
.hao-line.yin::after {
  content: '';
  position: absolute;
  top: -1px; bottom: -1px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--bg);
  border-radius: 1px;
}
.hao-line.moving.yin::after { background: var(--bg); }
.hao-line.empty { background: var(--border); }
.hao-line.sm { width: 44px; height: 3px; }
.hao-line.sm.yin::after { width: 8px; }
.hao-line.md { width: 72px; height: 4px; border-radius: 3px; }
.hao-line.md.yin::after { width: 11px; border-radius: 2px; }
.hao-line.lg { width: 100px; height: 6px; border-radius: 3px; }
.hao-line.lg.yin::after { width: 16px; border-radius: 2px; }
.hao-line.moving {
  background: var(--red) !important;
  animation: hao-shake 0.5s ease-out 1;
}
.hao-line.gieo {
  width: 200px;
  height: 12px;
  border-radius: 4px;
}
.hao-line.gieo.yang {
  background: var(--gold-hao);
}
.hao-line.gieo.yin {
  background: linear-gradient(
    to right,
    var(--gold-hao) 42%,
    transparent 42%,
    transparent 58%,
    var(--gold) 58%
  );
}
.hao-line.gieo.yin::after { display: none; }
.hao-line.gieo.yin.moving {
  background: linear-gradient(
    to right,
    var(--red) 42%,
    transparent 42%,
    transparent 58%,
    var(--red) 58%
  ) !important;
}
.hao-line.gieo.yang.moving {
  background: var(--red) !important;
}

@keyframes hao-shake {
  0%   { transform: translateX(0); }
  20%  { transform: translateX(-3px); }
  40%  { transform: translateX(3px); }
  60%  { transform: translateX(-2px); }
  80%  { transform: translateX(2px); }
  100% { transform: translateX(0); }
}

/* Legacy — giữ để không break */
.hex-seg, .big-seg, .bien-seg, .qc-seg, .que-card-line { display: none; }

/* ── AI SECTION ── */
.ai-loading {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--text3);
  font-size: 13px;
  padding: 8px 0;
}

.ai-dot {
  width: 5px; height: 5px;
  border-radius: 50%;
  background: var(--gold);
  animation: aiPulse 1.2s ease-in-out infinite;
}
.ai-dot:nth-child(2) { animation-delay: 0.2s; }
.ai-dot:nth-child(3) { animation-delay: 0.4s; }

.ai-result {
  font-size: 14px;
  line-height: 1.85;
  color: var(--text);
}
.ai-result p { margin-bottom: 12px; }
.ai-result p:last-child { margin-bottom: 0; }

/* ── AUTH MODAL ── */
.auth-overlay {
  position: fixed; inset: 0;
  background: rgba(26,24,20,0.7);
  z-index: 300;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s;
}
.auth-overlay.open { opacity: 1; pointer-events: all; }

.auth-panel {
  background: var(--surface);
  border-radius: var(--radius);
  max-width: 400px;
  width: 100%;
  padding: 40px 36px;
  text-align: center;
  box-shadow: var(--shadow-lg);
  transform: translateY(20px);
  transition: transform 0.2s;
}
.auth-overlay.open .auth-panel { transform: translateY(0); }

.auth-han {
  font-family: 'Noto Serif SC', serif;
  font-size: 48px;
  color: var(--gold);
  margin-bottom: 16px;
}

.auth-title {
  font-family: var(--font-serif);
  font-size: 22px;
  font-weight: 400;
  margin-bottom: 8px;
}

.auth-desc {
  font-size: 13px;
  color: var(--text2);
  line-height: 1.7;
  margin-bottom: 8px;
}

.auth-free-note {
  font-size: 12px;
  color: var(--gold);
  margin-bottom: 28px;
  font-style: italic;
}

.auth-quota-bar {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  margin-bottom: 24px;
}

.auth-quota-dot {
  width: 10px; height: 10px;
  border-radius: 50%;
  background: var(--border);
}
.auth-quota-dot.used { background: var(--gold); }

.btn-google {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  width: 100%;
  padding: 12px 20px;
  background: var(--text);
  color: var(--bg);
  border: none;
  border-radius: var(--radius-sm);
  font-family: var(--font-sans);
  font-size: 13px;
  cursor: pointer;
  transition: opacity var(--transition);
  margin-bottom: 10px;
}
.btn-google:hover { opacity: 0.85; }

.btn-email-login {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  width: 100%;
  padding: 11px 20px;
  background: transparent;
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-family: var(--font-sans);
  font-size: 13px;
  cursor: pointer;
  transition: all var(--transition);
  margin-bottom: 20px;
}
.btn-email-login:hover { background: var(--bg2); }

.auth-skip {
  font-size: 12px;
  color: var(--text3);
  cursor: pointer;
  text-decoration: underline;
  background: none;
  border: none;
  font-family: var(--font-sans);
}
.auth-skip:hover { color: var(--text2); }

/* ── QUOTA BADGE (nav) ── */
.quota-badge {
  font-size: 11px;
  color: var(--text3);
  background: var(--bg2);
  border: 1px solid var(--border-light);
  border-radius: 20px;
  padding: 3px 10px;
  white-space: nowrap;
}
.quota-badge.low { color: var(--red); border-color: var(--red); }

/* ── USER AVATAR (nav) ── */
.nav-user {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: var(--radius-sm);
  transition: background var(--transition);
}
.nav-user:hover { background: var(--bg2); }

.nav-avatar {
  width: 28px; height: 28px;
  border-radius: 50%;
  background: var(--gold);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 500;
  color: var(--bg);
  flex-shrink: 0;
}

.nav-username {
  font-size: 12px;
  color: var(--text2);
  max-width: 100px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;

}

/* ============================================
   SETTINGS PANEL — thêm vào components.css
============================================ */

/* Nút Settings ⚙ */
.btn-settings {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  border: 1px solid var(--gold);
  background: rgba(177, 177, 177, 0.12);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: var(--text2);
  position: relative;
  transition: background var(--transition);
  padding: 0;
}
.btn-settings:hover { background: var(--bg2); }
.btn-settings svg { width: 15px; height: 15px; stroke: currentColor; fill: none; stroke-width: 1.6; }

/* Settings Panel dropdown */
.settings-panel {
  position: fixed;
  top: 52px;
  right: 16px;
  width: 232px;
  background: var(--surface);
  border: 0.5px solid var(--border);
  border-radius: var(--radius);
  padding: 6px;
  box-shadow: var(--shadow-lg);
  z-index: 200;
  opacity: 0;
  pointer-events: none;
  transform: translateY(-6px);
  transition: opacity 0.15s ease, transform 0.15s ease;
}
.settings-panel.open {
  opacity: 1;
  pointer-events: all;
  transform: translateY(0);
}

.settings-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 9px 10px;
  border-radius: var(--radius-sm);
}
.settings-row:hover { background: var(--bg2); }

.settings-row-label { font-size: 13px; color: var(--text); }
.settings-row-sub   { font-size: 11px; color: var(--text3); margin-top: 1px; }

.settings-divider {
  height: 0.5px;
  background: var(--border-light);
  margin: 3px 0;
}

.settings-note {
  font-size: 11px;
  color: var(--text3);
  padding: 5px 10px 3px;
  line-height: 1.5;
}

/* Language toggle VI | EN */
.lang-toggle {
  display: flex;
  background: var(--bg2);
  border-radius: var(--radius-sm);
  padding: 2px;
  gap: 1px;
}
.lang-btn {
  padding: 3px 10px;
  font-size: 12px;
  font-weight: 500;
  border-radius: 4px;
  cursor: pointer;
  color: var(--text3);
  transition: all var(--transition);
  user-select: none;
  border: none;
  background: transparent;
}
.lang-btn.active {
  background: var(--text2);
  color: var(--bg);
}

.settings-row:hover { background: var(--border-light); }
.lang-toggle { border: 0.5px solid var(--border); }

/* ── AI BLOCK CARD (top of ketqua right col) ── */
.ai-block-card {
  background: linear-gradient(150deg, #182e2a 0%, #0d2018 100%);
  border: 1px solid rgba(42,110,96,0.45);
  border-radius: var(--radius);
  margin-bottom: 16px;
  position: relative;
  overflow: hidden;
  display: flex;
  align-items: center;
}
.ai-block-card::before {
  content: '';
  position: absolute; top: 0; left: 0; right: 0; bottom: 0;
  background: radial-gradient(ellipse at top left, rgba(42,110,96,0.1) 0%, transparent 55%);
  pointer-events: none;
}
.ai-block-card::after {
  content: '';
  position: absolute; top: 0; left: 0; right: 0; height: 1px;
  background: linear-gradient(90deg, transparent, rgba(232,184,90,0.3), transparent);
}

.ai-block-text {
  flex: 1;
  padding: 18px 20px;
  position: relative;
}
.ai-block-header {
  display: flex; align-items: center; gap: 7px; margin-bottom: 7px;
}
.ai-block-pulse {
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--gold);
  box-shadow: 0 0 0 3px rgba(232,184,90,0.18);
  animation: aiPulse 2.2s ease infinite;
  flex-shrink: 0;
}
.ai-block-pulse--closed {
  background: #8abcaa;
  box-shadow: none;
  animation: none;
}
@keyframes aiPulse {
  0%, 100% { box-shadow: 0 0 0 3px rgba(232,184,90,0.18); }
  50%       { box-shadow: 0 0 0 6px rgba(232,184,90,0.06); }
}
.ai-block-label {
  font-size: 10px; color: #7aa898; letter-spacing: 0.08em;
  font-family: var(--font-sans);
}
.ai-block-title {
  font-family: var(--font-serif); font-size: 17px;
  color: #f0ece4; margin-bottom: 3px; line-height: 1.2;
}
.ai-block-sub {
  font-size: 11px; color: #5a8878; line-height: 1.5;
}
.ai-block-btn-wrap {
  padding: 18px 20px 18px 0;
  flex-shrink: 0; position: relative;
}

/* Mobile: stack vertical */
@media (max-width: 768px) {
  .ai-block-card { flex-direction: column; align-items: stretch; }
  .ai-block-text { padding: 16px 16px 12px; }
  .ai-block-btn-wrap { padding: 0 16px 16px; }
  .btn-ai-ask { width: 100%; justify-content: center; font-size: 13px; padding: 11px 16px; }
}

a.nav-link {
  text-decoration: none;
  color: var(--gold);
  font-family: var(--font-sans);
}
a.nav-link:hover {
  color: var(--gold);
}

a.bottom-nav-item {
  text-decoration: none;
}