/**
 * Sales Gate - Front-end Notifications
 * Design compact optimisé
 * @author H2J
 * @version 1.3.0
 */

/* Variables - couleur injectée dynamiquement via JS */
:root {
    --h2j-salesgate-color: var(--h2j-salesgate-color);
    --h2j-salesgate-color-dark: var(--h2j-salesgate-color-dark);
}

/* Container principal */
.h2j-salesgate {
    position: fixed;
    z-index: 999999;
    pointer-events: none;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
}

/* Positions */
.h2j-salesgate.bottom-left { bottom: 120px; left: 20px; }
.h2j-salesgate.bottom-right { bottom: 120px; right: 20px; }
.h2j-salesgate.top-left { top: 80px; left: 20px; }
.h2j-salesgate.top-right { top: 80px; right: 20px; }

/* Mobile - éviter menu burger (110x60) et chariot */
@media (max-width: 768px) {
    .h2j-salesgate.top-left { top: 80px; left: 130px; }
    .h2j-salesgate.top-right { top: 80px; right: 80px; }
}
.h2j-salesgate.top-center { top: 20px; left: 50%; transform: translateX(-50%); }

/* Mobile - Notification compacte haut-droite */
@media (max-width: 480px) {
    .h2j-salesgate {
        left: auto !important;
        right: 10px !important;
        width: 75%;
        max-width: 280px;
        transform: none !important;
    }
    
    /* Toutes positions mobile → tout en haut à droite */
    .h2j-salesgate.mobile-bottom,
    .h2j-salesgate.mobile-top {
        top: 10px !important;
        bottom: auto !important;
        left: auto !important;
        right: 10px !important;
    }
    
    /* Toast plus compact sur mobile */
    .h2j-salesgate-toast {
        max-width: 100%;
    }
}

/* ============================================
   TOAST - Design compact
   ============================================ */

.h2j-salesgate-toast {
    position: relative;
    display: flex;
    flex-direction: row;
    align-items: stretch;
    max-width: 320px;
    background: #ffffff;
    border-radius: 10px;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.12), 0 0 0 1px rgba(0, 0, 0, 0.04);
    pointer-events: auto;
    cursor: pointer;
    transform: translateX(-120%);
    opacity: 0;
    transition: all 0.4s cubic-bezier(0.68, -0.55, 0.265, 1.55);
    overflow: visible; /* Important pour le badge */
    margin-top: 10px; /* Espace pour le badge */
}

/* Bordure accent gauche */
.h2j-salesgate-toast::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 3px;
    height: 100%;
    background: linear-gradient(180deg, var(--h2j-salesgate-color), var(--h2j-salesgate-color-dark));
    border-radius: 10px 0 0 10px;
}

/* Positions right */
.h2j-salesgate.bottom-right .h2j-salesgate-toast,
.h2j-salesgate.top-right .h2j-salesgate-toast {
    transform: translateX(120%);
}

/* Position center */
.h2j-salesgate.top-center .h2j-salesgate-toast {
    transform: translateY(-120%);
}

/* Mobile */
@media (max-width: 480px) {
    .h2j-salesgate-toast {
        max-width: 100%;
        transform: translateY(100%);
    }
}

/* ============================================
   IMAGE - Compacte
   ============================================ */

.h2j-salesgate-image {
    flex-shrink: 0;
    width: 65px;
    min-height: 65px;
    background: #f8f8f8;
    border-radius: 10px 0 0 10px;
    overflow: hidden;
}

.h2j-salesgate-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

/* ============================================
   CONTENU - Compact
   ============================================ */

.h2j-salesgate-content {
    flex: 1;
    min-width: 0;
    padding: 8px 10px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 2px;
}

