/* ==========================================================================
   FAQ Component — Standalone CSS
   --------------------------------------------------------------------------
   Hoàn toàn độc lập với theme. Dùng chung cho mọi giao diện.
   - All selectors prefixed `.faq-` để tránh collision
   - CSS custom properties (--faq-*) cho phép tùy biến màu/spacing từ ngoài
   - Không depend external libraries
   ========================================================================== */

/* ============================================================================
   Layout 2 cột: FAQ list (trái) + contact card+form (phải). Mobile collapse 1 cột.
   Tokens shared với .faq-app — đặt ở :where(.faq-layout, .faq-app) để cả 2 inherit.
   ============================================================================ */
.faq-layout {
    --faq-accent: #c5a572;
    --faq-accent-dark: #a8895c;
    --faq-text: #1f2937;
    --faq-text-muted: #6b7280;
    --faq-border: #e5e7eb;
    --faq-bg: #ffffff;
    --faq-bg-alt: #f8fafc;
    --faq-shadow: 0 1px 2px rgba(0,0,0,0.04), 0 8px 24px rgba(0,0,0,0.05);
    --faq-radius: 10px;
    --faq-font: -apple-system, BlinkMacSystemFont, "Segoe UI", "Montserrat", Roboto, "Helvetica Neue", Arial, sans-serif;
    --faq-font-heading: Georgia, "Playfair Display", "Times New Roman", serif;

    display: grid;
    grid-template-columns: minmax(0, 1.5fr) minmax(0, 1fr);
    gap: 32px;
    max-width: 1200px;
    margin: 0 auto;
    padding: 40px 20px;
    font-family: var(--faq-font);
    color: var(--faq-text);
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
}
@media (max-width: 900px) {
    .faq-layout { grid-template-columns: 1fr; gap: 24px; }
}
.faq-layout .faq-main { min-width: 0; }

.faq-app {
    /* Tokens duplicated cho trường hợp .faq-app dùng standalone (không bọc .faq-layout) */
    --faq-accent: #c5a572;
    --faq-accent-dark: #a8895c;
    --faq-text: #1f2937;
    --faq-text-muted: #6b7280;
    --faq-border: #e5e7eb;
    --faq-bg: #ffffff;
    --faq-bg-alt: #f8fafc;
    --faq-shadow: 0 1px 2px rgba(0,0,0,0.04), 0 8px 24px rgba(0,0,0,0.05);
    --faq-radius: 10px;
    --faq-font: -apple-system, BlinkMacSystemFont, "Segoe UI", "Montserrat", Roboto, "Helvetica Neue", Arial, sans-serif;
    --faq-font-heading: Georgia, "Playfair Display", "Times New Roman", serif;

    max-width: 860px;
    margin: 0 auto;
    padding: 40px 20px;
    font-family: var(--faq-font);
    color: var(--faq-text);
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
}
/* Khi nằm trong .faq-layout, bỏ max-width/margin/padding riêng (layout đã set) */
.faq-layout .faq-app { max-width: none; margin: 0; padding: 0; }

/* Layout-only resets (chỉ trong .faq-app, không leak ra ngoài) */
.faq-app *, .faq-app *::before, .faq-app *::after { box-sizing: border-box; }

/* ---- Header ---- */
.faq-app .faq-header {
    text-align: center;
    margin-bottom: 32px;
    /* Override theme default — santi (và một số theme khác) gắn box-shadow vào thẻ <header> chung */
    box-shadow: none;
}
.faq-app .faq-header h1 {
    font-family: var(--faq-font-heading);
    font-size: 2.4rem;
    font-weight: 700;
    margin: 0 0 12px;
    color: var(--faq-text);
    letter-spacing: -0.01em;
}
.faq-app .faq-header p {
    color: var(--faq-text-muted);
    font-size: 1rem;
    margin: 0;
    max-width: 580px;
    margin-left: auto;
    margin-right: auto;
}

