*, *::before, *::after {
    box-sizing: border-box;
}

:root {
    --header-height: 4rem;
}

header {
    height: var(--header-height);
    /* ... rest of your styles ... */
}

main {
    margin-top: var(--header-height);
    /* ... rest of your styles ... */
}

hr { color: #eee; margin: 1rem 0;     border: 0;
    border-top: 1px solid #eee;
    margin-bottom: 2rem;}

body { font-family: system-ui, sans-serif; line-height: 1.6; margin: 0; color: #333; padding-top: var(--header-height); }
header { height: var(--header-height); position: fixed; z-index: 1000; top:0; left:0; width: 100%; background: #f4f4f4; padding: 1rem; border-bottom: 1px solid #ddd; }
header a { text-decoration: none; }
nav { display: flex; justify-content: space-between; width: 100%; max-width: 1000px; margin: 0 auto; }
nav ul { display: flex; list-style: none; gap: 20px; margin: 0; padding: 0; }
nav ul li {
    margin: 0;
    /* Add a transparent border to everything */
    border-bottom: 2px solid transparent; 
    padding-bottom: 4px; /* Gives the flag some breathing room */
    display: flex;
    align-items: center;
}
nav ul .selected { border-bottom-color: black; }
nav ul img { height: 16px; }
main { max-width: 1000px; margin: 2rem auto; padding: 0 1rem; min-height: 60vh; }
footer { text-align: center; padding: 1rem; background: #333; color: white; margin-top: 4rem; }
.hero { display: flex; flex-direction: column; align-items: center; gap: 8px; text-align: center; margin-bottom: 1rem; }
.btn { background: #007bff; color: white; padding: 0.5rem 1rem; text-decoration: none; border-radius: 5px; }
.btn:hover { background: #006bff }
.book-card h4 { line-height: 0; }
.book-card h5 { line-height: 0; color: gray; }

.book-card-flex {
    display: flex;
    gap: 20px;
    align-items: start;
    justify-content: space-between;
}

.book-card-text {
    flex: 5; /* Takes up more space */
}

.book-card-image {
    flex: 1; /* Takes up less space */
    min-width: 100px; /* Ensures it doesn't get too squished */
}

.book-card-image img {
    width: 100%;
    height: auto;
    border-radius: 4px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

/* Responsive: Stack on small screens */
@media (max-width: 600px) {
    .book-card-flex {
        flex-direction: column-reverse;
        align-items: center; /* Center the content when stacked */
    }

    .book-card-image {
        width: 100%; /* Change from 120px to 100% */
        max-width: 250px; /* Limits size so it doesn't get TOO big */
        margin-bottom: 1.5rem;
    }

    .book-card-text {
        text-align: center; /* Optional: better look for mobile */
    }
}

.book-detail {
   padding-top: var(--header-height / 2); 
}


/* Layout Container */
.book-container {
    display: flex;
    gap: 1rem;
    align-items: start;
}

/* Fix for the Book Detail page specifically */
@media (max-width: 768px) {
    .book-container {
        flex-direction: column !important; /* Force stack */
        align-items: center;
    }

    .book-image {
        width: 100%;
        max-width: 300px; /* Keeps the detail cover a nice size */
        margin-bottom: 1rem;
    }
}

.book-image {
    flex: 1;
}

.book-image img {
    width: 100%;
    border-radius: 8px;
    box-shadow: 0 4px 15px rgba(0,0,0,0.1);
}

.book-info {
    flex: 2;
}

.price {
    font-size: 1.5rem;
    font-weight: bold;
    color: #2c3e50;
    margin: 10px 0;
}

.book-languages {
    margin-top: 1.5rem;
    text-align: center;
}
.lang-flags {
    display: flex;
    justify-content: center;
    gap: 15px;
    list-style: none;
    padding: 0;
}
.lang-flags img {
    height: 24px; /* Slightly larger for easier clicking */
    transition: transform 0.2s;
}
.lang-flags li.selected img {
    border-bottom: 3px solid #333;
    padding-bottom: 4px;
}
.lang-flags a:hover img {
    transform: scale(1.1);
}

/* Ensure RTL works for the book details */
[dir="rtl"] .book-container {
    flex-direction: row-reverse;
    text-align: right;
}

.opinions-section {
    margin-top: 2rem;
    padding-top: 1.5rem;
    border-top: 1px solid #eee;
}

.opinion-quote {
    font-style: italic;
    border-left: 4px solid #007bff;
    margin: 1.5rem 0;
    padding: 0.5rem 1rem;
    background: #f9f9f9;
    line-height: 1.4;
}

/* Flip the border for Arabic */
[dir="rtl"] .opinion-quote {
    border-left: none;
    border-right: 4px solid #007bff;
}

.related-books {
    margin-top: 3rem;
    padding-bottom: 2rem;
}

.related-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 20px;
}

.related-item {
    text-decoration: none;
    color: inherit;
    text-align: center;
    transition: transform 0.2s;
}

.related-item:hover {
    transform: translateY(-5px);
}

.related-item img {
    width: 100%;
    max-width: 120px;
    height: auto;
    border-radius: 4px;
    box-shadow: 0 4px 10px rgba(0,0,0,0.1);
    margin-bottom: 10px;
}

.related-item h4 {
    font-size: 0.9rem;
    margin: 0;
    line-height: 1.2;
}
