/**
 * D-15 FAQ Block — Frontend Styles
 * Version: 3.2.3 — Premium Modern Design
 */

/* ============================================================
   CSS CUSTOM PROPERTIES
   ============================================================ */
.d15-faq-wrapper {
    --d15-brand: #3b82f6;
    --d15-font: 16px;
    --d15-radius: 16px;
    --d15-spacing: 16px;
    --d15-bg: #ffffff;
    --d15-text: #1e293b;
    --d15-text-secondary: #64748b;
    --d15-border: #e2e8f0;
    --d15-hover: #f8fafc;
    --d15-shadow: 0 4px 6px -1px rgba(0,0,0,0.1), 0 2px 4px -2px rgba(0,0,0,0.1);
    --d15-shadow-lg: 0 10px 15px -3px rgba(0,0,0,0.1), 0 4px 6px -4px rgba(0,0,0,0.1);
    --d15-shadow-xl: 0 20px 25px -5px rgba(0,0,0,0.1), 0 8px 10px -6px rgba(0,0,0,0.1);
    --d15-transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    --d15-q-bg: linear-gradient(135deg, #fafafa 0%, #f8fafc 100%);
    --d15-q-open-bg: linear-gradient(135deg, var(--d15-hover) 0%, #e0e7ff 100%);
    --d15-q-color: var(--d15-text);
    --d15-a-bg: linear-gradient(180deg, #f8fafc 0%, #ffffff 100%);
    --d15-a-color: var(--d15-text-secondary);
    --d15-accent: var(--d15-brand);
    --d15-icon-bg: var(--d15-accent);
    --d15-icon-color: #ffffff;

    font-size: var(--d15-font);
    color: var(--d15-text);
    line-height: 1.7;
    max-width: 100%;
    margin: 2.5em 0;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
}

/* ============================================================
   TITLE — Premium Header
   ============================================================ */
.d15-faq-title {
    font-size: 1.75em;
    font-weight: 800;
    margin-bottom: 1.5em;
    color: var(--d15-text);
    letter-spacing: -0.02em;
    line-height: 1.3;
    position: relative;
    padding-bottom: 0.75em;
}

.d15-faq-title::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    width: 60px;
    height: 4px;
    background: linear-gradient(90deg, var(--d15-brand) 0%, transparent 100%);
    border-radius: 2px;
}

/* ============================================================
   SEARCH — Premium Modern
   ============================================================ */
.d15-search-wrap {
    margin-bottom: calc(var(--d15-spacing) * 2);
    position: relative;
}

.d15-search-icon {
    position: absolute;
    left: 20px;
    top: 50%;
    transform: translateY(-50%);
    width: 20px;
    height: 20px;
    z-index: 2;
    pointer-events: none;
    background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='20' height='20' fill='%2394a3b8' viewBox='0 0 24 24'%3E%3Cpath d='M15.5 14h-.79l-.28-.27A6.47 6.47 0 0016 9.5 6.5 6.5 0 109.5 16c1.61 0 3.09-.59 4.23-1.57l.27.28v.79l5 4.99L20.49 19l-4.99-5zm-6 0C7.01 14 5 11.99 5 9.5S7.01 5 9.5 5 14 7.01 14 9.5 11.99 14 9.5 14z'/%3E%3C/svg%3E") center / contain no-repeat;
}

.d15-search-input {
    width: 100%;
    padding: 18px 24px 18px 60px !important;
    text-indent: 0 !important;
    border: 2px solid var(--d15-border);
    border-radius: 14px;
    font-size: 1em;
    background: var(--d15-bg);
    transition: var(--d15-transition);
    outline: none;
    box-sizing: border-box;
    color: var(--d15-text);
    box-shadow: 0 4px 6px -1px rgba(0,0,0,0.05), 0 2px 4px -2px rgba(0,0,0,0.05);
    font-weight: 500;
    background-image: none !important;
}

.d15-search-input::placeholder {
    color: #94a3b8;
    font-weight: 400;
}

.d15-search-input:focus {
    border-color: var(--d15-brand);
    box-shadow: 0 0 0 4px rgba(59, 130, 246, 0.1), 0 4px 20px rgba(59, 130, 246, 0.15);
    transform: translateY(-2px);
}

.d15-search-wrap::before { content: none !important; }

/* Highlight match */
.d15-highlight {
    background: linear-gradient(135deg, #fef08a 0%, #fde047 100%);
    padding: 2px 6px;
    border-radius: 4px;
    color: #1e293b;
    font-weight: 600;
}

/* Search match animation */
.d15-search-match {
    animation: d15-pulse 0.3s ease;
}

@keyframes d15-pulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.01); }
}

