/* --- 1. VARIABLEN & GRUNDSTEUERUNG --- */
:root { 
    --sidebar-width: 240px; 
    --primary: #9575CD; 
    --primary-dark: #7E57C2;
    --primary-light: #F3E5F5; 
    --text: #333;
    --bg: #f8f9fa;
    --white: #ffffff;
    --border: #eeeeee;
}

/* DARK MODE FARBEN */
body.dark-mode {
    --bg: #121212;
    --white: #1e1e1e;
    --text: #e0e0e0;
    --border: #333;
    --primary-light: #311b92;
}

body { 
    font-family: 'Segoe UI', system-ui, -apple-system, sans-serif; 
    background: var(--bg); 
    margin: 0; 
    display: flex; 
    color: var(--text); 
    line-height: 1.5;
}

/* --- 2. LUCIDE ICONS ALLGEMEIN --- */
.lucide {
    width: 20px;
    height: 20px;
    stroke-width: 1.2; 
    display: inline-block;
    vertical-align: middle;
    margin-right: 12px;
    transition: stroke 0.3s ease;
}

/* Spezialfall: Keine Ergebnisse Icon */
#noResults .lucide {
    color: var(--primary);
    opacity: 0.5;
    margin-right: 0;
}

/* --- 3. SLOGAN & INFO-TRIGGER (FIXED) --- */
.slogan-container { 
    display: flex; 
    align-items: center; 
    gap: 8px; 
    margin-top: 10px; 
    color: #666; 
}

.info-trigger {
    background: none !important;
    border: none !important;
    padding: 6px !important;
    margin: 0 !important;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: var(--primary);
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    border-radius: 50%;
    opacity: 0.6;
    outline: none;
}

.info-trigger:hover {
    opacity: 1;
    transform: scale(1.2);
    background-color: var(--primary-light) !important;
}

.info-trigger .lucide {
    width: 18px;
    height: 18px;
    margin: 0; /* Kein margin-right für zentrierte Icons im Button */
    stroke-width: 2;
}

/* Container-Steuerung */
.header-with-image {
    display: flex;
    align-items: center; /* Richtet Bild und Text mittig aneinander aus */
    gap: 25px;           /* Abstand zwischen Bild und Text */
}

/* Bild-Steuerung */
.header-logo {
    width: 100px;        /* Breite anpassen */
    height: auto;        /* Proportional skalieren */
    object-fit: contain;
    flex-shrink: 0;      /* Verhindert, dass das Bild gequetscht wird */
}

.header-text h1 {
    margin: 0;           /* Entfernt den Standardabstand */
}

/* Mobile Optimierung: Jetzt NEBENEINANDER statt untereinander */
@media (max-width: 600px) {
    .header-with-image {
        flex-direction: row;      /* Erzwingt, dass es nebeneinander bleibt */
        align-items: center;      /* Vertikale Zentrierung */
        gap: 15px;                /* Etwas weniger Abstand auf schmalen Screens */
        padding-bottom: 10px;
    }

    .header-logo {
        width: 60px;              /* Logo auf dem Handy etwas kleiner machen */
    }

    .header-text h1 {
        font-size: 1.5rem;        /* Schriftgröße der Headline etwas reduzieren */
    }

    .slogan-container span {
        font-size: 0.85rem;       /* Slogan etwas kleiner, damit alles passt */
    }
}

/* --- 4. SIDEBAR (DESKTOP) --- */
aside { 
    width: var(--sidebar-width); 
    background: var(--white); 
    border-right: 1px solid var(--border); 
    height: 100vh; 
    position: fixed; 
    padding: 25px 20px; 
    box-sizing: border-box; 
    overflow-y: auto;
    z-index: 1000;
}

.genre-list { list-style: none; padding: 0; margin: 0; }
.genre-list li { margin-bottom: 5px; }
.genre-list a { 
    text-decoration: none; 
    color: var(--text); 
    display: flex; 
    align-items: center; 
    padding: 10px 15px; 
    border-radius: 8px; 
    font-size: 0.95rem; 
    transition: 0.2s;
}

.genre-list a:hover, .genre-list a.active { 
    background: var(--primary-light) !important; 
    color: var(--primary) !important; 
    font-weight: bold; 
}

/* --- 5. MAIN CONTENT --- */
main { flex: 1; margin-left: var(--sidebar-width); padding: 40px; min-width: 0; }

.page-header { 
    margin-bottom: 40px; 
    border-bottom: 2px solid var(--primary-light); 
    padding-bottom: 20px; 
}

.page-header h1 { margin: 0; font-size: 2.5rem; color: var(--text); }

/* SUCHE */
#bookSearch {
    width: 100%; 
    max-width: 600px; 
    padding: 15px; 
    border-radius: 10px; 
    border: 1px solid var(--border); 
    font-size: 1rem; 
    box-shadow: 0 2px 5px rgba(0,0,0,0.05);
    background: var(--white);
    color: var(--text);
}

/* GRID & CARDS */
.grid { 
    display: grid; 
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); 
    gap: 25px; 
}

