/* --- CSS VARIABLES --- */
:root {
    --primary: #2563eb; 
    --secondary: #f43f5e;
    --accent-pink: #eb2f5b; 
    --accent-green: #10b981;
    
    --gradient-main: linear-gradient(135deg, #2563eb 0%, #4f46e5 100%);
    --gradient-shop: linear-gradient(135deg, #0f172a 0%, #1e293b 100%);
    
    --bg-body: #f8fafc;
    --bg-card: #ffffff;
    --bg-glass: rgba(255, 255, 255, 0.95);
    --text-main: #1e293b;
    --text-muted: #64748b;
    --border: #e2e8f0;
    
    --radius: 12px;
    --shadow-sm: 0 4px 6px -1px rgba(0, 0, 0, 0.05);
    --shadow-lg: 0 20px 25px -5px rgba(0, 0, 0, 0.1);
    --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

[data-theme="dark"] {
    --bg-body: #0f172a;
    --bg-card: #1e293b;
    --bg-glass: rgba(15, 23, 42, 0.9);
    --text-main: #f1f5f9;
    --text-muted: #94a3b8;
    --border: #334155;
    --shadow-sm: 0 4px 6px -1px rgba(0, 0, 0, 0.3);
    --shadow-lg: 0 20px 25px -5px rgba(0, 0, 0, 0.5);
}

/* --- GLOBAL RESETS --- */
* { margin: 0; padding: 0; box-sizing: border-box; }

body {
    font-family: 'Plus Jakarta Sans', sans-serif;
    background-color: var(--bg-body);
    color: var(--text-main);
    line-height: 1.6;
    overflow-x: hidden;
    transition: background-color 0.3s ease, color 0.3s ease;
}

h1, h2, h3, h4 { color: var(--text-main); font-weight: 700; letter-spacing: -0.02em; }
a { text-decoration: none; color: inherit; transition: var(--transition); }
ul { list-style: none; }

/* SAFER IMAGE RESET: Only constrain max width by default */
img { 
    max-width: 100%; 
    height: auto; 
    display: block; 
}

/* --- HEADER & NAV --- */
.top-bar {
    background: #0f172a; color: white; padding: 8px 5%; font-size: 0.8rem;
    display: flex; justify-content: space-between; align-items: center; font-weight: 500;
}
.breaking-tag {
    background: var(--accent-pink); padding: 2px 10px; border-radius: 20px;
    font-weight: 700; font-size: 0.65rem; text-transform: uppercase; margin-right: 12px;
}

/* UPDATED SELECTOR: Targets specific class instead of all headers */
.site-header {
    background: var(--bg-glass); 
    padding: 0 5%; 
    position: sticky; 
    top: 0; 
    z-index: 1000;
    backdrop-filter: blur(12px); 
    border-bottom: 1px solid var(--border);
    transition: background-color 0.3s ease;
}

nav { display: flex; justify-content: space-between; align-items: center; height: 80px; }

.logo { 
    font-size: 1.8rem; font-weight: 800; font-family: 'Merriweather', serif;
    background: var(--gradient-main); -webkit-background-clip: text; -webkit-text-fill-color: transparent;
}
.nav-links { display: flex; gap: 25px; } 
.nav-links a { font-weight: 600; font-size: 0.9rem; position: relative; }
.nav-links a:hover { color: var(--primary); }
.nav-icons { display: flex; gap: 20px; align-items: center; font-size: 1.2rem; cursor: pointer; }

.menu-toggle { display: none; }
.cart-icon { position: relative; }
.cart-count {
    position: absolute; top: -8px; right: -8px;
    background: var(--accent-pink); color: white;
    font-size: 0.7rem; width: 18px; height: 18px;
    border-radius: 50%; display: flex; justify-content: center; align-items: center;
}

/* --- LAYOUT & STICKY SIDEBAR (UPDATED) --- */
.container {
    display: grid; 
    grid-template-columns: 2.8fr 1.2fr; 
    gap: 50px;
    padding: 40px 5%; 
    max-width: 1400px; 
    margin: 0 auto;
    position: relative;
    align-items: start; /* CRITICAL: Keeps sidebar at the top */
}

/* CRITICAL FIX: Prevent Grid Blowout */
main {
    min-width: 0; 
    width: 100%;
}

aside {
    position: sticky;
    top: 100px; 
    height: fit-content; 
}

.section-header {
    display: flex; justify-content: space-between; align-items: center;
    margin-bottom: 25px; padding-bottom: 15px; border-bottom: 2px solid var(--border);
}
.section-title { font-size: 1.4rem; position: relative; }
.section-title::after {
    content: ''; position: absolute; bottom: -17px; left: 0;
    width: 60px; height: 4px; background: var(--accent-pink); border-radius: 2px;
}

/* --- HERO CARD --- */
.modern-hero-wrapper {
    margin-bottom: 40px; border-radius: var(--radius); overflow: hidden;
    position: relative; box-shadow: var(--shadow-lg); height: 450px;
    width: 100%;
}
/* Force hero image to fill container strictly */
.modern-hero-wrapper img { 
    width: 100%; 
    height: 100%; 
    object-fit: cover; 
    transition: transform 0.6s;
}
.modern-hero-wrapper:hover img { transform: scale(1.05); }

.modern-hero-overlay {
    position: absolute; bottom: 0; left: 0; right: 0;
    background: linear-gradient(to top, rgba(0,0,0,0.9) 0%, rgba(0,0,0,0.5) 60%, transparent 100%);
    padding: 40px; display: flex; flex-direction: column; justify-content: flex-end;
}
.modern-hero-title { color: white; font-size: 2rem; margin-bottom: 10px; line-height: 1.3; text-shadow: 0 2px 4px rgba(0,0,0,0.5); }

/* --- NEWS LIST --- */
.modern-list-container { display: flex; flex-direction: column; }
.modern-list-item {
    display: flex; align-items: center; gap: 20px; padding: 20px 0;
    border-bottom: 1px solid var(--border);
    transition: transform 0.2s ease;
}
.modern-list-item:last-child { border-bottom: none; }

/* Thumbnails */
.list-thumb-wrapper {
    width: 150px; height: 100px; flex-shrink: 0; border-radius: var(--radius); overflow: hidden;
}
/* Force thumbnail to fill wrapper strictly */
.list-thumb-wrapper img { 
    width: 100%; 
    height: 100%; 
    object-fit: cover; 
    transition: 0.4s; 
}
.modern-list-item:hover .list-thumb-wrapper img { transform: scale(1.1); }

.item-title { font-size: 1.1rem; font-weight: 700; margin-bottom: 5px; line-height: 1.4; color: var(--text-main); }
.modern-list-item:hover .item-title { color: var(--primary); }
.item-meta { font-size: 0.8rem; color: var(--text-muted); display: flex; gap: 15px; }

/* Badges */
.category-badge {
    display: inline-flex; align-items: center; gap: 6px; font-size: 0.75rem;
    font-weight: 800; text-transform: uppercase; color: var(--accent-pink); margin-bottom: 8px;
}
.category-badge::before {
    content: ''; display: block; width: 8px; height: 8px;
    background-color: var(--accent-pink); border-radius: 50%;
}
.category-badge.hero-badge {
    color: #fff; background: var(--accent-pink); padding: 5px 15px; border-radius: 20px; width: fit-content;
}
.category-badge.hero-badge::before { display: none; }

/* --- SIDEBAR WIDGETS --- */
.sidebar-widget {
    background: var(--bg-card); padding: 25px; border-radius: var(--radius);
    margin-bottom: 30px; border: 1px solid var(--border);
}
.widget-title { font-size: 1.1rem; margin-bottom: 20px; border-left: 4px solid var(--accent-pink); padding-left: 15px; }
.trending-item { display: flex; align-items: center; margin-bottom: 15px; gap: 15px; }
.trending-img { width: 60px; height: 60px; border-radius: 8px; object-fit: cover; }

/* --- SHOP SECTION --- */
.shop-section h2, 
.shop-section h3, 
.shop-section h4 {
    color: white;
}
.shop-section {
    background: var(--gradient-shop); color: white; padding: 80px 5%; margin-top: 40px;
}
.shop-header { text-align: center; margin-bottom: 50px; }
.shop-grid {
    display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 30px;
}
.book-card {
    background: rgba(255,255,255,0.05); backdrop-filter: blur(10px);
    border: 1px solid rgba(255,255,255,0.1); padding: 25px; 
    border-radius: var(--radius); text-align: center; transition: var(--transition);
}
.book-card:hover { transform: translateY(-10px); background: rgba(255,255,255,0.1); }
.book-cover { 
    height: 200px; 
    width: 150px; 
    max-width: 100%; 
    /* Changed margin-bottom: 20px to this shorthand: */
    margin: 0 auto 20px auto; 
    box-shadow: 0 10px 20px rgba(0,0,0,0.3); 
    border-radius: 4px; 
}
.book-price { font-size: 1.4rem; color: var(--primary); font-weight: 800; display: block; margin-bottom: 15px; }
.btn-shop {
    background: var(--accent-pink); color: white; padding: 10px 25px; border-radius: 30px; font-weight: 700; display: inline-block;
}

/* --- FOOTER --- */
footer {
    background: #0f172a; color: #cbd5e1; padding: 70px 5% 30px; font-size: 0.95rem;
}
.footer-grid {
    display: grid; grid-template-columns: 1.5fr 1fr 1fr; gap: 50px; padding-bottom: 50px; border-bottom: 1px solid #334155;
}
.footer-col h3 { color: white; font-size: 1.1rem; margin-bottom: 25px; }
.footer-col a { color: #cbd5e1; display: block; margin-bottom: 12px; transition: color 0.2s; }
.footer-col a:hover { color: var(--accent-pink); }
.social-icons a {
    display: inline-block; width: 40px; height: 40px; line-height: 40px; text-align: center;
    border-radius: 50%; border: 1px solid #334155; margin-right: 10px;
}
.social-icons a:hover { background: var(--accent-pink); border-color: var(--accent-pink); color: white; }
.copyright { text-align: center; padding-top: 30px; font-size: 0.85rem; color: #64748b; }

/* --- HEADER SEARCH (New) --- */
.header-search-wrapper {
    position: relative; /* Anchor for absolute positioning */
    display: flex;
    align-items: center;
    margin-right: 15px;
}

/* Toggle Button (The Magnifying Glass) */
.search-toggle-btn {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 1.1rem;
    /* CHANGE THIS LINE: Use --text-main instead of --text-color */
    color: var(--text-main); 
    padding: 5px;
    z-index: 10; 
}

/* --- Search Form (Hidden State) --- */
.search-form {
    display: flex;
    align-items: center;
    background: #fff;
    border: 1px solid #ddd;
    border-radius: 25px;
    padding: 0; /* Zero padding when closed */
    
    /* Animation Properties */
    position: absolute;
    right: 0;
    width: 0; /* Start hidden */
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease-in-out;
    overflow: hidden;
    z-index: 20;
}

/* --- Search Form (Active/Open State) --- */
.header-search-wrapper.active .search-form {
    width: 250px; /* Width when open */
    opacity: 1;
    visibility: visible;
    padding: 5px 15px;
    box-shadow: 0 4px 15px rgba(0,0,0,0.1);
}

/* Hide the toggle button when search is open */
.header-search-wrapper.active .search-toggle-btn {
    opacity: 0;
    pointer-events: none;
}

/* Input Styling */
.search-input {
    border: none;
    background: transparent;
    outline: none;
    width: 100%;
    font-size: 0.95rem;
    color: #333;
}

/* Close "X" Button */
.search-close-btn {
    background: none;
    border: none;
    cursor: pointer;
    color: #999;
    font-size: 0.9rem;
    margin-left: 5px;
}
.search-close-btn:hover { color: #f00; }

/* --- Live Results Dropdown --- */
.live-search-dropdown {
    position: absolute;
    top: 100%;
    right: 0;
    width: 300px;
    background: #fff;
    border-radius: 8px;
    box-shadow: 0 5px 20px rgba(0,0,0,0.15);
    z-index: 1000;
    margin-top: 15px;
    display: none;
}

.live-search-dropdown:not(:empty) {
    display: block;
}

/* --- LIVE SEARCH RESULTS STYLING --- */
#search-results-container {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    width: 100%;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 0 0 8px 8px;
    box-shadow: var(--shadow-lg);
    z-index: 1000;
    max-height: 400px;
    overflow-y: auto;
    margin-top: 2px;
}

.live-search-item {
    display: flex;
    align-items: center;
    padding: 10px;
    border-bottom: 1px solid var(--border);
    text-decoration: none;
    color: var(--text-main);
    transition: background-color 0.2s;
}

.live-search-item:last-child { border-bottom: none; }
.live-search-item:hover { background-color: var(--bg-body); }

.live-search-thumb {
    width: 50px; height: 50px; object-fit: cover;
    border-radius: 4px; margin-right: 12px;
    background-color: var(--border); flex-shrink: 0;
}

.live-search-content { flex: 1; min-width: 0; }

.live-search-content h4 {
    margin: 0 0 4px 0; font-size: 0.9rem; font-weight: 700;
    color: var(--text-main); line-height: 1.2;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

.live-search-meta { font-size: 0.75rem; color: var(--text-muted); }

.live-search-footer {
    display: block; text-align: center; padding: 10px;
    background-color: var(--bg-body); color: var(--primary);
    font-weight: 600; font-size: 0.85rem; text-decoration: none;
    border-top: 1px solid var(--border);
}
.live-search-footer:hover { text-decoration: underline; opacity: 0.9; }

.no-results {
    padding: 15px; text-align: center; color: var(--text-muted);
    font-style: italic; font-size: 0.9rem;
}

/* --- LOGO TOGGLE FIX --- */
.nav-logo { display: flex; align-items: center; }
.logo-light { display: block; max-height: 20px; width: auto; }
.logo-dark { display: none; max-height: 20px; width: auto; }

[data-theme="dark"] .logo-light { display: none !important; }
[data-theme="dark"] .logo-dark { display: block !important; }

/* --- RESPONSIVE FIXES (UPDATED) --- */
@media (max-width: 992px) {
    .container { 
        grid-template-columns: 1fr; /* Stack columns on mobile */
        gap: 40px;
    }
    
    aside { 
        position: static; 
        width: 100%; 
        margin-top: 20px;
    }
    
    .nav-links { 
        display: none; position: absolute; top: 80px; left: 0; width: 100%;
        background: var(--bg-card); flex-direction: column; padding: 20px;
        box-shadow: 0 10px 20px rgba(0,0,0,0.1);
    }
    .nav-links.active { display: flex; }
    .menu-toggle { display: block; }
}

@media (max-width: 768px) {
    .top-bar { display: none; }
    .modern-hero-wrapper { height: 300px; }
    .modern-hero-title { font-size: 1.4rem; }
    .modern-list-item { align-items: flex-start; }
    .footer-grid { grid-template-columns: 1fr; }

    /* Header Search Mobile */
    .header-search-wrapper.active { position: static; }
    .header-search-wrapper.active .search-form {
        position: fixed; top: 60px; left: 5%; width: 90%; z-index: 1001;
    }
    .live-search-dropdown {
        position: fixed; top: 110px; left: 5%; width: 90%; z-index: 1000;
    }
}

/* --- CUSTOM BLOG LOAD MORE BUTTON --- */
.btn-load-more {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 12px 35px;
    border-radius: 50px;       /* Fully rounded pill shape */
    font-weight: 700;
    font-size: 1rem;
    text-decoration: none;
    transition: all 0.3s ease;
    cursor: pointer;
    
    /* Light Mode Default */
    background-color: transparent;
    border: 2px solid var(--primary); /* Uses your site's blue */
    color: var(--primary);            /* Text matches border */
}

/* Hover Effect (Fills with Blue) */
.btn-load-more:hover {
    background-color: var(--primary);
    color: #ffffff;
    transform: translateY(-3px);      /* Slight lift effect */
    box-shadow: 0 5px 15px rgba(37, 99, 235, 0.25); /* Subtle shadow */
}

/* Dark Mode Specifics */
/* Ensures the button glows slightly more against the dark background */
[data-theme="dark"] .btn-load-more:hover {
    box-shadow: 0 5px 15px rgba(37, 99, 235, 0.4);
}