/**
 * Ronin Bestseller - Frontend Styles
 * Version: 1.2.1 - "Bereits hinzugefügt" Button States
 * 
 * Design by UI/UX Lead:
 * - Glassmorphism wie Adventskalender
 * - Quadratische Bilder (1:1)
 * - Grüner Button (Ronin Brand Color #004d40)
 * - Responsive 4→3→2→1 Spalten
 * - Toast-Notification (oben mittig)
 * - Error-Modal-System
 * - "Alle kaufen" Section
 */

/* ===================================
   WRAPPER MIT HINTERGRUNDBILD
   =================================== */

.ronin-bestseller-wrapper {
    width: 100%;
    max-width: 100%;
    padding: 60px 20px;
    background-image: url('https://www.ronin-hoerverlag.de/wp-content/uploads/2025/01/ronin-hoerverlag-neuerscheinung.webp');
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    position: relative;
    min-height: 600px;
}

/* Dunkler Overlay über Hintergrundbild */
.ronin-bestseller-wrapper::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.4);
    z-index: 0;
}

/* ===================================
   GRID LAYOUT
   =================================== */

.ronin-bestseller-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 2rem;
    padding: 2rem 0;
    max-width: 1400px;
    margin: 0 auto;
    
    /* Über dem Overlay */
    position: relative;
    z-index: 1;
}

/* ===================================
   GLASSMORPHISM PRODUKT-KARTE
   =================================== */

.bestseller-product-card {
    /* Glassmorphism Effekt (wie Adventskalender) */
    background: rgba(255, 255, 255, 0.15);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.3);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.37);
    
    border-radius: 12px;
    padding: 1.5rem;
    text-align: center;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    
    /* Flexbox für vertikale Anordnung */
    display: flex;
    flex-direction: column;
    gap: 1rem;
    
    /* Relative für Gradient-Overlay */
    position: relative;
    overflow: hidden;
}

/* Gradient Overlay (abwechselnd Rot/Grün) */
.bestseller-product-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(135deg, rgba(208, 0, 0, 0.3), rgba(0, 77, 64, 0.3));
    z-index: 0;
    border-radius: 12px;
    transition: opacity 0.3s ease;
}

/* Abwechselnder Gradient */
.bestseller-product-card:nth-child(even)::before {
    background: linear-gradient(135deg, rgba(0, 77, 64, 0.3), rgba(208, 0, 0, 0.3));
}

/* Hover: Gradient intensiver */
.bestseller-product-card:hover::before {
    opacity: 0.7;
}

/* Hover: Card lift */
.bestseller-product-card:hover {
    transform: translateY(-8px);
    box-shadow: 0 16px 40px rgba(0, 0, 0, 0.5);
}

/* Alle Elemente über dem Gradient */
.bestseller-product-card > * {
    position: relative;
    z-index: 2;
}

/* ===================================
   PRODUKTBILD (QUADRATISCH)
   =================================== */

.bestseller-product-card .product-image {
    width: 100%;
    height: auto;
    aspect-ratio: 1/1; /* QUADRATISCH statt 2/3 */
    object-fit: cover;
    border-radius: 8px;
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.5); /* Mehr Kontrast auf Glassmorphism */
    transition: transform 0.3s ease;
}

.bestseller-product-card:hover .product-image {
    transform: scale(1.02);
}

/* ===================================
   PRODUKTTITEL (WEISS FÜR DUNKLEN HINTERGRUND)
   =================================== */

.bestseller-product-card .product-title {
    font-size: 1.1rem;
    font-weight: 600;
    line-height: 1.4;
    color: #ffffff; /* WEISS statt schwarz */
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.8); /* Lesbarkeit */
    margin: 0.5rem 0;
    min-height: 3em; /* Platz für 2-zeilige Titel */
    
    /* Typografie */
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    
    /* Text-Overflow Handling */
    overflow: hidden;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
}

/* ===================================
   BUTTON (GRÜN - RONIN BRAND)
   =================================== */

