/* ========================================
   SYSTÈME DE NOTIFICATIONS AMÉLIORÉ
   ======================================== */

/* ---- Centre de notifications (icône cloche) ---- */
#notificationCenter {
    position: fixed;
    top: 8px;
    right: 55px;
    z-index: 300;
    cursor: pointer;
    transition: transform 0.2s ease;
}

#notificationCenter:hover {
    transform: scale(1.1);
}

#notificationCenter .bell-icon {
    width: 28px;
    height: 28px;
    color: #fff;
    filter: drop-shadow(0 2px 4px rgba(0,0,0,0.3));
}

#notificationCenter .notification-badge {
    position: absolute;
    top: -5px;
    right: -5px;
    background: linear-gradient(135deg, #ee3124, #ff5847);
    color: #fff;
    border-radius: 50%;
    min-width: 18px;
    height: 18px;
    font-size: 11px;
    font-weight: bold;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 6px rgba(238, 49, 36, 0.5);
    animation: pulse-badge 2s infinite;
}

#notificationCenter .notification-badge.hidden {
    display: none;
}

@keyframes pulse-badge {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.15); }
}

/* Animation de la cloche quand nouvelle notification */
@keyframes bell-shake {
    0%, 100% { transform: rotate(0); }
    10%, 30%, 50%, 70%, 90% { transform: rotate(-10deg); }
    20%, 40%, 60%, 80% { transform: rotate(10deg); }
}

#notificationCenter.has-new .bell-icon {
    animation: bell-shake 0.5s ease-in-out;
}

/* ---- Panneau des notifications ---- */
#notificationPanel {
    position: fixed;
    top: 50px;
    right: 10px;
    width: 340px;
    max-width: calc(100vw - 20px);
    max-height: 70vh;
    background: rgba(30, 30, 35, 0.98);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-radius: 16px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5), 
                0 0 0 1px rgba(255, 255, 255, 0.1);
    z-index: 400;
    overflow: hidden;
    transform: translateY(-20px) scale(0.95);
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

#notificationPanel.open {
    transform: translateY(0) scale(1);
    opacity: 1;
    visibility: visible;
}

.notification-panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 20px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    background: rgba(255, 255, 255, 0.03);
}

.notification-panel-header h3 {
    margin: 0;
    color: #fff;
    font-size: 16px;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 8px;
}

.notification-panel-header h3 i {
    color: #ee3124;
}

.clear-all-btn {
    background: none;
    border: none;
    color: #ee3124;
    font-size: 12px;
    cursor: pointer;
    padding: 6px 12px;
    border-radius: 20px;
    transition: all 0.2s;
    width: auto;
    height: auto;
}

.clear-all-btn:hover {
    background: rgba(238, 49, 36, 0.15);
}

.notification-panel-body {
    max-height: calc(70vh - 120px);
    overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-color: rgba(255,255,255,0.2) transparent;
}

.notification-panel-body::-webkit-scrollbar {
    width: 6px;
}

.notification-panel-body::-webkit-scrollbar-track {
    background: transparent;
}

.notification-panel-body::-webkit-scrollbar-thumb {
    background: rgba(255,255,255,0.2);
    border-radius: 3px;
}

/* ---- Élément de notification dans le panneau ---- */
.notification-item {
    display: flex;
    gap: 12px;
    padding: 14px 20px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    cursor: pointer;
    transition: background 0.2s;
    position: relative;
}

.notification-item:hover {
    background: rgba(255, 255, 255, 0.05);
}

.notification-item.unread {
    background: rgba(238, 49, 36, 0.08);
}

.notification-item.unread::before {
    content: '';
    position: absolute;
    left: 8px;
    top: 50%;
    transform: translateY(-50%);
    width: 6px;
    height: 6px;
    background: #ee3124;
    border-radius: 50%;
}