/* ---- Search bar ---- */
.faq-app .faq-search {
    position: relative;
    margin-bottom: 28px;
}
.faq-app .faq-search-input {
    width: 100%;
    height: 52px;
    padding: 0 48px 0 50px;
    font: inherit;
    font-size: 0.95rem;
    color: var(--faq-text);
    background: var(--faq-bg);
    border: 1px solid var(--faq-border);
    border-radius: var(--faq-radius);
    outline: none;
    transition: border-color 0.2s, box-shadow 0.2s;
}
.faq-app .faq-search-input::placeholder { color: var(--faq-text-muted); }
.faq-app .faq-search-input:focus {
    border-color: var(--faq-accent);
    box-shadow: 0 0 0 4px rgba(197, 165, 114, 0.12);
}
.faq-app .faq-search-icon {
    position: absolute;
    left: 18px;
    top: 50%;
    transform: translateY(-50%);
    width: 18px; height: 18px;
    color: var(--faq-text-muted);
    pointer-events: none;
}
.faq-app .faq-search-clear {
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    width: 28px; height: 28px;
    border: 0;
    background: transparent;
    color: var(--faq-text-muted);
    cursor: pointer;
    border-radius: 50%;
    display: none;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    line-height: 1;
    transition: background 0.2s, color 0.2s;
}
.faq-app .faq-search-clear:hover { background: var(--faq-bg-alt); color: var(--faq-text); }
.faq-app.has-query .faq-search-clear { display: inline-flex; }

/* ---- Results count ---- */
.faq-app .faq-count {
    font-size: 0.85rem;
    color: var(--faq-text-muted);
    margin: 0 4px 18px;
    min-height: 1.2em;
}

/* ---- List ---- */
.faq-app .faq-list {
    list-style: none;
    margin: 0;
    padding: 0;
}
.faq-app .faq-item {
    background: var(--faq-bg);
    border: 1px solid var(--faq-border);
    border-radius: var(--faq-radius);
    margin-bottom: 12px;
    overflow: hidden;
    transition: border-color 0.25s ease, box-shadow 0.25s ease;
}
.faq-app .faq-item:hover { border-color: #d1d5db; }
.faq-app .faq-item.is-open {
    border-color: var(--faq-accent);
    box-shadow: var(--faq-shadow);
}

/* Question — button so it's keyboard-accessible */
.faq-app .faq-q {
    width: 100%;
    background: transparent;
    border: 0;
    padding: 20px 60px 20px 24px;
    text-align: left;
    font: inherit;
    font-size: 1.02rem;
    font-weight: 600;
    color: var(--faq-text);
    cursor: pointer;
    position: relative;
    transition: color 0.2s;
    line-height: 1.5;
    display: block;
}
.faq-app .faq-q:hover { color: var(--faq-accent); }
.faq-app .faq-q:focus { outline: none; }
.faq-app .faq-q:focus-visible {
    outline: 2px solid var(--faq-accent);
    outline-offset: -2px;
    border-radius: var(--faq-radius);
}

/* Chevron icon — animated rotation on open */
.faq-app .faq-q-icon {
    position: absolute;
    right: 22px;
    top: 50%;
    margin-top: -6px;
    width: 12px; height: 12px;
    pointer-events: none;
    transition: transform 0.35s cubic-bezier(0.22, 1, 0.36, 1);
}
.faq-app .faq-q-icon::before,
.faq-app .faq-q-icon::after {
    content: "";
    position: absolute;
    top: 50%;
    width: 12px; height: 2px;
    background: var(--faq-text-muted);
    border-radius: 1px;
    transform-origin: center;
    transition: background 0.2s, transform 0.35s cubic-bezier(0.22, 1, 0.36, 1);
}
.faq-app .faq-q-icon::after { transform: rotate(90deg); }
.faq-app .faq-item.is-open .faq-q-icon::before { background: var(--faq-accent); }
.faq-app .faq-item.is-open .faq-q-icon::after { transform: rotate(0deg); background: var(--faq-accent); }

/* Answer panel — grid-row trick để animate height tự động không cần JS đo */
.faq-app .faq-a {
    display: grid;
    grid-template-rows: 0fr;
    transition: grid-template-rows 0.4s cubic-bezier(0.22, 1, 0.36, 1);
}
.faq-app .faq-item.is-open .faq-a {
    grid-template-rows: 1fr;
}
.faq-app .faq-a > .faq-a-inner {
    overflow: hidden;
    min-height: 0;
}
.faq-app .faq-a-content {
    padding: 0 24px 24px;
    color: var(--faq-text);
    font-size: 0.97rem;
    line-height: 1.75;
}
.faq-app .faq-a-content > *:first-child { margin-top: 0; }
.faq-app .faq-a-content > *:last-child { margin-bottom: 0; }
.faq-app .faq-a-content p { margin: 0 0 1em; }
.faq-app .faq-a-content h3,
.faq-app .faq-a-content h4 {
    font-family: var(--faq-font-heading);
    font-weight: 700;
    color: var(--faq-text);
    margin: 1.4em 0 0.5em;
    font-size: 1.1rem;
}
.faq-app .faq-a-content ul,
.faq-app .faq-a-content ol {
    margin: 0 0 1em;
    padding-left: 1.4em;
}
.faq-app .faq-a-content li { margin-bottom: 0.4em; }
.faq-app .faq-a-content li::marker { color: var(--faq-accent); }
.faq-app .faq-a-content a {
    color: var(--faq-accent);
    text-decoration: underline;
    text-underline-offset: 3px;
    text-decoration-thickness: 1px;
    transition: color 0.2s;
}
.faq-app .faq-a-content a:hover { color: var(--faq-accent-dark); }
.faq-app .faq-a-content strong { color: var(--faq-text); font-weight: 600; }
.faq-app .faq-a-content em { color: var(--faq-text-muted); }
.faq-app .faq-a-content code {
    background: var(--faq-bg-alt);
    padding: 2px 6px;
    border-radius: 4px;
    font-family: ui-monospace, "SF Mono", Menlo, monospace;
    font-size: 0.9em;
    color: var(--faq-accent-dark);
}
.faq-app .faq-a-content blockquote {
    margin: 1.2em 0;
    padding: 12px 18px;
    border-left: 3px solid var(--faq-accent);
    background: var(--faq-bg-alt);
    color: var(--faq-text-muted);
    font-style: italic;
}
.faq-app .faq-a-content img {
    max-width: 100%;
    height: auto;
    margin: 1em 0;
    border-radius: 6px;
    display: block;
}
.faq-app .faq-a-content hr {
    border: 0;
    height: 1px;
    background: var(--faq-border);
    margin: 1.5em 0;
}
.faq-app .faq-a-content table {
    width: 100%;
    border-collapse: collapse;
    margin: 1em 0;
    font-size: 0.92em;
}
.faq-app .faq-a-content th,
.faq-app .faq-a-content td {
    padding: 10px 14px;
    border: 1px solid var(--faq-border);
    text-align: left;
}
.faq-app .faq-a-content th {
    background: var(--faq-bg-alt);
    font-weight: 600;
}

/* Highlight search match in question text */
.faq-app mark {
    background: rgba(197, 165, 114, 0.25);
    color: inherit;
    padding: 1px 2px;
    border-radius: 2px;
}

/* ---- Empty state ---- */
.faq-app .faq-empty {
    text-align: center;
    padding: 60px 20px;
    color: var(--faq-text-muted);
    display: none;
}
.faq-app .faq-empty-icon {
    font-size: 2rem;
    margin-bottom: 12px;
    opacity: 0.4;
}
.faq-app .faq-empty h3 {
    margin: 0 0 6px;
    color: var(--faq-text);
    font-size: 1.2rem;
    /* font-family kế thừa từ theme — không override */
}
.faq-app .faq-empty p { margin: 0; font-size: 0.95rem; }
.faq-app.is-empty .faq-empty { display: block; }
.faq-app.is-empty .faq-list,
.faq-app.is-empty .faq-pagination { display: none; }

/* ---- Pagination ---- */
.faq-app .faq-pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 6px;
    margin-top: 28px;
    flex-wrap: wrap;
}
.faq-app .faq-pagination button,
.faq-app .faq-pagination span {
    min-width: 38px;
    height: 38px;
    padding: 0 12px;
    border: 1px solid var(--faq-border);
    background: var(--faq-bg);
    color: var(--faq-text);
    border-radius: 6px;
    font: inherit;
    font-size: 0.92rem;
    font-weight: 500;
    cursor: pointer;
    transition: border-color 0.2s, background 0.2s, color 0.2s;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}