.bestseller-add-to-cart {
    /* Grüner Gradient (Ronin Brand Color) */
    background: linear-gradient(135deg, #00695c 0%, #004d40 100%);
    color: #ffffff;
    border: none;
    padding: 0.875rem 1.5rem;
    font-size: 1rem;
    font-weight: 600;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    width: 100%;
    
    /* Mehr Shadow für Kontrast auf Glassmorphism */
    box-shadow: 0 6px 16px rgba(0, 77, 64, 0.5);
    
    /* Typografie */
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    letter-spacing: 0.02em;
    text-transform: none;
    
    /* Flexbox für Icon/Text */
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
}

.bestseller-add-to-cart:hover {
    background: linear-gradient(135deg, #00897b 0%, #00695c 100%);
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(0, 77, 64, 0.6); /* Noch mehr Kontrast bei Hover */
}

.bestseller-add-to-cart:active {
    background: #004d40;
    transform: translateY(0);
    box-shadow: 0 4px 12px rgba(0, 77, 64, 0.5);
}

.bestseller-add-to-cart:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
    box-shadow: 0 4px 12px rgba(0, 77, 64, 0.3);
}

/* NEU v1.2.1: "Bereits hinzugefügt" Button State */
.bestseller-in-cart {
    background: rgba(0, 0, 0, 0.1) !important;
    color: #666 !important;
    cursor: not-allowed !important;
    box-shadow: none !important;
}

.bestseller-in-cart:hover {
    background: rgba(0, 0, 0, 0.1) !important;
    transform: none !important;
    box-shadow: none !important;
}

/* Loading State */
.bestseller-add-to-cart.is-loading {
    position: relative;
    color: transparent;
}

.bestseller-add-to-cart.is-loading::after {
    content: '';
    position: absolute;
    width: 16px;
    height: 16px;
    top: 50%;
    left: 50%;
    margin-left: -8px;
    margin-top: -8px;
    border: 2px solid #ffffff;
    border-radius: 50%;
    border-top-color: transparent;
    animation: spinner 0.6s linear infinite;
}

@keyframes spinner {
    to { transform: rotate(360deg); }
}

/* ===================================
   STATUS-MELDUNGEN
   =================================== */

.ronin-bestseller-inactive,
.ronin-bestseller-empty {
    text-align: center;
    padding: 3rem 1rem;
    font-size: 1.125rem;
    color: #ffffff; /* Weiss auf dunklem Hintergrund */
    background: rgba(255, 255, 255, 0.15);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.3);
    border-radius: 8px;
    margin: 2rem auto;
    max-width: 600px;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.8);
}

/* ===================================
   RESPONSIVE DESIGN
   =================================== */

/* Tablet (3 Spalten) */
@media (max-width: 1199px) {
    .ronin-bestseller-grid {
        grid-template-columns: repeat(3, 1fr);
        gap: 1.5rem;
    }
}

/* Mobile Landscape (2 Spalten) */
@media (max-width: 767px) {
    .ronin-bestseller-wrapper {
        padding: 40px 15px;
    }
    
    .ronin-bestseller-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 1rem;
        padding: 1rem 0;
    }
    
    .bestseller-product-card {
        padding: 1rem;
    }
    
    .bestseller-product-card .product-title {
        font-size: 1rem;
        min-height: 2.8em;
    }
    
    .bestseller-add-to-cart {
        padding: 0.75rem 1rem;
        font-size: 0.9rem;
    }
}

/* Mobile Portrait (1 Spalte) */
@media (max-width: 480px) {
    .ronin-bestseller-wrapper {
        padding: 30px 10px;
    }
    
    .ronin-bestseller-grid {
        grid-template-columns: 1fr;
    }
    
    .bestseller-product-card {
        max-width: 400px;
        margin: 0 auto;
    }
}

/* ===================================
   ACCESSIBILITY
   =================================== */

/* Fokus-State für Tastaturnavigation */
.bestseller-add-to-cart:focus {
    outline: 3px solid #00897b;
    outline-offset: 2px;
}

/* Reduced Motion für barrierefreie Nutzung */
@media (prefers-reduced-motion: reduce) {
    .bestseller-product-card,
    .bestseller-add-to-cart,
    .product-image,
    .bestseller-product-card::before {
        transition: none;
    }
    
    .bestseller-product-card:hover {
        transform: none;
    }
    
    .bestseller-add-to-cart:hover {
        transform: none;
    }
}

/* High Contrast Mode */
@media (prefers-contrast: high) {
    .bestseller-product-card {
        border: 2px solid #ffffff;
    }
    
    .bestseller-add-to-cart {
        border: 2px solid #ffffff;
    }
}

/* ===================================
   BROWSER-FALLBACKS
   =================================== */

/* Safari < 15.4 (kein backdrop-filter Support) */
@supports not (backdrop-filter: blur(10px)) {
    .bestseller-product-card {
        background: rgba(255, 255, 255, 0.25); /* Etwas opaker als Fallback */
    }
}

/* ===================================
   TOAST-NOTIFICATION
   =================================== */

