/* ========================================
   NOTIFICATIONS TEMPS RÉEL - SIRH IPS-CO
   ======================================== */

/* Conteneur principal des toasts */
.notification-container {
    position: fixed;
    top: 80px;
    right: 20px;
    z-index: 1060;
    max-width: 400px;
    pointer-events: none;
}

/* Toast de notification */
.toast-notification {
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    box-shadow: 0 8px 25px var(--shadow-lg);
    margin-bottom: 12px;
    opacity: 0;
    transform: translateX(100%);
    transition: all 0.3s ease;
    pointer-events: auto;
    overflow: hidden;
    position: relative;
}

.toast-notification.show {
    opacity: 1;
    transform: translateX(0);
}

.toast-notification::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 4px;
    background: var(--primary);
}

/* Types de toasts */
.toast-notification.toast-success::before {
    background: var(--success);
}

.toast-notification.toast-warning::before {
    background: var(--warning);
}

.toast-notification.toast-error::before {
    background: var(--danger);
}

.toast-notification.toast-urgent::before {
    background: var(--danger);
    animation: urgentPulse 1s infinite;
}

@keyframes urgentPulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

.toast-content {
    display: flex;
    align-items: flex-start;
    padding: 16px;
    gap: 12px;
}

.toast-icon {
    flex-shrink: 0;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    background: var(--bg-secondary);
}

.toast-icon .fas {
    font-size: 14px;
    color: var(--primary);
}

.toast-success .toast-icon .fas {
    color: var(--success);
}

.toast-warning .toast-icon .fas {
    color: var(--warning);
}

.toast-error .toast-icon .fas,
.toast-urgent .toast-icon .fas {
    color: var(--danger);
}

.toast-body {
    flex: 1;
    min-width: 0;
}

.toast-title {
    font-weight: 600;
    color: var(--text-primary);
    font-size: 14px;
    margin-bottom: 4px;
    line-height: 1.3;
}

.toast-message {
    color: var(--text-secondary);
    font-size: 13px;
    line-height: 1.4;
    word-wrap: break-word;
}

.toast-close {
    flex-shrink: 0;
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 4px;
    border-radius: 4px;
    transition: all 0.2s ease;
}

.toast-close:hover {
    background: var(--bg-secondary);
    color: var(--text-primary);
}

/* ========================================
   DROPDOWN DE NOTIFICATIONS
   ======================================== */

.notification-dropdown {
    min-width: 350px;
    max-width: 400px;
    border: none;
    border-radius: 12px;
    box-shadow: 0 8px 25px var(--shadow-lg);
    padding: 0;
    overflow: hidden;
}

.notification-header {
    background: linear-gradient(135deg, var(--primary) 0%, var(--secondary) 100%);
    color: white;
    padding: 16px;
}

.notification-header .dropdown-header {
    color: white;
    font-weight: 600;
    font-size: 16px;
    margin: 0;
    padding: 0;
    border: none;
}

.notification-header .btn {
    color: white;
    border-color: rgba(255, 255, 255, 0.3);
    font-size: 12px;
    padding: 4px 8px;
}

.notification-header .btn:hover {
    background: rgba(255, 255, 255, 0.1);
    border-color: rgba(255, 255, 255, 0.5);
}

.notification-list {
    max-height: 400px;
    overflow-y: auto;
    background: var(--bg-primary);
}

.notification-item {
    display: flex;
    align-items: flex-start;
    padding: 12px 16px;
    border-bottom: 1px solid var(--border-color);
    cursor: pointer;
    transition: background-color 0.2s ease;
    position: relative;
    gap: 12px;
}

.notification-item:hover {
    background: var(--bg-secondary);
}

.notification-item:last-child {
    border-bottom: none;
}

.notification-item.unread {
    background: linear-gradient(90deg, rgba(102, 126, 234, 0.05) 0%, var(--bg-primary) 100%);
}

.notification-item.unread::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 3px;
    background: var(--primary);
}

.notification-icon {
    flex-shrink: 0;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    background: var(--bg-secondary);
}

.notification-icon .fas {
    font-size: 14px;
}

.notification-content {
    flex: 1;
    min-width: 0;
}

.notification-title {
    font-weight: 600;
    color: var(--text-primary);
    font-size: 14px;
    margin-bottom: 4px;
    line-height: 1.3;
}

