/* Responsive Styles for Quran DB V8 */

/* Mobile First Adjustments */
@media (max-width: 768px) {

    /* Sura Header */
    .wp-block-qdb-sura .sura_header .sura_header-inner {
        grid-template-columns: 1fr auto !important;
        grid-template-areas:
            "left right"
            "seal seal"
            "player player" !important;
        gap: 10px;
        padding: 1rem;
    }

    .wp-block-qdb-sura .sura_header-center {
        grid-area: left;
        display: flex;
        flex-direction: column;
        align-items: flex-start;
    }

    .wp-block-qdb-sura .sura_header-right {
        grid-area: right;
        justify-content: flex-end;
    }

    /* Shift header when drawer is open */
    .sura_header--shifted-for-drawer {
        top: var(--drawer-height, 0px) !important;
        transition: top 0.3s ease;
    }

    .wp-block-qdb-sura .sura_header-initials {
        grid-area: seal;
        justify-self: center;
        margin-top: 0.5rem;
    }

    /* Typography */
    .wp-block-qdb-sura .sura-phon {
        font-size: 1.25rem;
    }

    .wp-block-qdb-sura .sura-en {
        font-size: 1rem;
    }

    /* Controls Row */
    .qdb-controls-row {
        flex-direction: column;
        align-items: stretch;
        gap: 1rem;
    }

    .qdb-view,
    .qdb-font-controls {
        justify-content: center;
        width: 100%;
    }

    /* Verse List */
    .quran_aya {
        padding: 1rem 0;
    }

    .quran_ar {
        font-size: 1.5rem;
        /* Larger Arabic on mobile */
        line-height: 2.2;
    }

    .quran_en .ayah_en_text {
        font-size: 1rem;
        color: #000000 !important;
        /* Fix faint text issue */
    }

    /* Urdu: keep Nastaliq font and size on mobile */
    .quran_en .ayah_en_text[data-lang=ur] {
        font-family: 'Noto Nastaliq Urdu', 'Jameel Noori Nastaleeq', serif !important;
        line-height: 2.4 !important;
        direction: rtl !important;
        text-align: right !important;
    }

    /* Farsi: keep Scheherazade font and RTL on mobile */
    .quran_en .ayah_en_text[data-lang=fa] {
        font-family: 'Scheherazade New', serif !important;
        line-height: 2.0 !important;
        direction: rtl !important;
        text-align: right !important;
    }

    /* Compact Header for Small Screens (e.g. iPhone SE 375px) */
    @media (max-width: 400px) {
        .wp-block-qdb-sura .sura_header .sura_header-inner {
            padding: 0.5rem 0.75rem;
            grid-template-columns: 1fr auto !important;
            grid-template-areas:
                "left right"
                "seal seal"
                "player player" !important;
            gap: 4px;
        }

        .wp-block-qdb-sura .sura-num {
            font-size: 0.8em;
            /* Smaller sura number */
        }

        .wp-block-qdb-sura .sura-phon {
            font-size: 1.1rem;
            /* Compact phonetic name */
            margin-bottom: 0;
            line-height: 1.2;
        }

        .wp-block-qdb-sura .sura-en {
            font-size: 0.85rem;
            /* Compact English name */
            line-height: 1.2;
        }

        .wp-block-qdb-sura .sura_header-center {
            row-gap: 2px;
        }

        .wp-block-qdb-sura .sura_header-initials {
            margin-top: 0.25rem;
            font-size: 0.85rem;
        }

        /* Adjust sticky offset if needed or ensure search doesn't break */
        .quran-db-container:root {
            --qdb-sticky-offset: 120px;
            /* Reduced offset for compact header */
        }
    }
}

/* Dark Mode Support (Optional but good for "Premium") */
@media (prefers-color-scheme: dark) {
    .quran-db-container {
        --qdb-text: #e5e7eb;
        --qdb-bg: #1f2937;
    }

    .wp-block-qdb-sura {
        background-color: var(--qdb-bg);
        color: var(--qdb-text);
    }

    .qdb-controls-row {
        background-color: #374151;
        border-color: #4b5563;
        color: #f3f4f6;
    }

    .qdb-label {
        color: #f3f4f6;
    }
}

/* Global Search Visibility (Desktop & Mobile) */
/* Ensure header is sticky by default */
.sura_header {
    position: sticky !important;
    top: 0;
    /* Default position */
    z-index: 100;
    transition: top 0.3s ease;
}

body.qdb-search-active .sura_header {
    top: var(--qdb-drawer-height, 0px) !important;
    transition: top 0.3s ease;
}

/* Unified Controls Row */
.qdb-controls-row {
    display: flex;
    justify-content: space-between !important;
    /* Left and Right split */
    align-items: center;
    padding: 8px 15px !important;
    font-size: 13px !important;
    position: static !important;
    background-color: #f7f9fa;
    /* Light gray background */
    border: 1px solid #e5e7eb;
    border-radius: 6px;
    /* Rounded corners */
    width: 100%;
    box-sizing: border-box;
    margin-bottom: 10px;
}

/* Toggle Wrapper (Left) */
.qdb-view-toggle-wrapper {
    display: flex;
    align-items: center;
    gap: 8px;
}

/* Font Controls (Right) */
.qdb-font-controls {
    display: flex;
    align-items: center;
    gap: 8px;
}

/* Button Styling - Blue Outline */
.qdb-controls-row .button {
    padding: 2px 10px !important;
    font-size: 14px !important;
    line-height: 1.2 !important;
    min-height: auto !important;
    background: #fff !important;
    border: 1px solid #005a9c !important;
    /* Blue border */
    color: #005a9c !important;
    /* Blue text */
    border-radius: 4px !important;
    font-weight: 600 !important;
    cursor: pointer;
    transition: all 0.2s ease;
}

.qdb-controls-row .button:hover {
    background: #f0f7ff !important;
}

/* Dark mode adjustment if needed */
@media (prefers-color-scheme: dark) {
    .qdb-controls-row {
        background-color: var(--qdb-bg, #1f2937);
        border-color: #374151;
    }
}


/* Sura Meta Styling - Single Row Flow */
.sura_meta {
    display: flex;
    flex-wrap: wrap;
    /* Wraps naturally if space is tight */
    align-items: center;
    justify-content: center;
    width: 100%;
    margin-top: 10px;
    gap: 10px;
}

/* Unified Meta Chips - Direct Children */
.sura_meta>span {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    height: 32px;
    padding: 0 12px;
    background-color: #f0f4f8;
    border-radius: 4px;
    font-size: 14px;
    line-height: normal;
    color: #333;
    white-space: nowrap;
}

.sura_meta strong {
    margin-right: 5px;
    color: #0d5379;
}

/* Mobile adjustments */
@media (max-width: 768px) {
    .sura_meta {
        gap: 5px;
    }

    .sura_meta>span {
        font-size: 12px;
        height: 28px;
        padding: 0 8px;
    }
}