.card { 
    background: var(--white); 
    border-radius: 12px; 
    padding: 20px; 
    border: 1px solid var(--border);
    box-shadow: 0 3px 10px rgba(0,0,0,0.05); 
    display: flex; 
    flex-direction: column;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.card:hover { transform: translateY(-5px); box-shadow: 0 10px 20px rgba(0,0,0,0.1); }
.card img { width: 100%; height: 180px; object-fit: contain; margin-bottom: 15px; }

/* BUTTONS */
.buy-button {
    background: var(--primary); color: white; border: none; padding: 10px; 
    border-radius: 8px; cursor: pointer; font-weight: bold; font-size: 0.9rem; 
    transition: 0.3s; width: 100%; margin-top: 10px;
}
.buy-button:hover { background: var(--primary-dark); }

@media (min-width: 769px) {
    .buy-button { opacity: 0; visibility: hidden; }
    .card:hover .buy-button { opacity: 1; visibility: visible; }
}

/* --- 6. MODALS & FORMS --- */
.modal {
    display: none; position: fixed; z-index: 4000; left: 0; top: 0; width: 100%; height: 100%;
    background: rgba(0,0,0,0.6); backdrop-filter: blur(3px); align-items: center; justify-content: center;
    padding: 20px; box-sizing: border-box;
}


.modal-content {  
    background: var(--white); 
    padding: 30px; 
    border-radius: 15px; 
    max-width: 550px; 
    width: 100%;  
    max-height: 90vh; 
    overflow-y: auto; 
    position: relative; /* WICHTIG für die Positionierung des Buttons */
    box-shadow: 0 5px 30px rgba(0,0,0,0.3);
}

.close-modal {
    position: absolute;
    top: 15px;
    right: 15px;
    width: 36px;
    height: 36px;
    background: var(--bg);
    color: var(--text);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
    z-index: 10;
    border: 1px solid var(--border);
    padding: 0; /* Verhindert Verschiebungen */
}

.close-modal:hover {
    background: var(--primary-light);
    color: var(--primary);
    transform: rotate(90deg); /* Kleiner visueller Effekt beim Hover */
}

.close-modal .lucide {
    margin-right: 0 !important;
}

/* Smartphone-Optimierung für das Modal */
@media (max-width: 768px) {
    .close-modal {
        top: 10px;
        right: 10px;
        width: 40px; /* Noch etwas griffiger für Touch-Bedienung */
        height: 40px;
    }
}

.order-form-container { background: var(--bg); padding: 20px; border-radius: 10px; margin-top: 15px; border: 1px solid var(--border); }

input, textarea, select { 
    width: 100%; padding: 12px; margin-bottom: 10px; border: 1px solid var(--border); border-radius: 8px; box-sizing: border-box; font-family: inherit;
    background: var(--white); color: var(--text);
}

/* Standard-Farbe für Texte im Modal (Light Mode) */
.modal-content p {
    color: #444; 
}

/* Automatische Anpassung im Dark Mode */
body.dark-mode .modal-content p {
    color: var(--text); /* Nutzt dann dein helles #e0e0e0 */
}

/* Optional: Auch die Überschriften im Order-Form anpassen */
body.dark-mode .order-form-container h4 {
    color: var(--text);
}

/* --- 7. NAVIGATION DRAWER & TOGGLE --- */
.nav-drawer {
    position: fixed; top: 0; right: -300px; width: 300px; height: 100vh;
    background: var(--white); z-index: 2500; box-shadow: -5px 0 25px rgba(0,0,0,0.1);
    transition: 0.4s cubic-bezier(0.4, 0, 0.2, 1); padding: 80px 30px; box-sizing: border-box;
}
.nav-drawer.open { right: 0; }
.nav-drawer ul { list-style: none; padding: 0; }
.nav-drawer li { margin-bottom: 20px; }
.nav-drawer a { text-decoration: none; color: var(--text); font-size: 1.1rem; font-weight: 500; transition: 0.2s; display: flex; align-items: center; }
.nav-drawer a:hover { color: var(--primary); padding-left: 10px; }

.mode-toggle {
    background: var(--white); border: 1px solid var(--border); color: var(--text);
    padding: 10px 18px; border-radius: 25px; cursor: pointer; width: 100%;
    display: flex; align-items: center; justify-content: center; gap: 10px; font-weight: 500; transition: 0.3s;
}

.menu-overlay {
    position: fixed; top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(0,0,0,0.3); z-index: 2400; display: none; backdrop-filter: blur(2px);
}

/* --- 8. MOBILE RESPONSIVENESS (FIXED) --- */
@media (max-width: 768px) {
    aside {
        position: fixed; top: 60px; left: 0; width: 100%; height: auto;
        border-right: none; border-bottom: 1px solid var(--border); padding: 0; z-index: 1000;
    }

    .category-toggle {
        display: flex; justify-content: space-between; align-items: center;
        padding: 15px 20px; cursor: pointer; font-weight: 600; color: var(--primary);
    }

    .genre-list { display: none; padding: 0 10px 15px 10px; max-height: 300px; overflow-y: auto; }
    aside.open .genre-list { display: block; }

    main { margin-left: 0; margin-top: 110px; padding: 20px; }
    .page-header h1 { font-size: 1.8rem; }
    .grid { grid-template-columns: 1fr; }

    .mobile-header {
        position: fixed; top: 0; left: 0; width: 100%; height: 60px;
        background: var(--primary); color: white; display: flex;
        align-items: center; justify-content: space-between; padding: 0 20px;
        box-sizing: border-box; z-index: 2001; box-shadow: 0 2px 10px rgba(0,0,0,0.1);
    }

    .menu-trigger {
        display: flex !important;
        align-items: center !important;
        justify-content: center !important;
        color: white !important;
        background: rgba(255, 255, 255, 0.2) !important; 
        width: 42px !important;
        height: 42px !important;
        border-radius: 50% !important;
        padding: 0 !important;
        border: none !important;
    }

    .menu-trigger .lucide {
        margin: 0 !important;
        stroke-width: 2.5;
    }
    
    .menu-trigger:active {
        background: rgba(255, 255, 255, 0.4) !important;
        transform: scale(0.9);
    }
    
    body.dark-mode .mobile-header { background: var(--white); border-bottom: 1px solid var(--border); }
}

/* --- 9. DESKTOP OPTIMIERUNG --- */
@media (min-width: 769px) {
    .mobile-header { background: transparent !important; box-shadow: none !important; pointer-events: none; }
    .mobile-header div:first-child { display: none !important; }

    .menu-trigger {
        display: flex !important;
        align-items: center !important;
        justify-content: center !important;
        position: fixed !important;
        top: 25px;
        right: 25px;
        z-index: 3000;
        width: 48px !important;
        height: 48px !important;
        background: var(--white) !important;
        border-radius: 50% !important;
        box-shadow: 0 4px 12px rgba(0,0,0,0.15);
        color: var(--text) !important;
        cursor: pointer !important;
        pointer-events: auto !important; /* REAKTIVIERT DEN KLICK */
        transition: transform 0.2s ease;
        padding: 0 !important;
    }

    .menu-trigger .lucide {
        margin: 0 !important;
        width: 24px;
        height: 24px;
    }

    .menu-trigger:hover {
        transform: scale(1.1);
        color: var(--primary) !important;
    }

    .category-toggle { display: none !important; }
}

/* --- ANIMATIONEN --- */
@keyframes pulse-once {
    0% { transform: scale(1); }
    50% { transform: scale(1.15); }
    100% { transform: scale(1); }
}

.menu-trigger .lucide {
    animation: pulse-once 1s ease-in-out 2;
}

#backToTop {
    position: fixed;
    bottom: 30px;
    right: 30px;
    width: 48px;
    height: 48px;
    background: var(--primary);
    color: white;
    border: 0px solid var(--white); /* Feiner weißer Rand zur Abgrenzung */
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2000;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);

    /* DER GLOW-EFFEKT: 
       1. Schatten: Normale Tiefe 
       2. Schatten: Ein weicher lila Glow (angepasst an deine Primärfarbe) */
    box-shadow: 
        0 8px 20px rgba(0,0,0,0.2), 
        inset 0 1px 3px rgba(255,255,255,0.3);
}