.notification-message {
    color: var(--text-secondary);
    font-size: 13px;
    line-height: 1.4;
    margin-bottom: 4px;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    line-clamp: 2; /* Standard property for compatibility */
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.notification-time {
    color: var(--text-muted);
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.notification-dot {
    position: absolute;
    top: 12px;
    right: 12px;
    width: 8px;
    height: 8px;
    background: var(--primary);
    border-radius: 50%;
    animation: notificationDot 2s infinite;
}

@keyframes notificationDot {
    0%, 100% { opacity: 1; transform: scale(1); }
    50% { opacity: 0.7; transform: scale(1.2); }
}

.notification-footer {
    background: var(--bg-secondary);
    border-top: 1px solid var(--border-color);
}

.notification-footer .dropdown-item {
    color: var(--text-primary);
    font-weight: 500;
    text-align: center;
    padding: 12px;
    transition: all 0.2s ease;
}

.notification-footer .dropdown-item:hover {
    background: var(--bg-tertiary);
    color: var(--primary);
}

/* États spéciaux */
.notification-loading,
.notification-empty,
.notification-error {
    padding: 24px 16px;
    text-align: center;
    color: var(--text-muted);
}

.notification-loading .fas,
.notification-empty .fas,
.notification-error .fas {
    font-size: 24px;
    margin-bottom: 8px;
    display: block;
}

.notification-loading .fas {
    animation: spin 1s linear infinite;
}

@keyframes spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

/* Badge de notification */
.notification-badge {
    font-size: 10px;
    min-width: 18px;
    height: 18px;
    line-height: 18px;
    padding: 0 4px;
    animation: badgePulse 2s infinite;
}

@keyframes badgePulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.1); }
}

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

@media (max-width: 768px) {
    .notification-container {
        top: 60px;
        right: 10px;
        left: 10px;
        max-width: none;
    }
    
    .notification-dropdown {
        min-width: 300px;
        max-width: none;
        left: 0 !important;
        right: 0 !important;
        transform: none !important;
    }
    
    .toast-notification {
        margin-left: 0;
        margin-right: 0;
    }
}

@media (max-width: 480px) {
    .notification-container {
        top: 50px;
        right: 5px;
        left: 5px;
    }
    
    .toast-content {
        padding: 12px;
        gap: 8px;
    }
    
    .toast-title {
        font-size: 13px;
    }
    
    .toast-message {
        font-size: 12px;
    }
    
    .notification-item {
        padding: 10px 12px;
        gap: 10px;
    }
    
    .notification-icon {
        width: 28px;
        height: 28px;
    }
}

/* ========================================
   MODE SOMBRE
   ======================================== */

[data-theme="dark"] .toast-notification {
    background: var(--bg-primary);
    border-color: var(--border-color);
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.4);
}

[data-theme="dark"] .notification-dropdown {
    background: var(--bg-primary);
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.5);
}

[data-theme="dark"] .notification-item.unread {
    background: linear-gradient(90deg, rgba(102, 126, 234, 0.1) 0%, var(--bg-primary) 100%);
}

/* ========================================
   ANIMATIONS AVANCÉES
   ======================================== */

.toast-notification {
    animation: slideInRight 0.3s ease;
}

@keyframes slideInRight {
    from {
        opacity: 0;
        transform: translateX(100%);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

.notification-item {
    animation: fadeInUp 0.3s ease;
}

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Effet de hover sur les notifications */
.notification-item::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(90deg, transparent 0%, rgba(102, 126, 234, 0.05) 100%);
    opacity: 0;
    transition: opacity 0.3s ease;
    pointer-events: none;
}

.notification-item:hover::after {
    opacity: 1;
}

/* ========================================
   ACCESSIBILITÉ
   ======================================== */

.toast-close:focus-visible {
    outline: 2px solid var(--primary);
    outline-offset: 2px;
}

.notification-item:focus-visible {
    outline: 2px solid var(--primary);
    outline-offset: -2px;
}

/* Réduction des mouvements */
@media (prefers-reduced-motion: reduce) {
    .toast-notification,
    .notification-item,
    .notification-badge,
    .notification-dot,
    .toast-urgent::before {
        animation: none;
        transition: none;
    }
}

/* Contraste élevé */
@media (prefers-contrast: high) {
    .notification-item {
        border-bottom-width: 2px;
    }
    
    .toast-notification {
        border-width: 2px;
    }
}

/* ========================================
   PRINT MODE
   ======================================== */

@media print {
    .notification-container,
    .notification-dropdown,
    .notification-badge {
        display: none !important;
    }
}
