/**
 * insights.css
 * Styles pour le système d'insights contextuels
 */

/* === Badge flottant === */
.insights-badge {
    position: fixed;
    bottom: 24px;
    right: 24px;
    width: 56px;
    height: 56px;
    background: linear-gradient(135deg, #DD922E 0%, #4C8E88 100%);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15), 0 2px 4px rgba(0, 0, 0, 0.1);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 1000;
    color: white;
    font-size: 24px;
}

.insights-badge:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 16px rgba(0, 0, 0, 0.2), 0 4px 8px rgba(0, 0, 0, 0.15);
}

.insights-badge:active {
    transform: translateY(0);
}

.insights-badge.hidden {
    opacity: 0;
    transform: translateY(20px) scale(0.8);
    pointer-events: none;
}

.insights-badge.pulse {
    animation: insights-pulse 0.6s ease-out;
}

@keyframes insights-pulse {
    0% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.1);
        box-shadow: 0 0 0 0 rgba(20, 184, 166, 0.7);
    }
    100% {
        transform: scale(1);
        box-shadow: 0 0 0 20px rgba(20, 184, 166, 0);
    }
}

.insights-badge .insights-count {
    position: absolute;
    top: -4px;
    right: -4px;
    background: #EF4444;
    color: white;
    font-size: 12px;
    font-weight: 600;
    min-width: 20px;
    height: 20px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 6px;
    border: 2px solid white;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.insights-badge .insights-count.hidden {
    display: none;
}

/* === Panneau d'insights === */
.insights-panel {
    position: fixed;
    top: 0;
    right: 0;
    width: 400px;
    height: 100vh;
    background: white;
    box-shadow: -4px 0 24px rgba(0, 0, 0, 0.15);
    transform: translateX(100%);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 1001;
    display: flex;
    flex-direction: column;
}

.insights-panel.open {
    transform: translateX(0);
}

/* Header */
.insights-panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px;
    border-bottom: 1px solid #E5E7EB;
    background: linear-gradient(135deg, #14B8A6 0%, #0D9488 100%);
    color: white;
}

.insights-panel-title {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 20px;
    font-weight: 600;
}

.insights-panel-title i {
    font-size: 24px;
}

.insights-panel-close {
    background: rgba(255, 255, 255, 0.2);
    border: none;
    color: white;
    width: 36px;
    height: 36px;
    border-radius: 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
    flex-shrink: 0;
}

.insights-panel-close:hover {
    background: rgba(255, 255, 255, 0.3);
}

.insights-panel-close i {
    font-size: 16px;
    pointer-events: none;
}

/* Content */
.insights-panel-content {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
}

/* Empty state */
.insights-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 60px 20px;
    color: #9CA3AF;
}

.insights-empty i {
    font-size: 64px;
    margin-bottom: 16px;
    opacity: 0.3;
}

.insights-empty p {
    font-size: 18px;
    font-weight: 500;
    margin: 0 0 8px 0;
    color: #6B7280;
}

.insights-empty small {
    font-size: 14px;
    color: #9CA3AF;
}

.insights-empty.hidden {
    display: none;
}

/* Liste d'insights */
.insights-list {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.insights-list.hidden {
    display: none;
}

/* Item d'insight */
.insight-item {
    background: #F9FAFB;
    border: 1px solid #E5E7EB;
    border-radius: 12px;
    padding: 16px;
    display: flex;
    gap: 12px;
    position: relative;
    transition: all 0.2s;
}

.insight-item:hover {
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.08);
    border-color: #D1D5DB;
}

.insight-item.unread {
    background: #EEF2FF;
    border-color: #C7D2FE;
}

.insight-item.unread::before {
    content: '';
    position: absolute;
    left: 0;
    top: 16px;
    width: 4px;
    height: calc(100% - 32px);
    background: linear-gradient(135deg, #14B8A6 0%, #0D9488 100%);
    border-radius: 0 4px 4px 0;
}

/* Icône */
.insight-icon {
    flex-shrink: 0;
    width: 40px;
    height: 40px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
}

/* Contenu */
.insight-content {
    flex: 1;
    min-width: 0;
}

.insight-header {
    display: flex;
    align-items: center;
    justify-content: between;
    gap: 8px;
    margin-bottom: 6px;
}

.insight-type-label {
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.insight-time {
    font-size: 11px;
    color: #9CA3AF;
    margin-left: auto;
}

.insight-title {
    font-size: 15px;
    font-weight: 600;
    color: #1F2937;
    margin: 0 0 4px 0;
    line-height: 1.4;
}

.insight-message {
    font-size: 14px;
    color: #6B7280;
    margin: 0;
    line-height: 1.5;
}

/* Données supplémentaires */
.insight-data {
    margin-top: 12px;
    padding: 12px;
    background: white;
    border-radius: 8px;
    border: 1px solid #E5E7EB;
}

.insight-data-item {
    font-size: 13px;
    color: #374151;
    padding: 4px 0;
    line-height: 1.4;
}

.insight-data-item strong {
    color: #1F2937;
    font-weight: 600;
}

/* Bouton de suppression */
.insight-delete {
    position: absolute;
    top: 12px;
    right: 12px;
    background: transparent;
    border: none;
    color: #9CA3AF;
    width: 24px;
    height: 24px;
    border-radius: 6px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: all 0.2s;
}

.insight-item:hover .insight-delete {
    opacity: 1;
}

.insight-delete:hover {
    background: #FEE2E2;
    color: #DC2626;
}

/* Footer */
.insights-panel-footer {
    padding: 16px 20px;
    border-top: 1px solid #E5E7EB;
    background: #F9FAFB;
}

.insights-clear-btn {
    width: 100%;
    padding: 10px 16px;
    background: white;
    border: 1px solid #E5E7EB;
    border-radius: 8px;
    color: #6B7280;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: all 0.2s;
}

.insights-clear-btn:hover {
    background: #FEE2E2;
    border-color: #FCA5A5;
    color: #DC2626;
}

/* === Responsive === */
@media (max-width: 768px) {
    .insights-panel {
        width: 100%;
        max-width: 100vw;
        /* Permettre la transition lors du swipe */
        will-change: transform;
    }

    /* Drag handle visuel en haut du header */
    .insights-panel-header {
        position: relative;
        padding-top: 24px;
    }

    .insights-panel-header::before {
        content: '';
        position: absolute;
        top: 8px;
        left: 50%;
        transform: translateX(-50%);
        width: 36px;
        height: 4px;
        background: rgba(255, 255, 255, 0.45);
        border-radius: 2px;
    }

    /* Bouton fermer plus grand (cible tactile 44px min) */
    .insights-panel-close {
        width: 44px;
        height: 44px;
        border-radius: 12px;
        font-size: 18px;
    }
    
    .insights-badge {
        bottom: 80px; /* Au-dessus des contrôles mobiles */
        right: 16px;
        width: 48px;
        height: 48px;
        font-size: 20px;
    }
    
    .insights-badge .insights-count {
        top: -2px;
        right: -2px;
        min-width: 18px;
        height: 18px;
        font-size: 11px;
    }

    /* Hint de swipe dans le footer */
    .insights-panel-footer::after {
        content: '← Glisser vers la droite pour fermer';
        display: block;
        text-align: center;
        font-size: 11px;
        color: #9CA3AF;
        margin-top: 8px;
    }
}

/* Mode simple adjustments */
body.simple-mode .insights-badge {
    bottom: 24px; /* Position normale en mode simple */
}

@media (max-width: 768px) {
    body.simple-mode .insights-badge {
        bottom: 100px; /* Au-dessus des contrôles de lecture en mode simple mobile */
    }
}