.faq-app .faq-pagination button:hover:not(:disabled) {
    border-color: var(--faq-accent);
    color: var(--faq-accent);
}
.faq-app .faq-pagination button.is-current {
    background: var(--faq-accent);
    border-color: var(--faq-accent);
    color: #fff;
    cursor: default;
}
.faq-app .faq-pagination button:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}
.faq-app .faq-pagination .faq-page-ellipsis {
    border: 0;
    background: transparent;
    color: var(--faq-text-muted);
    cursor: default;
}

/* ---- Responsive ---- */
@media (max-width: 600px) {
    .faq-app { padding: 24px 16px; }
    .faq-app .faq-header h1 { font-size: 1.8rem; }
    .faq-app .faq-q { padding: 16px 50px 16px 18px; font-size: 0.97rem; }
    .faq-app .faq-q-icon { right: 18px; }
    .faq-app .faq-a-content { padding: 0 18px 18px; font-size: 0.94rem; }
    .faq-app .faq-search-input { height: 48px; padding-left: 46px; font-size: 0.92rem; }
    .faq-app .faq-search-icon { left: 16px; width: 16px; height: 16px; }
}

/* ---- Reduced motion ---- */
@media (prefers-reduced-motion: reduce) {
    .faq-app *, .faq-app *::before, .faq-app *::after {
        transition-duration: 0.01ms !important;
    }
}