/* ============================================================
   NO RESULTS — Beautiful Empty State
   ============================================================ */
.d15-no-results {
    text-align: center;
    padding: 60px 24px;
    opacity: 0;
    transform: translateY(20px);
    transition: all 0.5s cubic-bezier(0.4, 0, 0.2, 1);
}

.d15-no-results-visible {
    opacity: 1;
    transform: translateY(0);
}

.d15-no-results-icon {
    font-size: 64px;
    margin-bottom: 20px;
    filter: grayscale(0.3);
}

.d15-no-results-text {
    font-size: 18px;
    font-weight: 600;
    color: #94a3b8;
}

/* ============================================================
   TOGGLE ALL — follows closed question style
   ============================================================ */
.d15-toggle-all-wrap {
    margin-bottom: var(--d15-spacing);
    text-align: right;
}

.d15-toggle-all-btn {
    background: var(--d15-q-bg) !important;
    border: 1px solid var(--d15-border);
    border-left: 4px solid var(--d15-accent);
    border-radius: var(--d15-radius);
    padding: 14px 24px;
    cursor: pointer;
    font-size: 0.95em;
    font-weight: 600;
    color: var(--d15-q-color) !important;
    transition: var(--d15-transition);
    box-shadow: var(--d15-shadow);
    min-width: 170px;
    text-align: center;
}

.d15-toggle-all-btn:hover {
    background: var(--d15-q-bg) !important;
    color: var(--d15-q-color) !important;
    border-color: var(--d15-border);
    border-left-color: var(--d15-accent);
    transform: translateY(-2px);
    box-shadow: var(--d15-shadow-lg);
    filter: brightness(0.96);
}

.d15-all-open .d15-toggle-all-btn {
    background: var(--d15-q-open-bg) !important;
    color: var(--d15-q-color) !important;
}

/* ============================================================
   MINI NAV — Sticky Navigation
   ============================================================ */
