:root {
    --bg-color: #000000;
    --container-bg: #111111;
    --text-color: #ffffff;
    --nav-hover: #888888;
}

body.light-mode {
    --bg-color: #f4f4f4;
    --container-bg: #ffffff;
    --text-color: #1a1a1a;
    --nav-hover: #555555;
}

body {
    background-color: var(--bg-color);
    color: var(--text-color);
    font-family: 'Segoe UI', sans-serif;
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    transition: background-color 0.3s;
}

html,
body {
    margin: 0;
    padding: 0;
    background-color: #000;
}

/* Ensure the wrapper takes up the full screen height */
.app-wrapper {
    display: flex;
    align-items: flex-start;
    justify-content: center;
    min-height: 100vh;
    width: 100vw;
    box-sizing: border-box;
    /* Use ONLY left/right padding. No top padding. */
    padding: 0 80px;
    overflow-x: hidden;
}

/* Container for the whole app */
#appTitle {
    font-size: 1.8rem;
    font-weight: 700;
    margin: 2px;
    align-items: center;
}

.main-content {
    display: flex;
    flex-direction: row;
    gap: 40px;
    width: 100%;
    max-width: 1600px;
    /* Ensure internal columns align to the top of the main-content */
    align-items: flex-start;
}

.content-column {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
    /* Remove height: 100% if it was there */
}

.column-header {
    flex-shrink: 0;
    height: auto;
    display: flex;
    align-items: flex-end;
    /* This creates a tiny 10px gap from the browser edge */
    margin-top: 10px;
    margin-bottom: 5px;
}

.image-box {
    width: 100%;
    aspect-ratio: 1 / 1;
    /* This defines the "master" height */
    display: flex;
    align-items: center;
    justify-content: center;
}

.image-box img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

/* Updated container for the description */
.description-box {
    width: 100%;
    /* Remove the height: 0 and padding-bottom: 100% hacks */
    min-height: 400px;
    /* Gives it a base height */
    max-height: 90vh;
    /* Prevents it from getting too long on 4K */
    display: flex;
    flex-direction: column;
    background: var(--container-bg);
    border-radius: 12px;
    overflow: hidden;
    /* Clips anything trying to leak out */
    position: relative;
}

/* We need an inner wrapper to handle the actual text and scrolling */
.description-content {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    padding: 30px;
    overflow-y: auto;
    box-sizing: border-box;
    line-height: 1.7;
}

/* The actual text container */
#descriptionText {
    padding: 30px;
    line-height: 1.7;
    overflow-y: auto;
    /* Adds scrollbar only if text is long */
    overflow-x: hidden;
    /* STOPS THE RIGHT-SIDE LEAK */
    word-wrap: break-word;
    overflow-wrap: break-word;
    white-space: normal;
    transition: opacity 0.4s ease-in-out;
}

/* Ensure headings and paragraphs don't push the box wide */
#descriptionText h2,
#descriptionText p {
    max-width: 100%;
    margin-bottom: 1.2rem;
    color: var(--text-color);
}

#descriptionText h2 {
    color: #ffd700;
    /* Gold heading as requested */
}


/* Adjust Nav Buttons for large layout */
/* Floating Navigation Buttons */
.nav-btn {
    position: fixed;
    top: 45%;
    transform: translateY(-50%);
    background: rgba(128, 128, 128, 0.1);
    /* Very subtle background */
    color: var(--text-color);
    border: none;
    width: 60px;
    height: 100px;
    font-size: 2rem;
    cursor: pointer;
    z-index: 1000;
    opacity: 0.2;
    /* Semi-hidden by default */
    transition: opacity 0.3s, background 0.3s, transform 0.3s;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Hover state: bring them to life */
.nav-btn:hover {
    opacity: 1;
    background: rgba(128, 128, 128, 0.3);
    transform: translateY(-50%) scale(1.05);
}

/* Position them on the edges */
.nav-btn.prev {
    left: 20px;
}

.nav-btn.next {
    right: 20px;
}

/* Hide them on small screens or keep them at the bottom */
@media (max-width: 1024px) {
    .nav-btn {
        width: 50px;
        height: 70px;
        opacity: 0.5;
        /* More visible on touch devices */
    }
}

.controls {
    display: flex;
    gap: 12px;
    width: 100%;
    justify-content: flex-end;
    /* Keeps them pushed to the right */
    align-items: center;
}

.controls:hover {
    opacity: 1;
}

.controls button {
    background: #1a1a1a;
    /* Darker grey background for buttons */
    color: white;
    border: 1px solid #333;
    padding: 10px 15px;
    border-radius: 8px;
    cursor: pointer;
    font-weight: bold;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.3s;
}

.controls button:hover {
    background: #333;
}

#langBtn {
    min-width: 50px;
    /* Keeps button size consistent when text changes */
    font-size: 0.9rem;
}

/* Ensure the dropdown matches the button style */
#surahSelect {
    background: #1a1a1a;
    color: white;
    border: 1px solid #333;
    padding: 8px;
    border-radius: 6px;
}

/* Specifically target the Share SVG color */
#shareBtn svg {
    fill: var(--text-color);
}

/* Ensure the theme button text doesn't look too big compared to flags */
#themeBtn {
    font-size: 0.75rem;
    font-weight: bold;
    letter-spacing: 1px;
}

/* RESPONSIVE DESIGN: For Tablets and Phones */
@media (max-width: 900px) {
    .app-wrapper {
        height: auto;
        flex-direction: column;
    }

    .main-content {
        flex-direction: column;
        align-items: center;
    }

    .image-box,
    .description-box {
        width: 90vw;
        /* Occupy most of the width on mobile */
        height: auto;
        aspect-ratio: auto;
    }

    .nav-btn {
        position: fixed;
        bottom: 20px;
        z-index: 100;
        background: rgba(0, 0, 0, 0.5);
        border-radius: 50%;
    }
}

#quranImage {
    transition: opacity 0.4s ease-in-out;
    opacity: 1;
}

/* A helper class for when the image is swapping */
.fade-out {
    opacity: 0 !important;
}

#descriptionText {
    transition: opacity 0.4s ease-in-out;
}

/* Modal Background */
.modal {
    display: none;
    /* Hidden by default */
    position: fixed;
    z-index: 2000;
    /* High z-index to stay on top */
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.7);
    /* Black w/ opacity */
    backdrop-filter: blur(5px);
    /* Softens the background */
}

/* Modal Content Box */
.modal-content {
    font-size: 0.9rem;
    background-color: #1a1a1a;
    /* Match your dark theme */
    color: #EEEEEE;
    margin: 10% auto;
    padding: 30px;
    border: 1px solid #444;
    width: 80%;
    max-width: 500px;
    border-radius: 12px;
    position: relative;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
}

.modal-content a {
    color: #FFFFFF;
    font-weight: 700;
    text-decoration: none;
}

.close-btn {
    position: absolute;
    right: 20px;
    top: 15px;
    font-size: 28px;
    cursor: pointer;
    color: #888;
}

.close-btn:hover {
    color: white;
}

.video-container {
    position: relative;
    padding-bottom: 56.25%;
    /* 16:9 Aspect Ratio */
    height: 0;
    overflow: hidden;
    max-width: 100%;
    margin: 20px 0;
    border-radius: 8px;
    background: #000;
}

.video-container iframe {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
}