/* ============================================================================
   Contact aside (right column) — card + form. Inherit token vars từ .faq-layout.
   ============================================================================ */
.faq-contact-aside {
    display: flex;
    flex-direction: column;
    gap: 16px;
    box-sizing: border-box;
}
.faq-contact-aside *, .faq-contact-aside *::before, .faq-contact-aside *::after { box-sizing: border-box; }

/* ── Contact card ── */
.faq-contact-card {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 18px;
    background: var(--faq-bg);
    border: 1px solid var(--faq-border);
    border-radius: var(--faq-radius);
    box-shadow: var(--faq-shadow);
}
.faq-cc-image {
    flex-shrink: 0;
    width: 80px; height: 80px;
    border-radius: 50%;
    background: var(--faq-bg-alt);
    display: flex; align-items: center; justify-content: center;
    overflow: hidden;
}
.faq-cc-image img { max-width: 80%; max-height: 80%; object-fit: contain; }
.faq-cc-info { flex: 1; min-width: 0; }
.faq-cc-title {
    margin: 0 0 8px;
    font-family: var(--faq-font-heading);
    font-size: 1.15rem;
    font-weight: 700;
    color: var(--faq-text);
    line-height: 1.3;
    word-break: break-word;
}
.faq-cc-row {
    display: flex; align-items: center; gap: 8px;
    font-size: 0.9rem;
    color: var(--faq-text-muted);
    margin-bottom: 4px;
}
.faq-cc-row svg { color: var(--faq-accent); flex-shrink: 0; }
.faq-cc-row a { color: inherit; text-decoration: none; }
.faq-cc-row a:hover { color: var(--faq-accent-dark); text-decoration: underline; }

/* ── Contact form ── */
.faq-contact-form {
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding: 18px;
    background: var(--faq-bg);
    border: 1px solid var(--faq-border);
    border-radius: var(--faq-radius);
    box-shadow: var(--faq-shadow);
}
.faq-form-row { display: flex; gap: 10px; }
.faq-form-row-2 > * { flex: 1; min-width: 0; }
@media (max-width: 500px) { .faq-form-row-2 { flex-direction: column; } }

.faq-field {
    position: relative;
    display: block;
    background: #fff;
    border: 1px solid var(--faq-border);
    border-radius: 8px;
    transition: border-color 0.15s, box-shadow 0.15s;
}
.faq-field:focus-within {
    border-color: var(--faq-accent);
    box-shadow: 0 0 0 3px rgba(197,165,114,0.15);
}
.faq-field-icon {
    position: absolute;
    left: 12px; top: 13px;
    color: var(--faq-text-muted);
    pointer-events: none;
}
.faq-field-textarea .faq-field-icon { top: 14px; }
.faq-field input, .faq-field textarea {
    width: 100%;
    padding: 11px 14px 11px 36px;
    border: 0;
    background: transparent;
    color: var(--faq-text);
    font-family: inherit;
    font-size: 0.92rem;
    line-height: 1.4;
    outline: none;
    border-radius: 8px;
}
.faq-field textarea { resize: vertical; min-height: 100px; }
.faq-field input::placeholder, .faq-field textarea::placeholder { color: #94a3b8; }

.faq-form-submit {
    align-self: flex-start;
    margin-top: 4px;
    padding: 11px 36px;
    background: var(--faq-accent);
    color: #fff;
    border: 0;
    border-radius: 8px;
    font-family: inherit;
    font-size: 0.95rem;
    font-weight: 600;
    letter-spacing: 0.02em;
    cursor: pointer;
    transition: background-color 0.15s, transform 0.15s;
}
.faq-form-submit:hover { background: var(--faq-accent-dark); }
.faq-form-submit:active { transform: translateY(1px); }
.faq-form-submit:disabled { opacity: 0.6; cursor: not-allowed; }

.faq-form-feedback {
    font-size: 0.85rem;
    min-height: 18px;
    margin-top: 2px;
}
.faq-form-feedback.success { color: #16a34a; }
.faq-form-feedback.error   { color: #dc2626; }

@media (max-width: 600px) {
    .faq-contact-card { flex-direction: column; text-align: center; }
    .faq-cc-info { text-align: center; }
    .faq-cc-row { justify-content: center; }
}