.notification-item-icon {
    width: 40px;
    height: 40px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.notification-item-icon.success {
    background: linear-gradient(135deg, #10b981, #059669);
}

.notification-item-icon.error {
    background: linear-gradient(135deg, #ef4444, #dc2626);
}

.notification-item-icon.info {
    background: linear-gradient(135deg, #3b82f6, #2563eb);
}

.notification-item-icon.warning {
    background: linear-gradient(135deg, #f59e0b, #d97706);
}

.notification-item-icon.course {
    background: linear-gradient(135deg, #8b5cf6, #7c3aed);
}

.notification-item-icon i {
    color: #fff;
    font-size: 16px;
}

.notification-item-content {
    flex: 1;
    min-width: 0;
}

.notification-item-title {
    color: #fff;
    font-size: 14px;
    font-weight: 500;
    margin-bottom: 4px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.notification-item-message {
    color: rgba(255, 255, 255, 0.6);
    font-size: 13px;
    line-height: 1.4;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.notification-item-time {
    color: rgba(255, 255, 255, 0.4);
    font-size: 11px;
    margin-top: 6px;
}

.notification-item-close {
    position: absolute;
    top: 10px;
    right: 10px;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.1);
    border: none;
    color: rgba(255, 255, 255, 0.5);
    font-size: 10px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: all 0.2s;
}

.notification-item:hover .notification-item-close {
    opacity: 1;
}

.notification-item-close:hover {
    background: rgba(238, 49, 36, 0.3);
    color: #fff;
}

/* État vide */
.notification-empty {
    padding: 40px 20px;
    text-align: center;
    color: rgba(255, 255, 255, 0.4);
}

.notification-empty i {
    font-size: 48px;
    margin-bottom: 16px;
    opacity: 0.3;
}

.notification-empty p {
    margin: 0;
    font-size: 14px;
}

/* ---- Toast notifications (in-app) ---- */
#toastContainer {
    position: fixed;
    top: 70px;
    right: 20px;
    z-index: 10000;
    display: flex;
    flex-direction: column;
    gap: 10px;
    pointer-events: none;
    max-width: calc(100vw - 40px);
}

.toast-notification {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 16px;
    background: rgba(30, 30, 35, 0.95);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-radius: 12px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4),
                0 0 0 1px rgba(255, 255, 255, 0.1);
    min-width: 300px;
    max-width: 400px;
    pointer-events: auto;
    transform: translateX(120%);
    opacity: 0;
    animation: toast-slide-in 0.4s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
    position: relative;
    overflow: hidden;
}

.toast-notification.removing {
    animation: toast-slide-out 0.3s ease-in forwards;
}

@keyframes toast-slide-in {
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

@keyframes toast-slide-out {
    to {
        transform: translateX(120%);
        opacity: 0;
    }
}

/* Progress bar */
.toast-progress {
    position: absolute;
    bottom: 0;
    left: 0;
    height: 3px;
    background: rgba(255, 255, 255, 0.3);
    animation: toast-progress linear forwards;
}

@keyframes toast-progress {
    from { width: 100%; }
    to { width: 0%; }
}

.toast-notification.success .toast-progress { background: #10b981; }
.toast-notification.error .toast-progress { background: #ef4444; }
.toast-notification.info .toast-progress { background: #3b82f6; }
.toast-notification.warning .toast-progress { background: #f59e0b; }

/* Toast icon */
.toast-icon {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.toast-notification.success .toast-icon {
    background: rgba(16, 185, 129, 0.2);
    color: #10b981;
}

.toast-notification.error .toast-icon {
    background: rgba(239, 68, 68, 0.2);
    color: #ef4444;
}

.toast-notification.info .toast-icon {
    background: rgba(59, 130, 246, 0.2);
    color: #3b82f6;
}

.toast-notification.warning .toast-icon {
    background: rgba(245, 158, 11, 0.2);
    color: #f59e0b;
}

.toast-icon i {
    font-size: 18px;
}

/* Toast content */
.toast-content {
    flex: 1;
    min-width: 0;
}

.toast-title {
    color: #fff;
    font-size: 14px;
    font-weight: 600;
    margin-bottom: 4px;
}

.toast-message {
    color: rgba(255, 255, 255, 0.7);
    font-size: 13px;
    line-height: 1.4;
}

.toast-close {
    background: none;
    border: none;
    color: rgba(255, 255, 255, 0.4);
    cursor: pointer;
    padding: 4px;
    border-radius: 4px;
    transition: all 0.2s;
    width: auto;
    height: auto;
}

.toast-close:hover {
    color: #fff;
    background: rgba(255, 255, 255, 0.1);
}

/* ---- Actions dans les notifications ---- */
.toast-actions {
    display: flex;
    gap: 8px;
    margin-top: 12px;
}

.toast-action-btn {
    padding: 6px 14px;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    width: auto;
    height: auto;
}

.toast-action-btn.primary {
    background: #ee3124;
    color: #fff;
    border: none;
}

.toast-action-btn.primary:hover {
    background: #d12a1f;
}

.toast-action-btn.secondary {
    background: rgba(255, 255, 255, 0.1);
    color: #fff;
    border: none;
}

.toast-action-btn.secondary:hover {
    background: rgba(255, 255, 255, 0.2);
}

/* ---- Overlay pour fermer le panneau ---- */
#notificationOverlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 350;
    display: none;
}

#notificationOverlay.active {
    display: block;
}

/* ---- Responsive ---- */
@media (max-width: 480px) {
    #notificationPanel {
        right: 5px;
        left: 5px;
        width: auto;
        max-height: 60vh;
    }
    
    #toastContainer {
        right: 10px;
        left: 10px;
        top: 60px;
    }
    
    .toast-notification {
        min-width: auto;
        max-width: none;
    }
    
    #notificationCenter {
        right: 50px;
    }
}

/* ---- Types spéciaux de notifications ---- */
.notification-item.course-reminder {
    border-left: 3px solid #8b5cf6;
}

.notification-item.inscription-success {
    border-left: 3px solid #10b981;
}

.notification-item.place-available {
    border-left: 3px solid #f59e0b;
}

/* ---- Animation pour les nouvelles notifications ---- */
@keyframes notification-new {
    0% {
        transform: translateX(20px);
        opacity: 0;
    }
    100% {
        transform: translateX(0);
        opacity: 1;
    }
}

.notification-item.new-item {
    animation: notification-new 0.3s ease-out;
}