#backToTop.show {
    opacity: 1;
    visibility: visible;
}

#backToTop:hover {
    background: var(--primary-dark);
    transform: translateY(-5px);
    /* Beim Hover wird nur der Schatten etwas weicher und tiefer */
    box-shadow: 
        0 12px 25px rgba(0,0,0,0.25),
        inset 0 1px 3px rgba(255,255,255,0.4);
}

#backToTop::after {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    border-radius: 50%;
    /* Ein hauchzarter lila Schein, der nur minimal übersteht */
    box-shadow: 0 0 15px var(--primary);
    opacity: 0.2;
    z-index: -1;
}

/* Verhindert, dass das Icon im Button verschoben wird */
#backToTop .lucide {
    margin: 0 !important;
    stroke-width: 3; /* Etwas dickere Linie für bessere Sichtbarkeit */
}

@media (max-width: 768px) {
    #backToTop {
        bottom: 20px;
        right: 20px;
        width: 44px;
        height: 44px;
        /* Etwas transparenter, wenn er über Text liegt */
        opacity: 0.9; 
    }
}

/* Korrektur für Buchbeschreibungen und Texte im Modal */
body.dark-mode .modal-content {
    color: var(--text); /* Erzwingt das helle e0e0e0 */
}

body.dark-mode .modal-content p, 
body.dark-mode .modal-content div {
    color: var(--text);
}

/* Falls du spezifisch die Beschreibung im Modal ansprichst: */
.modal-description {
    color: #666; /* Standard für Light Mode */
    line-height: 1.6;
}

body.dark-mode .modal-description {
    color: var(--text); /* Korrektur für Dark Mode */
}