.ronin-toast {
    position: fixed;
    top: 20px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 9999;
    
    /* Layout */
    max-width: 500px;
    padding: 20px 24px;
    display: flex;
    align-items: flex-start;
    gap: 16px;
    
    /* Glassmorphism */
    background: rgba(255, 255, 255, 0.15);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.3);
    border-left: 4px solid #004d40; /* Ronin-Grün */
    border-radius: 12px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.37);
    
    /* Animation */
    animation: slideDown 0.3s ease-out;
}

.ronin-toast-icon {
    flex-shrink: 0;
    width: 36px;
    height: 36px;
}

.ronin-toast-icon svg {
    width: 100%;
    height: 100%;
    filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.3));
}

.ronin-toast-content {
    flex: 1;
    color: #ffffff;
}

.ronin-toast-title {
    font-size: 1rem;
    font-weight: 600;
    margin-bottom: 4px;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.8);
}

.ronin-toast-info {
    font-size: 0.9rem;
    font-weight: 400;
    color: rgba(255, 255, 255, 0.9);
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.8);
}

.ronin-toast-link {
    display: inline-block;
    margin-top: 8px;
    color: #00897b;
    font-weight: 600;
    font-size: 0.9rem;
    text-decoration: underline;
    transition: color 0.2s;
}

.ronin-toast-link:hover {
    color: #00bfa5;
}

/* Fade-out Animation */
.ronin-toast-fadeout {
    animation: fadeOut 0.5s ease-in forwards;
}

/* NEU v1.2.1: Info-Toast (Blauer Border für "Bereits im Warenkorb") */
.ronin-toast-info {
    border-left-color: #2196F3; /* Blau statt Grün */
}

/* Animationen */
@keyframes slideDown {
    from {
        top: -100px;
        opacity: 0;
    }
    to {
        top: 20px;
        opacity: 1;
    }
}

@keyframes fadeOut {
    from {
        opacity: 1;
    }
    to {
        opacity: 0;
        transform: translateX(-50%) translateY(-10px);
    }
}

/* Mobile Anpassung Toast */
@media (max-width: 767px) {
    .ronin-toast {
        width: calc(100% - 32px);
        left: 16px;
        right: 16px;
        transform: none;
        padding: 16px 20px;
    }
    
    .ronin-toast-title {
        font-size: 0.95rem;
    }
    
    .ronin-toast-info {
        font-size: 0.85rem;
    }
    
    @keyframes slideDown {
        from {
            top: -100px;
            opacity: 0;
        }
        to {
            top: 16px;
            opacity: 1;
        }
    }
    
    @keyframes fadeOut {
        from {
            opacity: 1;
        }
        to {
            opacity: 0;
            transform: translateY(-10px);
        }
    }
}

/* ===================================
   ALLE KAUFEN SECTION
   =================================== */

.ronin-buy-all-section {
    max-width: 800px;
    margin: 0 auto 3rem;
    padding: 3rem 2rem;
    text-align: center;
    
    /* Glassmorphism (wie Cards) */
    background: rgba(255, 255, 255, 0.15);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.3);
    border-radius: 16px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.37);
    
    /* Über Overlay */
    position: relative;
    z-index: 1;
}

.ronin-buy-all-headline {
    font-size: 1.8rem;
    font-weight: 700;
    color: #ffffff;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.8);
    margin-bottom: 0.75rem;
    line-height: 1.3;
}

.ronin-buy-all-subheadline {
    font-size: 1.1rem;
    font-weight: 400;
    color: rgba(255, 255, 255, 0.9);
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.8);
    margin-bottom: 2rem;
}