/* Message - 2 lignes autorisées */
.h2j-salesgate-message {
    font-size: 11px;
    color: #666;
    line-height: 1.35;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.h2j-salesgate-message strong {
    color: var(--h2j-salesgate-color);
    font-weight: 600;
}

/* Nom du produit - 1 ligne SEUL élément tronqué */
.h2j-salesgate-product {
    font-size: 12px;
    font-weight: 600;
    color: #1a1a1a;
    line-height: 1.3;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Meta (prix + temps) */
.h2j-salesgate-meta {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 2px;
}

.h2j-salesgate-price {
    font-size: 12px;
    font-weight: 700;
    color: var(--h2j-salesgate-color);
}

.h2j-salesgate-time {
    font-size: 10px;
    color: #999;
}

/* Urgence stock */
.h2j-salesgate-urgency {
    font-size: 10px;
    font-weight: 600;
    color: #e74c3c;
    background: rgba(231, 76, 60, 0.1);
    padding: 2px 6px;
    border-radius: 4px;
    margin-top: 3px;
    display: inline-block;
}

/* ============================================
   BADGE - Compact
   ============================================ */

.h2j-salesgate-badge {
    position: absolute;
    top: -6px;
    left: 8px;
    padding: 2px 8px;
    background: linear-gradient(135deg, var(--h2j-salesgate-color), var(--h2j-salesgate-color-dark));
    color: white;
    font-size: 9px;
    font-weight: 600;
    border-radius: 8px;
    text-transform: uppercase;
    letter-spacing: 0.3px;
    box-shadow: 0 2px 6px rgba(192, 87, 124, 0.35);
    z-index: 10;
}

/* ============================================
   CLOSE BUTTON
   ============================================ */

.h2j-salesgate-close {
    position: absolute;
    top: 4px;
    right: 4px;
    width: 18px;
    height: 18px;
    border: none;
    background: rgba(0, 0, 0, 0.05);
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: all 0.2s;
    padding: 0;
    font-size: 14px;
    color: #999;
    line-height: 1;
    z-index: 10;
}

.h2j-salesgate-toast:hover .h2j-salesgate-close {
    opacity: 1;
}

.h2j-salesgate-close:hover {
    background: rgba(192, 87, 124, 0.15);
    color: var(--h2j-salesgate-color);
}

/* ============================================
   ANIMATIONS - Smooth
   ============================================ */

.h2j-salesgate-toast:hover {
    transform: translateX(0) scale(1.01);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.15);
}

/* Entrée smooth - Left */
@keyframes h2j-salesgate-slide-in-left {
    0% { 
        transform: translateX(-100%); 
        opacity: 0; 
    }
    100% { 
        transform: translateX(0); 
        opacity: 1; 
    }
}

.h2j-salesgate-toast.animate-in {
    animation: h2j-salesgate-slide-in-left 0.5s cubic-bezier(0.25, 0.46, 0.45, 0.94) forwards;
}

/* Sortie smooth */
@keyframes h2j-salesgate-slide-out-left {
    0% { 
        transform: translateX(0); 
        opacity: 1; 
    }
    100% { 
        transform: translateX(-100%); 
        opacity: 0; 
    }
}

.h2j-salesgate-toast.animate-out {
    animation: h2j-salesgate-slide-out-left 0.35s cubic-bezier(0.55, 0.06, 0.68, 0.19) forwards;
}

/* Right */
@keyframes h2j-salesgate-slide-in-right {
    0% { 
        transform: translateX(100%); 
        opacity: 0; 
    }
    100% { 
        transform: translateX(0); 
        opacity: 1; 
    }
}

.h2j-salesgate.bottom-right .h2j-salesgate-toast.animate-in,
.h2j-salesgate.top-right .h2j-salesgate-toast.animate-in {
    animation: h2j-salesgate-slide-in-right 0.5s cubic-bezier(0.25, 0.46, 0.45, 0.94) forwards;
}

@keyframes h2j-salesgate-slide-out-right {
    0% { 
        transform: translateX(0); 
        opacity: 1; 
    }
    100% { 
        transform: translateX(100%); 
        opacity: 0; 
    }
}

.h2j-salesgate.bottom-right .h2j-salesgate-toast.animate-out,
.h2j-salesgate.top-right .h2j-salesgate-toast.animate-out {
    animation: h2j-salesgate-slide-out-right 0.35s cubic-bezier(0.55, 0.06, 0.68, 0.19) forwards;
}

/* Center (top-center) */
@keyframes h2j-salesgate-slide-in-top {
    0% { 
        transform: translateY(-100%); 
        opacity: 0; 
    }
    100% { 
        transform: translateY(0); 
        opacity: 1; 
    }
}

.h2j-salesgate.top-center .h2j-salesgate-toast.animate-in {
    animation: h2j-salesgate-slide-in-top 0.5s cubic-bezier(0.25, 0.46, 0.45, 0.94) forwards;
}

@keyframes h2j-salesgate-slide-out-top {
    0% { 
        transform: translateY(0); 
        opacity: 1; 
    }
    100% { 
        transform: translateY(-100%); 
        opacity: 0; 
    }
}

.h2j-salesgate.top-center .h2j-salesgate-toast.animate-out {
    animation: h2j-salesgate-slide-out-top 0.35s cubic-bezier(0.55, 0.06, 0.68, 0.19) forwards;
}

/* Mobile animations - Slide depuis la droite */
@media (max-width: 480px) {
    /* Position initiale hors écran à droite */
    .h2j-salesgate.mobile-bottom .h2j-salesgate-toast,
    .h2j-salesgate.mobile-top .h2j-salesgate-toast {
        transform: translateX(120%);
    }
    
    @keyframes h2j-salesgate-slide-in-mobile {
        0% { 
            transform: translateX(120%); 
            opacity: 0; 
        }
        100% { 
            transform: translateX(0); 
            opacity: 1; 
        }
    }
    
    .h2j-salesgate.mobile-bottom .h2j-salesgate-toast.animate-in,
    .h2j-salesgate.mobile-top .h2j-salesgate-toast.animate-in {
        animation: h2j-salesgate-slide-in-mobile 0.5s cubic-bezier(0.25, 0.46, 0.45, 0.94) forwards;
    }
    
    @keyframes h2j-salesgate-slide-out-mobile {
        0% { 
            transform: translateX(0); 
            opacity: 1; 
        }
        100% { 
            transform: translateX(120%); 
            opacity: 0; 
        }
    }
    
    .h2j-salesgate.mobile-bottom .h2j-salesgate-toast.animate-out,
    .h2j-salesgate.mobile-top .h2j-salesgate-toast.animate-out {
        animation: h2j-salesgate-slide-out-mobile 0.35s cubic-bezier(0.55, 0.06, 0.68, 0.19) forwards;
    }
}

/* ============================================
   URGENCE STOCK
   ============================================ */

.h2j-salesgate-urgency {
    font-size: 10px;
    font-weight: 600;
    color: #e74c3c;
    background: rgba(231, 76, 60, 0.1);
    padding: 3px 8px;
    border-radius: 4px;
    margin-top: 4px;
    display: inline-block;
    animation: h2j-pulse 2s infinite;
}

@keyframes h2j-pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.7; }
}

/* ============================================
   COMPTEUR FICHE PRODUIT
   ============================================ */

.h2j-salesgate-product-counter {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 14px;
    background: linear-gradient(135deg, rgba(192, 87, 124, 0.08), rgba(192, 87, 124, 0.04));
    border: 1px solid rgba(192, 87, 124, 0.15);
    border-radius: 20px;
    font-size: 13px;
    color: #555;
    margin: 10px 0;
}

.h2j-salesgate-product-counter i {
    font-size: 16px;
    color: var(--h2j-salesgate-color, #c0577c);
}

.h2j-salesgate-product-counter span {
    font-weight: 500;
}
