/**
 * Debtia Dictionary Styles
 * Archive and Single template styling
 *
 * Uses Bootstrap CSS variables with fallbacks:
 * --bs-primary: #088c76 (Debtia green)
 * --bs-secondary: #002954 (Debtia dark blue)
 * --debtia-radius-sm/md/lg from debtia.css
 *
 * @package Debtia
 */

/* -----------------------------------------
   Archive Page Layout
   ----------------------------------------- */
.dictionary-archive-page {
    padding: 3rem 0 4rem;
    background: linear-gradient(180deg, #f8f9fa 0%, #fff 100%);
    min-height: 60vh;
}

.dictionary-archive {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 1.5rem;
}

/* -----------------------------------------
   Alphabet Navigation Bar
   ----------------------------------------- */
.dictionary-alphabet-nav {
    display: flex;
    flex-wrap: nowrap;
    justify-content: center;
    gap: 0.375rem;
    padding: 1rem 1rem;
    background: #fff;
    border-radius: var(--debtia-radius-sm, 16px);
    box-shadow: 0 2px 12px rgba(0, 41, 84, 0.06);
    border: 1px solid rgba(0, 41, 84, 0.08);
    margin-bottom: 2.5rem;
    position: sticky;
    top: 80px;
    z-index: 100;
}

.dictionary-alphabet-link {
    display: flex;
    align-items: center;
    justify-content: center;
    flex: 1;
    aspect-ratio: 1 / 1;
    min-width: 28px;
    max-width: 42px;
    font-weight: 600;
    font-size: 0.9375rem;
    color: var(--bs-secondary, #002954);
    background: #f8f9fa;
    border-radius: 8px;
    text-decoration: none;
    transition: all 0.2s ease;
}

.dictionary-alphabet-link:hover {
    background: var(--bs-primary, #088c76);
    color: #fff;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(8, 140, 118, 0.25);
}

.dictionary-alphabet-link.is-active {
    background: var(--bs-primary, #088c76);
    color: #fff;
}

.dictionary-alphabet-link.is-disabled {
    display: none;
}

/* -----------------------------------------
   Search Bar (optional)
   ----------------------------------------- */
.dictionary-search {
    position: relative;
    max-width: 400px;
    margin: 0 auto 2rem;
}

.dictionary-search-input {
    width: 100%;
    padding: 0.875rem 1rem 0.875rem 3rem;
    font-size: 0.9375rem;
    border: 1px solid rgba(0, 41, 84, 0.08);
    border-radius: var(--debtia-radius-sm, 16px);
    background: #fff;
    transition: all 0.2s ease;
}

.dictionary-search-input:focus {
    outline: none;
    border-color: var(--bs-primary, #088c76);
    box-shadow: 0 0 0 3px rgba(8, 140, 118, 0.1);
}

.dictionary-search-icon {
    position: absolute;
    left: 1rem;
    top: 50%;
    transform: translateY(-50%);
    color: #6c757d;
    pointer-events: none;
}

.dictionary-search-clear {
    position: absolute;
    right: 1rem;
    top: 50%;
    transform: translateY(-50%);
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #e9ecef;
    border: none;
    border-radius: 50%;
    color: #6c757d;
    cursor: pointer;
    opacity: 0;
    visibility: hidden;
    transition: all 0.2s ease;
}

.dictionary-search.has-value .dictionary-search-clear {
    opacity: 1;
    visibility: visible;
}

.dictionary-search-clear:hover {
    background: var(--bs-primary, #088c76);
    color: #fff;
}

.dictionary-search-clear svg {
    width: 12px;
    height: 12px;
}

/* Search Results */
.dictionary-search-results {
    margin-bottom: 2rem;
}

.dictionary-search-results-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1rem;
}

.dictionary-search-results-title {
    font-size: 1rem;
    font-weight: 600;
    color: var(--bs-secondary, #002954);
    margin: 0;
}

.dictionary-search-results-count {
    font-size: 0.875rem;
    color: #6c757d;
}

.dictionary-search-results-list {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.dictionary-search-result-item {
    display: block;
    padding: 1rem 1.25rem;
    background: #fff;
    border: 1px solid rgba(0, 41, 84, 0.08);
    border-radius: 8px;
    text-decoration: none;
    transition: all 0.2s ease;
}

.dictionary-search-result-item:hover {
    border-color: var(--bs-primary, #088c76);
    box-shadow: 0 4px 12px rgba(8, 140, 118, 0.1);
}

.dictionary-search-result-title {
    font-size: 1rem;
    font-weight: 600;
    color: var(--bs-secondary, #002954);
    margin-bottom: 0.25rem;
}

.dictionary-search-result-item:hover .dictionary-search-result-title {
    color: var(--bs-primary, #088c76);
}

.dictionary-search-result-excerpt {
    font-size: 0.875rem;
    color: #6c757d;
    line-height: 1.5;
    margin: 0;
}

.dictionary-search-result-excerpt mark {
    background: rgba(8, 140, 118, 0.15);
    color: inherit;
    padding: 0.1em 0.2em;
    border-radius: 2px;
}

.dictionary-search-no-results {
    text-align: center;
    padding: 2rem;
    color: #6c757d;
}

.dictionary-search-no-results svg {
    width: 48px;
    height: 48px;
    margin-bottom: 1rem;
    opacity: 0.5;
}

/* Hide normal content when searching */
.dictionary-archive.is-searching .dictionary-words-container,
.dictionary-archive.is-searching .dictionary-alphabet-nav {
    display: none;
}

/* -----------------------------------------
   Letter Section
   ----------------------------------------- */
.dictionary-letter-section {
    margin-bottom: 2rem;
    scroll-margin-top: 140px;
    padding: 2rem 0;
    border-bottom: 1px solid rgba(0, 41, 84, 0.08);
}

.dictionary-letter-section:last-child {
    border-bottom: none;
}

.dictionary-letter-heading {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 48px;
    height: 48px;
    font-size: 1.5rem;
    font-weight: 700;
    color: #fff;
    background: var(--bs-primary, #088c76);
    border-radius: 8px;
    margin-bottom: 1rem;
}

/* -----------------------------------------
   Words Grid (Multi-column)
   ----------------------------------------- */
.dictionary-words-grid {
    column-count: 4;
    column-gap: 1.5rem;
}

.dictionary-word-item {
    display: block;
    break-inside: avoid;
    margin-bottom: 0.5rem;
}

.dictionary-word-link {
    display: inline-block;
    padding: 0.375rem 0;
    font-size: 0.9375rem;
    color: var(--bs-secondary, #002954);
    text-decoration: none;
    transition: color 0.15s ease;
    position: relative;
}

.dictionary-word-link:hover {
    color: var(--bs-primary, #088c76);
}

.dictionary-word-link::after {
    content: '';
    position: absolute;
    bottom: 0.25rem;
    left: 0;
    width: 0;
    height: 1px;
    background: var(--bs-primary, #088c76);
    transition: width 0.2s ease;
}

.dictionary-word-link:hover::after {
    width: 100%;
}

/* -----------------------------------------
   Tooltip Styles (Popper.js compatible)
   ----------------------------------------- */
.dictionary-tooltip {
    position: absolute;
    z-index: 9999;
    max-width: 320px;
    padding: 0.875rem 1rem;
    font-size: 0.875rem;
    line-height: 1.5;
    color: #fff;
    background: #057861;
    border-radius: 8px;
    box-shadow: 0 8px 24px rgba(0, 41, 84, 0.2);
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.15s ease, visibility 0.15s ease;
    pointer-events: none;
}

.dictionary-tooltip.is-visible {
    opacity: 1;
    visibility: visible;
}

/* Tooltip arrow */
.dictionary-tooltip[data-popper-placement^='top'] .dictionary-tooltip-arrow {
    bottom: -6px;
}

.dictionary-tooltip[data-popper-placement^='bottom'] .dictionary-tooltip-arrow {
    top: -6px;
}

.dictionary-tooltip[data-popper-placement^='left'] .dictionary-tooltip-arrow {
    right: -6px;
}

.dictionary-tooltip[data-popper-placement^='right'] .dictionary-tooltip-arrow {
    left: -6px;
}

.dictionary-tooltip-arrow,
.dictionary-tooltip-arrow::before {
    position: absolute;
    width: 12px;
    height: 12px;
    background: inherit;
}

.dictionary-tooltip-arrow {
    visibility: hidden;
}

.dictionary-tooltip-arrow::before {
    content: '';
    visibility: visible;
    transform: rotate(45deg);
}

/* -----------------------------------------
   Single Page Layout
   ----------------------------------------- */
.dictionary-single-page {
    padding: 3rem 0 4rem;
    background: linear-gradient(180deg, #f8f9fa 0%, #fff 100%);
}

.dictionary-single-layout {
    display: grid;
    grid-template-columns: 1fr 320px;
    gap: 2.5rem;
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 1.5rem;
}

/* Main Content */
.dictionary-single-main {
    min-width: 0;
}

.dictionary-word-title {
    font-size: 2rem;
    font-weight: 700;
    color: var(--bs-secondary, #002954);
    margin: 0 0 1.5rem;
    line-height: 1.3;
}

.dictionary-content {
    font-size: 1.0625rem;
    line-height: 1.75;
    color: var(--bs-secondary, #002954);
}

.dictionary-content p {
    margin-bottom: 1.25rem;
}

.dictionary-content h2,
.dictionary-content h3 {
    margin-top: 2rem;
    margin-bottom: 1rem;
    color: var(--bs-secondary, #002954);
}

.dictionary-content a {
    color: var(--bs-primary, #088c76);
    text-decoration: underline;
    text-decoration-color: rgba(8, 140, 118, 0.3);
    text-underline-offset: 2px;
    transition: text-decoration-color 0.2s ease;
}

.dictionary-content a:hover {
    text-decoration-color: var(--bs-primary, #088c76);
}

/* -----------------------------------------
   Synonyms Section
   ----------------------------------------- */
.dictionary-synonyms {
    margin-top: 2rem;
    padding-top: 1.5rem;
    border-top: 1px solid rgba(0, 41, 84, 0.08);
}

.dictionary-synonyms-title {
    font-size: 0.875rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: #6c757d;
    margin-bottom: 0.75rem;
}

.dictionary-synonyms-list {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.dictionary-synonym-tag {
    display: inline-flex;
    align-items: center;
    padding: 0.375rem 0.875rem;
    font-size: 0.875rem;
    color: #057861;
    background: rgba(8, 140, 118, 0.08);
    border-radius: 100px;
    text-decoration: none;
    transition: all 0.2s ease;
}

.dictionary-synonym-tag:hover {
    background: var(--bs-primary, #088c76);
    color: #fff;
}

/* -----------------------------------------
   Related Box with Toggle
   ----------------------------------------- */
.dictionary-related-list-wrapper {
    max-height: 320px;
    overflow-y: auto;
    overflow-x: hidden;
    scrollbar-width: thin;
    scrollbar-color: rgba(8, 140, 118, 0.3) transparent;
}

.dictionary-related-list-wrapper::-webkit-scrollbar {
    width: 4px;
}

.dictionary-related-list-wrapper::-webkit-scrollbar-track {
    background: transparent;
}

.dictionary-related-list-wrapper::-webkit-scrollbar-thumb {
    background: rgba(8, 140, 118, 0.3);
    border-radius: 4px;
}

.dictionary-related-list-wrapper::-webkit-scrollbar-thumb:hover {
    background: rgba(8, 140, 118, 0.5);
}

/* Hidden items */
.dictionary-related-list li.is-hidden {
    display: none;
}

.dictionary-related-box.is-expanded .dictionary-related-list li.is-hidden {
    display: list-item;
}

.dictionary-related-toggle {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.375rem;
    width: 100%;
    margin-top: 0.75rem;
    padding: 0.625rem 1rem;
    font-size: 0.8125rem;
    font-weight: 600;
    color: var(--bs-primary, #088c76);
    background: rgba(8, 140, 118, 0.06);
    border: none;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.dictionary-related-toggle:hover {
    background: rgba(8, 140, 118, 0.12);
}

.dictionary-related-toggle svg {
    width: 16px;
    height: 16px;
    transition: transform 0.25s ease;
}

.dictionary-related-box.is-expanded .dictionary-related-toggle svg {
    transform: rotate(180deg);
}

/* -----------------------------------------
   FAQ Section on Single
   ----------------------------------------- */
.dictionary-faq-section {
    margin-top: 3rem;
    padding-top: 2rem;
    border-top: 1px solid rgba(0, 41, 84, 0.08);
}

.dictionary-faq-title {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--bs-secondary, #002954);
    margin-bottom: 1.25rem;
}

.dictionary-faq-list {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

/* FAQ Accordion Item */
.dictionary-faq-item {
    background: #fff;
    border-radius: 8px;
    border: 1px solid rgba(0, 41, 84, 0.08);
    overflow: hidden;
    transition: box-shadow 0.2s ease;
}

.dictionary-faq-item:hover {
    box-shadow: 0 4px 12px rgba(0, 41, 84, 0.06);
}

.dictionary-faq-trigger {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    width: 100%;
    padding: 1rem 1.25rem;
    font-size: 0.9375rem;
    font-weight: 600;
    color: var(--bs-secondary, #002954);
    background: none;
    border: none;
    cursor: pointer;
    text-align: left;
    transition: background 0.2s ease;
}

.dictionary-faq-trigger:hover {
    background: rgba(8, 140, 118, 0.03);
}

.dictionary-faq-icon {
    flex-shrink: 0;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(8, 140, 118, 0.08);
    border-radius: 6px;
    color: var(--bs-primary, #088c76);
    transition: all 0.25s ease;
}

.dictionary-faq-icon svg {
    width: 14px;
    height: 14px;
    transition: transform 0.25s ease;
}

.dictionary-faq-item.is-open .dictionary-faq-icon {
    background: var(--bs-primary, #088c76);
    color: #fff;
}

.dictionary-faq-item.is-open .dictionary-faq-icon svg {
    transform: rotate(45deg);
}

.dictionary-faq-question {
    flex: 1;
    margin: 0;
    font-size: inherit;
    font-weight: inherit;
}

.dictionary-faq-content {
    display: grid;
    grid-template-rows: 0fr;
    transition: grid-template-rows 0.3s ease;
}

.dictionary-faq-item.is-open .dictionary-faq-content {
    grid-template-rows: 1fr;
}

.dictionary-faq-answer {
    overflow: hidden;
}

.dictionary-faq-answer-inner {
    padding: 0 1.25rem 1.25rem 3.25rem;
    font-size: 0.9375rem;
    line-height: 1.65;
    color: #6c757d;
}

.dictionary-faq-answer-inner p:last-child {
    margin-bottom: 0;
}

/* -----------------------------------------
   Single Sidebar
   ----------------------------------------- */
.dictionary-single-sidebar {
    position: relative;
}

.dictionary-sidebar-inner {
    position: sticky;
    top: 100px;
}

/* Related Words Box */
.dictionary-related-box {
    background: #fff;
    border-radius: var(--debtia-radius-sm, 16px);
    border: 1px solid rgba(0, 41, 84, 0.08);
    padding: 1.5rem;
    margin-bottom: 1.5rem;
}

.dictionary-related-title {
    font-size: 0.9375rem;
    font-weight: 700;
    color: var(--bs-secondary, #002954);
    margin-bottom: 1rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.dictionary-related-title svg {
    color: var(--bs-primary, #088c76);
}

.dictionary-related-list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.dictionary-related-link {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.625rem 0.75rem;
    font-size: 0.875rem;
    line-height: 1.4;
    color: var(--bs-secondary, #002954);
    text-decoration: none;
    border-radius: 8px;
    transition: all 0.2s ease;
}

.dictionary-related-link:hover {
    color: var(--bs-primary, #088c76);
    background: rgba(8, 140, 118, 0.1);
}

.dictionary-related-link svg {
    flex-shrink: 0;
    width: 16px;
    height: 16px;
    margin-left: 0.5rem;
    color: #adb5bd;
    transition: all 0.2s ease;
}

.dictionary-related-link:hover svg {
    color: var(--bs-primary, #088c76);
    transform: translateX(2px);
}

/* CTA Box */
.dictionary-cta-box {
    border-radius: var(--debtia-radius-sm, 16px);
    padding: 1.75rem 1.5rem;
    text-align: center;
    color: #fff;
}

.dictionary-cta-icon {
    width: 48px;
    height: 48px;
    margin: 0 auto 1rem;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.15);
    border-radius: 12px;
}

.dictionary-cta-icon svg {
    width: 24px;
    height: 24px;
}

.dictionary-cta-title {
    font-size: 1.125rem;
    font-weight: 700;
    margin-bottom: 0.5rem;
}

.dictionary-cta-text {
    font-size: 0.875rem;
    opacity: 0.9;
    margin-bottom: 1.25rem;
    line-height: 1.5;
}

.dictionary-cta-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem 1.25rem;
    font-size: 0.875rem;
    font-weight: 600;
    color: #057861;
    background: #fff;
    border-radius: 8px;
    text-decoration: none;
    transition: all 0.2s ease;
}

.dictionary-cta-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.dictionary-cta-btn svg {
    width: 16px;
    height: 16px;
}

/* -----------------------------------------
   Back to Archive Link
   ----------------------------------------- */
.dictionary-back-link {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 1.5rem;
    font-size: 0.875rem;
    color: #6c757d;
    text-decoration: none;
    transition: color 0.15s ease;
}

.dictionary-back-link:hover {
    color: var(--bs-primary, #088c76);
}

.dictionary-back-link svg {
    width: 16px;
    height: 16px;
    transition: transform 0.2s ease;
}

.dictionary-back-link:hover svg {
    transform: translateX(-3px);
}

/* -----------------------------------------
   Responsive Design
   ----------------------------------------- */
@media (max-width: 1100px) {
    .dictionary-words-grid {
        column-count: 3;
    }
}

@media (max-width: 991px) {
    .dictionary-single-layout {
        grid-template-columns: 1fr;
    }

    .dictionary-single-sidebar {
        order: -1;
    }

    .dictionary-sidebar-inner {
        position: static;
    }

    .dictionary-related-box {
        display: none;
    }

    .dictionary-words-grid {
        column-count: 3;
    }
}

@media (max-width: 768px) {
    .dictionary-archive-page {
        padding: 2rem 0 3rem;
    }

    .dictionary-alphabet-nav {
        flex-wrap: wrap;
        gap: 0.3rem;
        padding: 0.75rem;
        position: static;
    }

    .dictionary-alphabet-link {
        min-width: 32px;
        max-width: 38px;
        font-size: 0.8125rem;
    }

    .dictionary-words-grid {
        column-count: 2;
    }

    .dictionary-letter-heading {
        width: 40px;
        height: 40px;
        font-size: 1.25rem;
    }

    .dictionary-single-page {
        padding: 2rem 0 3rem;
    }

    .dictionary-word-title {
        font-size: 1.5rem;
    }
}

@media (max-width: 480px) {
    .dictionary-words-grid {
        column-count: 1;
    }

    .dictionary-alphabet-link {
        min-width: 26px;
        max-width: 32px;
        font-size: 0.75rem;
        border-radius: 6px;
    }
}

/* -----------------------------------------
   Print Styles
   ----------------------------------------- */
@media print {
    .dictionary-alphabet-nav,
    .dictionary-single-sidebar,
    .dictionary-cta-box {
        display: none;
    }

    .dictionary-single-layout {
        grid-template-columns: 1fr;
    }
}