.ronin-buy-all-button {
    /* Roter Gradient (Ronin-Akzent) */
    background: linear-gradient(135deg, #d00000 0%, #a00000 100%);
    color: #ffffff;
    border: none;
    padding: 1.25rem 3rem;
    font-size: 1.1rem;
    font-weight: 600;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    
    /* Shadow */
    box-shadow: 0 8px 24px rgba(208, 0, 0, 0.5);
    
    /* Typografie */
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    letter-spacing: 0.02em;
    
    /* Display */
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
}

.ronin-buy-all-button:hover {
    background: linear-gradient(135deg, #ff0000 0%, #d00000 100%);
    transform: translateY(-2px);
    box-shadow: 0 12px 32px rgba(208, 0, 0, 0.6);
}

.ronin-buy-all-button:active {
    background: #a00000;
    transform: translateY(0);
    box-shadow: 0 6px 20px rgba(208, 0, 0, 0.5);
}

.ronin-buy-all-button:disabled {
    opacity: 0.7;
    cursor: not-allowed;
    transform: none;
}

/* NEU v1.2.1: "Alle bereits im Warenkorb" State */
.ronin-buy-all-disabled {
    background: rgba(0, 0, 0, 0.15) !important;
    color: #666 !important;
    cursor: not-allowed !important;
    box-shadow: none !important;
}

.ronin-buy-all-disabled:hover {
    background: rgba(0, 0, 0, 0.15) !important;
    transform: none !important;
    box-shadow: none !important;
}

/* Loading State für "Alle kaufen" Button */
.ronin-buy-all-button.is-loading {
    position: relative;
    color: transparent;
}

.ronin-buy-all-button.is-loading::after {
    content: '';
    position: absolute;
    width: 20px;
    height: 20px;
    top: 50%;
    left: 50%;
    margin-left: -10px;
    margin-top: -10px;
    border: 3px solid #ffffff;
    border-radius: 50%;
    border-top-color: transparent;
    animation: spinner 0.6s linear infinite;
}

/* Mobile Anpassung "Alle kaufen" */
@media (max-width: 767px) {
    .ronin-buy-all-section {
        margin: 0 auto 2rem;
        padding: 2rem 1.5rem;
    }
    
    .ronin-buy-all-headline {
        font-size: 1.4rem;
    }
    
    .ronin-buy-all-subheadline {
        font-size: 1rem;
        margin-bottom: 1.5rem;
    }
    
    .ronin-buy-all-button {
        padding: 1rem 2rem;
        font-size: 1rem;
        width: 100%; /* Volle Breite auf Mobile */
    }
}

/* ===================================
   ERROR/SUCCESS MODAL
   =================================== */

.ronin-modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.85);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 99999;
    padding: 20px;
}

.ronin-modal {
    /* OPAK (kein Glassmorphism) für maximale Lesbarkeit */
    background: #ffffff;
    border-radius: 16px;
    padding: 2.5rem;
    max-width: 500px;
    width: 100%;
    box-shadow: 0 20px 80px rgba(0, 0, 0, 0.3);
    text-align: center;
    animation: modalSlideIn 0.3s ease-out;
    
    /* Status-Border oben */
    border-top: 4px solid #ff9800; /* Default: Warning Orange */
}

.ronin-modal-error {
    border-top-color: #d00000; /* Error: Rot */
}

.ronin-modal-icon {
    font-size: 4rem;
    margin-bottom: 1rem;
}

.ronin-modal-title {
    font-size: 1.5rem;
    font-weight: 700;
    color: #1a1a1a;
    margin-bottom: 1rem;
}

.ronin-modal-text {
    font-size: 1rem;
    color: #4a4a4a;
    margin-bottom: 1.5rem;
    line-height: 1.5;
}

.ronin-modal-failed-list {
    list-style: none;
    padding: 0;
    margin: 1.5rem 0;
    text-align: left;
    background: rgba(208, 0, 0, 0.05);
    padding: 1rem 1.5rem;
    border-radius: 8px;
    border-left: 3px solid #d00000;
    max-height: 200px;
    overflow-y: auto;
}

.ronin-modal-failed-list li {
    color: #d00000;
    font-size: 0.95rem;
    margin-bottom: 0.5rem;
}

.ronin-modal-failed-list li:last-child {
    margin-bottom: 0;
}

.ronin-modal-actions {
    display: flex;
    gap: 1rem;
    margin-top: 2rem;
}

.ronin-modal-button {
    flex: 1;
    padding: 0.875rem 1.5rem;
    border-radius: 8px;
    font-weight: 600;
    font-size: 1rem;
    cursor: pointer;
    transition: all 0.2s;
    border: none;
    text-decoration: none;
    display: inline-block;
    text-align: center;
}

.ronin-modal-button-primary {
    background: linear-gradient(135deg, #004d40, #00695c);
    color: #ffffff;
}

.ronin-modal-button-primary:hover {
    background: linear-gradient(135deg, #00695c, #00897b);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 77, 64, 0.4);
}

.ronin-modal-button-secondary {
    background: rgba(0, 0, 0, 0.1);
    color: #1a1a1a;
}

.ronin-modal-button-secondary:hover {
    background: rgba(0, 0, 0, 0.15);
}

@keyframes modalSlideIn {
    from {
        opacity: 0;
        transform: translateY(-30px) scale(0.95);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

/* Mobile Anpassung Modal */
@media (max-width: 767px) {
    .ronin-modal {
        padding: 2rem 1.5rem;
    }
    
    .ronin-modal-icon {
        font-size: 3rem;
    }
    
    .ronin-modal-title {
        font-size: 1.3rem;
    }
    
    .ronin-modal-actions {
        flex-direction: column;
    }
    
    .ronin-modal-button {
        width: 100%;
    }
}
