/* ===== Brand tokens (theo logo TRUNG CHÂU 1 — Cao Đài) ===== */
:root {
  --brand-gold:        #B8860B;   /* vành ngoài logo */
  --brand-gold-dark:   #8B6508;
  --brand-gold-light:  #E2B53B;
  --brand-yellow:      #FACC15;   /* cạnh vàng tam giác */
  --brand-red:         #DC2626;   /* cạnh đỏ */
  --brand-blue:        #1D4ED8;   /* cạnh xanh */
  --brand-cream:       #FFF8E7;
  --brand-strip: linear-gradient(90deg,
    var(--brand-yellow) 0%,
    var(--brand-red) 50%,
    var(--brand-blue) 100%);
  --brand-btn: linear-gradient(135deg, #B45309 0%, #92400E 100%);
  --brand-btn-hover: linear-gradient(135deg, #C2410C 0%, #9A3412 100%);
}

/* ===== Modal system — dùng chung cho cả index.html và admin.html ===== */

.modal-overlay {
  position: fixed; inset: 0; z-index: 50;
  display: none;
  align-items: center; justify-content: center;
  padding: 1rem;
  background: rgba(2, 6, 23, 0.55);
  backdrop-filter: blur(14px) saturate(140%);
  -webkit-backdrop-filter: blur(14px) saturate(140%);
  animation: m-backdrop-in .22s ease-out;
}
.modal-overlay.is-open { display: flex; }

.modal-card {
  position: relative;
  width: 100%;
  background: rgba(255, 255, 255, 0.96);
  border: 1px solid rgba(255, 255, 255, 0.6);
  border-radius: 28px;
  box-shadow:
    0 30px 60px -20px rgba(15, 23, 42, 0.4),
    0 18px 40px -15px rgba(99, 102, 241, 0.25),
    0 0 0 1px rgba(255, 255, 255, 0.08) inset;
  animation: m-card-in .32s cubic-bezier(0.16, 1, 0.3, 1);
  overflow: hidden;
}
.dark .modal-card {
  background: rgba(15, 23, 42, 0.96);
  border-color: rgba(255, 255, 255, 0.08);
  box-shadow:
    0 30px 60px -20px rgba(0, 0, 0, 0.7),
    0 18px 40px -15px rgba(99, 102, 241, 0.35),
    0 0 0 1px rgba(255, 255, 255, 0.05) inset;
}

/* Dải gradient ở cạnh trên — vàng/đỏ/xanh theo logo Cao Đài */
.modal-strip {
  position: absolute; inset: 0 0 auto 0;
  height: 5px;
  background: var(--brand-strip);
}

/* Brand block — logo + tên site, ở đầu mỗi modal */
.modal-brand {
  display: flex; align-items: center; gap: 12px;
  padding: 0 0 1.1rem;
  margin-bottom: 1.1rem;
  border-bottom: 1px solid rgba(184, 134, 11, 0.15);
}
.dark .modal-brand { border-bottom-color: rgba(226, 181, 59, 0.18); }
.modal-brand-logo {
  width: 44px; height: 44px;
  border-radius: 12px;
  object-fit: contain;
  background: white;
  padding: 3px;
  box-shadow: 0 4px 12px -2px rgba(184, 134, 11, 0.3);
  flex-shrink: 0;
}
.dark .modal-brand-logo { box-shadow: 0 4px 12px -2px rgba(226, 181, 59, 0.4); }
.modal-brand-text { line-height: 1.25; min-width: 0; }
.modal-brand-title {
  font-size: 13px; font-weight: 800;
  color: var(--brand-gold-dark);
  letter-spacing: 0.02em;
  text-transform: uppercase;
}
.dark .modal-brand-title { color: var(--brand-gold-light); }
.modal-brand-sub {
  font-size: 11px; color: rgb(120, 113, 108);
  margin-top: 1px;
}
.dark .modal-brand-sub { color: rgb(168, 162, 158); }

.modal-body { padding: 1.75rem; }
@media (min-width: 640px) { .modal-body { padding: 2rem; } }

.modal-header {
  display: flex; align-items: flex-start;
  justify-content: space-between; gap: 1rem;
}

.modal-eyebrow {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 5px 11px;
  border-radius: 999px;
  background: rgba(184, 134, 11, 0.12);
  color: var(--brand-gold-dark);
  font-size: 10.5px; font-weight: 700;
  letter-spacing: 0.06em; text-transform: uppercase;
}
.dark .modal-eyebrow { background: rgba(226, 181, 59, 0.18); color: var(--brand-gold-light); }

.modal-title {
  margin-top: 0.75rem;
  font-size: 1.05rem; font-weight: 700; line-height: 1.4;
  color: rgb(15, 23, 42);
}
.dark .modal-title { color: rgb(241, 245, 249); }
@media (min-width: 640px) { .modal-title { font-size: 1.15rem; } }

.modal-subtitle {
  margin-top: 0.35rem;
  font-size: 0.85rem; color: rgb(100, 116, 139);
}
.dark .modal-subtitle { color: rgb(148, 163, 184); }

.modal-close {
  flex-shrink: 0;
  padding: 8px;
  border-radius: 12px;
  color: rgb(148, 163, 184);
  background: transparent;
  transition: all .15s;
  cursor: pointer;
  border: 0;
}
.modal-close:hover {
  background: rgb(241, 245, 249);
  color: rgb(15, 23, 42);
  transform: rotate(90deg);
}
.dark .modal-close:hover {
  background: rgba(255, 255, 255, 0.08);
  color: white;
}

/* Avatar/icon ở center cho login */
.modal-icon {
  width: 64px; height: 64px;
  border-radius: 20px;
  background: var(--brand-btn);
  color: white;
  display: flex; align-items: center; justify-content: center;
  margin: 0 auto;
  box-shadow: 0 18px 30px -10px rgba(180, 83, 9, 0.5);
}

/* Field */
.modal-field { display: block; }
.modal-field + .modal-field { margin-top: 1rem; }
.modal-label {
  display: block;
  font-size: 11px; font-weight: 700;
  letter-spacing: 0.06em; text-transform: uppercase;
  color: rgb(100, 116, 139);
  margin-bottom: 7px;
}
.dark .modal-label { color: rgb(148, 163, 184); }

.modal-input, .modal-textarea {
  width: 100%;
  padding: 13px 16px;
  border-radius: 14px;
  border: 1.5px solid rgb(226, 232, 240);
  background: rgb(248, 250, 252);
  font-size: 14px;
  font-family: inherit;
  color: rgb(15, 23, 42);
  transition: all .15s;
  outline: none;
  -webkit-appearance: none;
}
.modal-textarea { resize: none; min-height: 84px; line-height: 1.5; }
.modal-input::placeholder, .modal-textarea::placeholder { color: rgb(148, 163, 184); }
.modal-input:focus, .modal-textarea:focus {
  border-color: var(--brand-gold);
  background: white;
  box-shadow: 0 0 0 4px rgba(184, 134, 11, 0.18);
}
.dark .modal-input, .dark .modal-textarea {
  background: rgba(255, 255, 255, 0.04);
  border-color: rgba(255, 255, 255, 0.1);
  color: rgb(241, 245, 249);
}
.dark .modal-input:focus, .dark .modal-textarea:focus {
  background: rgba(255, 255, 255, 0.07);
  box-shadow: 0 0 0 4px rgba(226, 181, 59, 0.25);
}

.modal-row {
  display: grid; gap: 0.75rem;
}
@media (min-width: 640px) { .modal-row.cols-2 { grid-template-columns: 1fr 1fr; } }

/* Toggle (switch-style) */
.modal-toggle {
  display: flex; align-items: center; gap: 0.85rem;
  padding: 13px 16px;
  border-radius: 14px;
  background: rgb(248, 250, 252);
  border: 1.5px solid rgb(226, 232, 240);
  cursor: pointer;
  user-select: none;
  transition: all .15s;
}
.modal-toggle:hover { border-color: rgba(184, 134, 11, 0.4); }
.dark .modal-toggle {
  background: rgba(255, 255, 255, 0.04);
  border-color: rgba(255, 255, 255, 0.1);
}
.dark .modal-toggle:hover { border-color: rgba(226, 181, 59, 0.55); }
.modal-toggle input { display: none; }
.modal-switch {
  position: relative; width: 42px; height: 24px; flex-shrink: 0;
  background: rgb(203, 213, 225);
  border-radius: 999px;
  transition: background .2s;
}
.modal-switch::after {
  content: ""; position: absolute; top: 2px; left: 2px;
  width: 20px; height: 20px; border-radius: 50%;
  background: white;
  box-shadow: 0 2px 6px rgba(15, 23, 42, 0.2);
  transition: transform .22s cubic-bezier(0.16, 1, 0.3, 1);
}
.modal-toggle input:checked + .modal-switch { background: var(--brand-gold); }
.modal-toggle input:checked + .modal-switch::after { transform: translateX(18px); }
.modal-toggle-text { font-size: 13.5px; line-height: 1.4; }
.modal-toggle-text strong { display: block; font-weight: 600; color: rgb(30, 41, 59); }
.dark .modal-toggle-text strong { color: rgb(241, 245, 249); }
.modal-toggle-text small { color: rgb(100, 116, 139); font-size: 12px; }
.dark .modal-toggle-text small { color: rgb(148, 163, 184); }

/* Footer / actions */
.modal-actions {
  margin-top: 1.75rem;
  display: flex; gap: 0.6rem;
}
.modal-btn {
  flex: 1;
  padding: 13px 16px;
  border-radius: 14px;
  font-weight: 600;
  font-size: 14px;
  border: 0;
  cursor: pointer;
  transition: all .15s;
  display: inline-flex; align-items: center; justify-content: center;
  gap: 8px;
  font-family: inherit;
}
.modal-btn-primary {
  color: white;
  background: var(--brand-btn);
  box-shadow: 0 10px 24px -10px rgba(180, 83, 9, 0.6);
}
.modal-btn-primary:hover:not(:disabled) {
  transform: translateY(-1px);
  background: var(--brand-btn-hover);
  box-shadow: 0 14px 28px -10px rgba(180, 83, 9, 0.7);
}
.modal-btn-primary:active:not(:disabled) { transform: translateY(0) scale(0.985); }
.modal-btn-primary:disabled { opacity: 0.55; cursor: not-allowed; }
.modal-btn-secondary {
  color: rgb(71, 85, 105);
  background: rgb(241, 245, 249);
}
.modal-btn-secondary:hover { background: rgb(226, 232, 240); }
.dark .modal-btn-secondary {
  background: rgba(255, 255, 255, 0.06);
  color: rgb(203, 213, 225);
}
.dark .modal-btn-secondary:hover { background: rgba(255, 255, 255, 0.1); }

.modal-error {
  margin-top: 10px;
  font-size: 12.5px;
  color: rgb(244, 63, 94);
  display: flex; align-items: center; gap: 6px;
}
.modal-hint {
  margin-top: 1.1rem;
  text-align: center;
  font-size: 11.5px;
  color: rgb(148, 163, 184);
}
.modal-hint code {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  padding: 1px 6px;
  border-radius: 6px;
  background: rgb(241, 245, 249);
  color: rgb(71, 85, 105);
}
.dark .modal-hint code { background: rgba(255, 255, 255, 0.06); color: rgb(203, 213, 225); }

@keyframes m-backdrop-in { from { opacity: 0 } to { opacity: 1 } }
@keyframes m-card-in {
  from { opacity: 0; transform: scale(0.93) translateY(16px); }
  to   { opacity: 1; transform: scale(1) translateY(0); }
}

/* ===== Guide section (tab Hướng dẫn) ===== */
.guide-step {
  position: relative;
  opacity: 0;
  animation: guide-step-in .6s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}
.guide-step-num {
  position: absolute;
  top: -18px; left: 24px;
  width: 44px; height: 44px;
  border-radius: 14px;
  background: var(--brand-btn);
  color: white;
  font-weight: 800; font-size: 1.25rem;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 10px 25px -8px rgba(180, 83, 9, 0.55);
}
.guide-step-num::after {
  content: ""; position: absolute; inset: -4px;
  border-radius: 18px;
  border: 2px solid var(--brand-gold);
  opacity: 0;
  animation: ring-pulse 2.4s ease-out infinite;
}
.guide-step:nth-child(1) .guide-step-num::after { animation-delay: 0s; }
.guide-step:nth-child(2) .guide-step-num::after { animation-delay: 0.6s; }
.guide-step:nth-child(3) .guide-step-num::after { animation-delay: 1.2s; }
.guide-step:nth-child(4) .guide-step-num::after { animation-delay: 1.8s; }

.guide-step-icon {
  width: 52px; height: 52px;
  border-radius: 16px;
  background: linear-gradient(135deg, rgba(250,204,21,0.18) 0%, rgba(184,134,11,0.18) 100%);
  color: var(--brand-gold-dark);
  display: flex; align-items: center; justify-content: center;
  margin-top: 1rem;
  transition: transform .25s;
}
.dark .guide-step-icon {
  background: linear-gradient(135deg, rgba(250,204,21,0.16) 0%, rgba(226,181,59,0.22) 100%);
  color: var(--brand-gold-light);
}
.guide-step:hover .guide-step-icon { transform: scale(1.08) rotate(-4deg); }
.guide-step:hover .guide-step-num { transform: scale(1.05); transition: transform .2s; }

/* Mũi tên giữa các step (desktop) */
@media (min-width: 1024px) {
  .guide-step + .guide-step::before {
    content: "";
    position: absolute;
    left: -28px; top: 50%;
    width: 24px; height: 2px;
    background: linear-gradient(90deg, transparent, var(--brand-gold) 50%, var(--brand-gold));
    transform: translateY(-50%);
    opacity: 0;
    animation: arrow-draw .5s ease-out forwards;
    animation-delay: 0.7s;
  }
  .guide-step + .guide-step::after {
    content: "";
    position: absolute;
    left: -10px; top: 50%;
    transform: translateY(-50%) rotate(45deg);
    width: 8px; height: 8px;
    border-top: 2px solid var(--brand-gold);
    border-right: 2px solid var(--brand-gold);
    opacity: 0;
    animation: arrow-draw .5s ease-out forwards;
    animation-delay: 0.9s;
  }
}

.guide-tip {
  display: flex; gap: 0.85rem; align-items: flex-start;
  padding: 1rem 1.1rem;
  border-radius: 18px;
  background: rgba(255,255,255,0.55);
  border: 1px solid rgba(184,134,11,0.15);
  transition: all .2s;
  opacity: 0;
  animation: guide-step-in .5s ease-out forwards;
}
.dark .guide-tip {
  background: rgba(17,24,39,0.5);
  border-color: rgba(226,181,59,0.18);
}
.guide-tip:hover {
  transform: translateY(-2px);
  border-color: var(--brand-gold);
}
.guide-tip-emoji { font-size: 1.5rem; line-height: 1; flex-shrink: 0; margin-top: 2px; }
.guide-cta {
  display: inline-flex; align-items: center; gap: 0.6rem;
  padding: 14px 28px;
  border-radius: 18px;
  background: var(--brand-btn);
  color: white; font-weight: 600; font-size: 0.95rem;
  box-shadow: 0 12px 28px -10px rgba(180, 83, 9, 0.55);
  transition: all .2s;
  cursor: pointer; border: 0;
}
.guide-cta:hover {
  transform: translateY(-2px);
  background: var(--brand-btn-hover);
  box-shadow: 0 16px 34px -10px rgba(180, 83, 9, 0.65);
}
.guide-cta:active { transform: translateY(0) scale(0.98); }
.guide-cta svg {
  transition: transform .25s;
}
.guide-cta:hover svg { transform: translateX(4px); }

@keyframes guide-step-in {
  from { opacity: 0; transform: translateY(24px) scale(0.95); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}
@keyframes arrow-draw {
  from { opacity: 0; transform: translateY(-50%) translateX(-8px); }
  to   { opacity: 1; transform: translateY(-50%) translateX(0); }
}
@keyframes ring-pulse {
  0%   { opacity: 0.7; transform: scale(1); }
  70%  { opacity: 0;   transform: scale(1.35); }
  100% { opacity: 0;   transform: scale(1.35); }
}
