/**
 * Toast Notification System - Dashboard Fixes
 * REQ-2.1: Non-intrusive Alerts
 * REQ-2.2: Dismissible Notifications
 * REQ-2.3: Visual Hierarchy
 *
 * Features:
 * - Toast notifications (top-right, auto-dismiss)
 * - Notification badge in navbar for persistent alerts
 * - Priority-based colors (red=late, yellow=reminder, green=success)
 * - Accessible (WCAG 2.1 AA compliant)
 */

/* ==========================================================================
   NOTIFICATION BADGE IN NAVBAR
   ========================================================================== */

.navbar-notification-badge {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background-color: var(--bg-surface);
    border: 1px solid var(--border-color);
    transition: background-color 0.2s ease, border-color 0.2s ease, transform 0.2s ease;
    cursor: pointer;
}

.navbar-notification-badge:hover {
    background-color: var(--primary-light);
    border-color: var(--primary-color);
    transform: scale(1.05);
}

.navbar-notification-badge:focus-visible {
    outline: 3px solid var(--primary-color);
    outline-offset: 2px;
}

.navbar-notification-badge .bi {
    font-size: 1.25rem;
    color: var(--text-secondary);
}

.navbar-notification-badge:hover .bi {
    color: var(--primary-color);
}

/* Badge counter */
.notification-count {
    position: absolute;
    top: -4px;
    right: -4px;
    min-width: 20px;
    height: 20px;
    padding: 0 6px;
    background-color: var(--danger);
    color: white;
    border-radius: 10px;
    font-size: 0.7rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 2px solid var(--bg-header);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
    animation: pulse-badge 2s ease-in-out infinite;
}

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

/* Hide badge when count is 0 */
.notification-count[data-count="0"] {
    display: none;
}

/* Notification dropdown */
.notification-dropdown {
    position: absolute;
    top: calc(100% + 10px);
    right: 0;
    width: 380px;
    max-height: 500px;
    background-color: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.15);
    z-index: 1060;
    overflow: hidden;
    display: none;
}

.notification-dropdown.show {
    display: block;
    animation: slideDown 0.2s ease-out;
}

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

.notification-dropdown-header {
    padding: 1rem 1.25rem;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: linear-gradient(90deg, rgba(59, 89, 152, 0.05) 0%, transparent 50%);
}

.notification-dropdown-title {
    font-size: 0.95rem;
    font-weight: 700;
    margin: 0;
    color: var(--text-primary);
}

.notification-dropdown-clear {
    font-size: 0.8rem;
    color: var(--primary-color);
    background: none;
    border: none;
    cursor: pointer;
    padding: 0.25rem 0.5rem;
    border-radius: 6px;
    transition: background-color 0.2s ease;
}

.notification-dropdown-clear:hover {
    background-color: var(--primary-light);
}

.notification-dropdown-body {
    max-height: 400px;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}

.notification-item {
    padding: 1rem 1.25rem;
    border-bottom: 1px solid var(--border-light);
    display: flex;
    gap: 1rem;
    transition: background-color 0.2s;
    cursor: pointer;
}

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

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

.notification-item.unread {
    background-color: rgba(59, 89, 152, 0.03);
}

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

.notification-icon {
    flex-shrink: 0;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.1rem;
}

/* Priority-based colors (REQ-2.3) */
.notification-icon.priority-critical {
    background-color: rgba(239, 68, 68, 0.1);
    color: var(--danger);
}

.notification-icon.priority-warning {
    background-color: rgba(245, 158, 11, 0.1);
    color: var(--warning);
}

.notification-icon.priority-success {
    background-color: rgba(16, 185, 129, 0.1);
    color: var(--success);
}

.notification-icon.priority-info {
    background-color: rgba(59, 130, 246, 0.1);
    color: var(--info);
}

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

.notification-title {
    font-size: 0.9rem;
    font-weight: 600;
    margin-bottom: 0.25rem;
    color: var(--text-primary);
}

.notification-message {
    font-size: 0.85rem;
    color: var(--text-secondary);
    line-height: 1.4;
    margin-bottom: 0.25rem;
}

.notification-time {
    font-size: 0.75rem;
    color: var(--text-muted);
}

.notification-dropdown-footer {
    padding: 0.75rem 1.25rem;
    border-top: 1px solid var(--border-color);
    text-align: center;
}

.notification-dropdown-footer a {
    font-size: 0.85rem;
    color: var(--primary-color);
    text-decoration: none;
    font-weight: 600;
}

.notification-dropdown-footer a:hover {
    text-decoration: underline;
}

/* Empty state */
.notification-empty {
    padding: 3rem 1.5rem;
    text-align: center;
}

.notification-empty-icon {
    font-size: 3rem;
    color: var(--text-muted);
    opacity: 0.5;
    margin-bottom: 1rem;
}

.notification-empty-text {
    font-size: 0.9rem;
    color: var(--text-secondary);
}

/* ==========================================================================
   TOAST ENHANCEMENTS (REQ-2.3: Visual Hierarchy)
   ========================================================================== */

/* Priority-based toast colors */
.toast-custom.toast-critical {
    background-color: rgba(239, 68, 68, 0.95);
    color: white;
}

.toast-custom.toast-critical .toast-header {
    background-color: rgba(220, 38, 38, 0.95);
    color: white;
    border-bottom-color: rgba(255, 255, 255, 0.2);
}

/* Toast with sound indicator */
.toast-custom.with-sound::after {
    content: '🔔';
    position: absolute;
    top: 0.5rem;
    right: 3rem;
    font-size: 1rem;
    animation: ring 0.5s ease-in-out;
}

@keyframes ring {
    0%, 100% {
        transform: rotate(0deg);
    }
    25% {
        transform: rotate(-15deg);
    }
    75% {
        transform: rotate(15deg);
    }
}

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

@media (max-width: 767.98px) {
    .notification-dropdown {
        position: fixed;
        top: var(--header-height);
        left: 0;
        right: 0;
        width: 100%;
        max-height: calc(100vh - var(--header-height));
        border-radius: 0;
    }

    .navbar-notification-badge {
        width: 44px;
        height: 44px;
    }
}

/* ==========================================================================
   DARK MODE
   ========================================================================== */

[data-theme="dark"] .navbar-notification-badge {
    background-color: var(--bg-sidebar);
}

[data-theme="dark"] .navbar-notification-badge:hover {
    background-color: rgba(255, 255, 255, 0.05);
}

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

[data-theme="dark"] .notification-item:hover {
    background-color: rgba(255, 255, 255, 0.03);
}

[data-theme="dark"] .notification-item.unread {
    background-color: rgba(107, 143, 217, 0.05);
}

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

/* Focus visible for keyboard navigation */
.notification-item:focus-visible {
    outline: 3px solid var(--primary-color);
    outline-offset: -3px;
}

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {
    .notification-count,
    .notification-dropdown,
    .toast-custom.with-sound::after {
        animation: none;
    }
}