.d15-mini-nav {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: calc(var(--d15-spacing) * 1.5);
    padding: 16px;
    background: linear-gradient(135deg, #f8fafc 0%, #f1f5f9 100%);
    border-radius: var(--d15-radius);
    border: 1px solid var(--d15-border);
}

.d15-mini-nav__item {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border-radius: 10px;
    background: var(--d15-bg);
    color: var(--d15-text-secondary);
    text-decoration: none;
    font-size: 0.85em;
    font-weight: 600;
    transition: var(--d15-transition);
    border: 1px solid var(--d15-border);
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
}

.d15-mini-nav__item:hover,
.d15-mini-nav__item.d15-nav-active {
    background: var(--d15-brand);
    color: white;
    border-color: var(--d15-brand);
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(59, 130, 246, 0.3);
}

/* ============================================================
   CATEGORY
   ============================================================ */
.d15-category {
    margin-bottom: 2em;
}

.d15-category-title {
    font-size: 1.25em;
    font-weight: 700;
    margin-bottom: 1em;
    padding-bottom: 0.75em;
    border-bottom: 3px solid var(--d15-brand);
    color: var(--d15-text);
}

/* ============================================================
   FAQ LIST
   ============================================================ */
.d15-faq-list {
    display: grid;
    gap: 0;
}

/* ============================================================
   FAQ ITEM — Premium Card
   ============================================================ */
.d15-faq-item {
    border: 1px solid var(--d15-border);
    border-radius: var(--d15-radius);
    background: var(--d15-bg);
    overflow: hidden;
    transition: var(--d15-transition);
    box-shadow: var(--d15-shadow);
    margin-bottom: var(--d15-spacing);
    border-left: 4px solid transparent;
}

.d15-faq-item:last-child {
    margin-bottom: 0;
}

.d15-faq-item:hover {
    box-shadow: var(--d15-shadow-lg);
    transform: translateY(-2px);
}

.d15-faq-item.d15-open {
    border-left-color: var(--d15-accent, var(--d15-brand));
    box-shadow: var(--d15-shadow-xl);
}

/* ============================================================
   FAQ QUESTION — Interactive Button
   ============================================================ */
.d15-faq-question {
    display: flex;
    align-items: center;
    width: 100%;
    padding: 20px 24px;
    background: var(--d15-q-bg, linear-gradient(135deg, #fafafa 0%, #f8fafc 100%));
    border: none;
    cursor: pointer;
    font-size: 1.05em;
    font-weight: 600;
    text-align: left;
    color: var(--d15-q-color, var(--d15-text));
    gap: 16px;
    transition: var(--d15-transition);
    letter-spacing: -0.01em;
}

.d15-faq-wrapper .d15-faq-item:not(.d15-open) > .d15-faq-question {
    background: var(--d15-q-bg) !important;
    color: var(--d15-q-color) !important;
}

.d15-faq-wrapper .d15-faq-item.d15-open > .d15-faq-question {
    background: var(--d15-q-open-bg) !important;
    color: var(--d15-q-color) !important;
}

.d15-faq-question:hover {
    background: var(--d15-q-bg, linear-gradient(135deg, #f1f5f9 0%, #e2e8f0 100%));
}

.d15-faq-item.d15-open .d15-faq-question {
    background: var(--d15-q-open-bg, var(--d15-q-bg));
    color: var(--d15-q-color, var(--d15-text));
}

.d15-faq-question-text {
    flex: 1;
}

/* ============================================================
   FAQ ICON — Modern Circle
   ============================================================ */
.d15-faq-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    flex-shrink: 0;
    border-radius: 50%;
    background: var(--d15-icon-bg, var(--d15-accent));
    color: var(--d15-icon-color, #ffffff);
    transition: var(--d15-transition);
}

.d15-faq-icon::before {
    content: '';
    display: block;
    width: 8px;
    height: 8px;
    border-right: 2px solid currentColor;
    border-bottom: 2px solid currentColor;
    transform: rotate(-45deg) translate(-1px, -1px);
    transition: transform 0.3s cubic-bezier(0.68, -0.55, 0.265, 1.55);
}

.d15-open .d15-faq-icon {
    background: var(--d15-icon-bg, var(--d15-accent));
}

.d15-open .d15-faq-icon::before {
    transform: rotate(45deg) translate(-1px, -1px);
}

.d15-faq-question:hover .d15-faq-icon {
    transform: scale(1.1);
}

/* Icon sets from Gutenberg */
.d15-icon-plus .d15-faq-icon::before {
    content: '+';
    width: auto;
    height: auto;
    border: 0;
    transform: none;
    font-size: 22px;
    line-height: 1;
    font-weight: 500;
}

.d15-icon-plus .d15-open .d15-faq-icon::before {
    content: '-';
    transform: none;
}

.d15-icon-question .d15-faq-icon::before {
    content: '?';
    width: auto;
    height: auto;
    border: 0;
    transform: none;
    font-size: 18px;
    line-height: 1;
    font-weight: 800;
}

.d15-icon-dot .d15-faq-icon::before {
    content: '';
    width: 8px;
    height: 8px;
    border: 0;
    border-radius: 999px;
    background: currentColor;
    transform: none;
}

.d15-icon-arrow .d15-faq-icon::before {
    content: '→';
    width: auto;
    height: auto;
    border: 0;
    transform: none;
    font-size: 18px;
    line-height: 1;
    font-weight: 700;
}

.d15-icon-arrow .d15-open .d15-faq-icon::before {
    transform: rotate(90deg);
}

.d15-icon-none .d15-faq-icon {
    display: none;
}

/* Anchor link */
.d15-anchor-link {
    color: var(--d15-text-secondary);
    text-decoration: none;
    font-size: 0.8em;
    opacity: 0;
    transition: var(--d15-transition);
    padding: 6px 10px;
    border-radius: 8px;
    flex-shrink: 0;
    font-weight: 600;
}

.d15-faq-question:hover .d15-anchor-link {
    opacity: 0.6;
}

.d15-anchor-link:hover {
    opacity: 1 !important;
    background: rgba(59, 130, 246, 0.1);
    color: var(--d15-brand);
}

/* ============================================================
   FAQ ANSWER — Content Area
   ============================================================ */
.d15-faq-answer {
    max-height: 0;
    opacity: 0;
    overflow: hidden;
    transition: max-height 0.4s cubic-bezier(0.4, 0, 0.2, 1), opacity 0.3s ease;
}

.d15-open .d15-faq-answer {
    opacity: 1;
}

.d15-faq-answer-inner {
    padding: 8px 24px 24px 72px;
    color: var(--d15-a-color, var(--d15-text-secondary));
    background: var(--d15-a-bg, linear-gradient(180deg, #f8fafc 0%, #ffffff 100%));
    line-height: 1.8;
    font-size: 0.95em;
    border-top: 1px solid var(--d15-border);
}

.d15-faq-answer-inner p {
    margin: 0 0 1em;
}

.d15-faq-answer-inner p:last-child {
    margin-bottom: 0;
}

.d15-faq-answer-inner strong,
.d15-faq-answer-inner b {
    color: var(--d15-text);
    font-weight: 600;
}

.d15-faq-answer-inner a {
    color: var(--d15-brand);
    text-decoration: none;
    border-bottom: 1px solid transparent;
    transition: border-color 0.2s ease;
}

.d15-faq-answer-inner a:hover {
    border-bottom-color: var(--d15-brand);
}

.d15-faq-answer-inner ul,
.d15-faq-answer-inner ol {
    margin: 0.5em 0;
    padding-left: 1.5em;
}

.d15-faq-answer-inner li {
    margin-bottom: 0.5em;
}

/* ============================================================
   AI-OPTIMIZED ANSWER
   ============================================================ */
.d15-ai-answer .d15-ai-direct {
    font-size: 1.05em;
    padding: 16px 20px;
    background: linear-gradient(135deg, rgba(59, 130, 246, 0.05) 0%, rgba(59, 130, 246, 0.02) 100%);
    border-left: 4px solid var(--d15-brand);
    border-radius: 0 12px 12px 0;
    margin-bottom: 16px;
}

.d15-ai-answer .d15-ai-detail {
    padding-left: 20px;
    border-left: 2px solid var(--d15-border);
}

/* ============================================================
   CITATION-READY ANSWER
   ============================================================ */
.d15-citation-answer .d15-citation-short {
    margin: 0 0 16px;
    padding: 16px 20px;
    background: var(--d15-hover);
    border-left: 4px solid var(--d15-brand);
    font-style: italic;
    border-radius: 0 12px 12px 0;
}

.d15-citation-answer .d15-citation-source {
    display: inline-block;
    margin-top: 12px;
    font-size: 0.8em;
    color: var(--d15-text-secondary);
    padding: 4px 12px;
    background: var(--d15-hover);
    border-radius: 8px;
}

/* ============================================================
   TOOLTIP
   ============================================================ */
.d15-tooltip {
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%) translateY(8px);
    background: #1e293b;
    color: white;
    padding: 8px 14px;
    border-radius: 8px;
    font-size: 0.75em;
    white-space: nowrap;
    opacity: 0;
    transition: var(--d15-transition);
    pointer-events: none;
    z-index: 100;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
}

.d15-tooltip-visible {
    opacity: 1;
    transform: translateX(-50%) translateY(-4px);
}

/* ============================================================
   THEMES
   ============================================================ */

/* Dark Theme */
.d15-theme-dark {
    --d15-bg: #1e293b;
    --d15-text: #e2e8f0;
    --d15-text-secondary: #94a3b8;
    --d15-border: #334155;
    --d15-hover: #334155;
    --d15-shadow: 0 4px 6px -1px rgba(0,0,0,0.3);
    --d15-shadow-lg: 0 10px 15px -3px rgba(0,0,0,0.4);
    --d15-shadow-xl: 0 20px 25px -5px rgba(0,0,0,0.5);
}

/* Glass Theme */
.d15-theme-glass {
    --d15-bg: rgba(255,255,255,0.8);
    --d15-border: rgba(255,255,255,0.5);
}

.d15-theme-glass .d15-faq-item {
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
}

/* Neon Theme */
.d15-theme-neon {
    --d15-bg: #0f172a;
    --d15-text: #e2e8f0;
    --d15-text-secondary: #64748b;
    --d15-border: #1e293b;
    --d15-hover: #1e293b;
    --d15-brand: #00ff88;
    --d15-shadow: 0 0 20px rgba(0, 255, 136, 0.1);
    --d15-shadow-lg: 0 0 30px rgba(0, 255, 136, 0.2);
}

.d15-theme-neon .d15-faq-item.d15-open {
    box-shadow: 0 0 30px rgba(0, 255, 136, 0.3), inset 0 0 20px rgba(0, 255, 136, 0.05);
}

/* Editorial Theme */
.d15-theme-editorial {
    --d15-bg: #faf8f5;
    --d15-text: #2c2c2c;
    --d15-text-secondary: #666;
    --d15-border: #e8e4df;
    --d15-hover: #f0ece7;
    font-family: Georgia, 'Times New Roman', serif;
}

/* Brand Theme */
.d15-theme-brand {
    --d15-bg: #ffffff;
}

/* ============================================================
   LAYOUTS
   ============================================================ */

/* Cards */
.d15-layout-cards .d15-faq-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: var(--d15-spacing);
}

/* Grid */
.d15-layout-grid .d15-faq-list {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: var(--d15-spacing);
}

/* Bento */
.d15-layout-bento .d15-faq-list {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: var(--d15-spacing);
}

.d15-layout-bento .d15-faq-item:nth-child(3n+1) {
    grid-column: span 2;
}

/* Timeline */
.d15-layout-timeline .d15-faq-list {
    position: relative;
    padding-left: 40px;
}

.d15-layout-timeline .d15-faq-list::before {
    content: '';
    position: absolute;
    left: 15px;
    top: 0;
    bottom: 0;
    width: 3px;
    background: linear-gradient(180deg, var(--d15-brand) 0%, transparent 100%);
    border-radius: 2px;
}

.d15-layout-timeline .d15-faq-item {
    position: relative;
}

.d15-layout-timeline .d15-faq-item::before {
    content: '';
    position: absolute;
    left: -32px;
    top: 24px;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: var(--d15-brand);
    border: 3px solid var(--d15-bg);
    box-shadow: 0 0 0 2px var(--d15-brand);
}

/* Spotlight */
.d15-layout-spotlight .d15-faq-item {
    transition: all 0.4s ease;
}

.d15-layout-spotlight .d15-faq-item:not(.d15-open) {
    opacity: 0.6;
    transform: scale(0.98);
}

.d15-layout-spotlight .d15-faq-item.d15-open {
    opacity: 1;
    transform: scale(1);
    box-shadow: var(--d15-shadow-xl);
}

/* Chips */
.d15-layout-chips .d15-faq-list {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
}

.d15-layout-chips .d15-faq-item {
    flex: 0 0 auto;
    margin-bottom: 0;
}

.d15-layout-chips .d15-faq-question {
    padding: 12px 20px;
    border-radius: 30px;
    font-size: 0.9em;
}

/* ============================================================
   ANIMATIONS
   ============================================================ */
.d15-anim-fade .d15-faq-answer {
    max-height: none;
}

.d15-anim-spring .d15-faq-answer {
    transition: max-height 0.5s cubic-bezier(0.34, 1.56, 0.64, 1), opacity 0.3s ease;
}

.d15-anim-none .d15-faq-answer {
    transition: none;
}

/* ============================================================
   RESPONSIVE
   ============================================================ */
@media (max-width: 768px) {
    .d15-faq-question {
        padding: 16px 18px;
        font-size: 1em;
    }

    .d15-faq-answer-inner {
        padding: 8px 18px 18px 18px;
    }

    .d15-mini-nav {
        justify-content: center;
    }

    .d15-layout-cards .d15-faq-list,
    .d15-layout-grid .d15-faq-list,
    .d15-layout-bento .d15-faq-list {
        grid-template-columns: 1fr;
    }

    .d15-faq-icon {
        width: 28px;
        height: 28px;
    }
}

/* ============================================================
   PRINT
   ============================================================ */
@media print {
    .d15-search-wrap,
    .d15-toggle-all-wrap,
    .d15-mini-nav,
    .d15-anchor-link {
        display: none !important;
    }

    .d15-faq-answer {
        max-height: none !important;
        opacity: 1 !important;
        display: block !important;
    }

    .d15-faq-item {
        break-inside: avoid;
        box-shadow: none;
        border: 1px solid #ccc;
    }
}

/* ============================================================
   ACCESSIBILITY
   ============================================================ */
@media (prefers-reduced-motion: reduce) {
    .d15-faq-answer,
    .d15-faq-icon::before,
    .d15-faq-item,
    .d15-faq-question {
        transition: none !important;
        animation: none !important;
    }
}

/* ============================================================
   SEARCH MATCH
   ============================================================ */
.d15-search-match {
    border-color: var(--d15-brand) !important;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.15) !important;
}
