/**
 * SPARK Modern Notification System
 * Following SPARK Modern Design Variant principles
 * 
 * Features:
 * - Real-time WebSocket notifications
 * - Clean, professional design
 * - Subtle shadows and rounded corners
 * - Smooth animations
 */

:root {
    /* SPARK Modern Colors */
    --spark-primary: #2563eb;
    --spark-primary-hover: #1d4ed8;
    --spark-primary-light: #eff6ff;
    
    --spark-success: #059669;
    --spark-success-light: #ecfdf5;
    --spark-warning: #d97706;
    --spark-warning-light: #fffbeb;
    --spark-danger: #dc2626;
    --spark-danger-light: #fef2f2;
    --spark-info: #0891b2;
    --spark-info-light: #ecfeff;
    
    --spark-text: #1e293b;
    --spark-text-secondary: #64748b;
    --spark-text-muted: #94a3b8;
    
    --spark-border: #e2e8f0;
    --spark-bg: #f8fafc;
    --spark-surface: #ffffff;
    
    --spark-shadow: 0 1px 3px rgba(0, 0, 0, 0.1), 0 1px 2px rgba(0, 0, 0, 0.06);
    --spark-shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --spark-shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
}

/* ============================================
   Notification Trigger Button
   ============================================ */

.spark-notification-container {
    position: relative;
    z-index: 6100;
    isolation: isolate;
}

.spark-notification-trigger {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    background: transparent;
    border: none;
    border-radius: 6px;
    color: #ffffff;
    cursor: pointer;
    transition: all 0.15s ease;
}

.spark-notification-trigger:hover {
    background: rgba(255, 255, 255, 0.1);
}

.spark-notification-trigger i {
    font-size: 1.125rem;
}

.spark-notification-badge {
    position: absolute;
    top: 6px;
    right: 6px;
    min-width: 18px;
    height: 18px;
    padding: 0 5px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #dc2626;
    color: #ffffff;
    font-size: 0.6875rem;
    font-weight: var(--font-weight-bold);
    border-radius: 10px;
    box-shadow: 0 2px 4px rgba(220, 38, 38, 0.4);
    animation: pulse 2s infinite;
}

/* Animations */
.spark-row-fade-out {
    opacity: 0 !important;
    transform: translateX(20px) scale(0.95);
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1) !important;
    pointer-events: none;
}

@keyframes pop {
    0% { transform: scale(1); }
    50% { transform: scale(1.2); }
    100% { transform: scale(1); }
}

.spark-notification-badge.pop {
    animation: pop 0.3s ease-out;
}

/* ============================================
   Notification Dropdown
   ============================================ */

.spark-notification-dropdown {
    width: 320px;
    max-height: 600px;
    padding: 0.5rem;
    border-radius: 6px;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.4), 0 0 40px rgba(0, 0, 0, 0.1);
    overflow: hidden;
    background: linear-gradient(180deg, #003366 0%, #002244 100%);
    border: 1px solid rgba(255, 255, 255, 0.12);
    z-index: 6200 !important;
}

/* Header */
.spark-notification-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.25rem 0.5rem 0.5rem 0.5rem;
    margin-bottom: 0.5rem;
    background: transparent;
    border-bottom: 1px solid rgba(255,255,255,0.05);
}

.spark-notification-header-left {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.spark-notification-header-left i {
    display: none;
}

.spark-notification-header h6 {
    margin: 0;
    font-size: 0.6875rem;
    font-weight: 700;
    color: rgba(255, 255, 255, 0.4);
    text-transform: uppercase;
    letter-spacing: 0.1em;
}

.spark-notification-count {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 20px;
    height: 20px;
    padding: 0 0.375rem;
    background: rgba(255, 255, 255, 0.15);
    color: rgba(255, 255, 255, 0.9);
    font-size: 0.6875rem;
    font-weight: var(--font-weight-bold);
    border-radius: 10px;
    margin-left: 0.5rem;
}

.spark-notification-mark-all {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    min-width: 24px;
    padding: 0;
    border: none;
    border-radius: 4px;
    background: transparent;
    color: rgba(255, 255, 255, 0.4);
    cursor: pointer;
    transition: background-color 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

.spark-notification-mark-all:hover {
    background: rgba(255, 255, 255, 0.1);
    color: white;
}

.spark-notification-mark-all i {
    font-size: 0.8rem;
}

.btn-spark-text {
    display: inline-flex;
    align-items: center;
    gap: 0.375rem;
    padding: 0.375rem 0.75rem;
    background: transparent;
    border: none;
    border-radius: 4px;
    color: var(--spark-primary);
    font-size: 0.8125rem;
    font-weight: var(--font-weight-medium);
    cursor: pointer;
    transition: all 0.15s ease;
}

.btn-spark-text:hover {
    background: var(--spark-primary-light);
}

.btn-spark-text i {
    font-size: 0.75rem;
}

/* Notification List */
.spark-notification-list {
    max-height: 450px;
    overflow-y: auto;
    background: transparent;
    padding: 0;
}

.spark-notification-list::-webkit-scrollbar {
    width: 6px;
}

.spark-notification-list::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.2);
}

.spark-notification-list::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.2);
    border-radius: 3px;
}

.spark-notification-list::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.4);
}

.spark-notification-item {
    display: flex;
    align-items: flex-start;
    gap: 0.625rem;
    padding: 0.5rem 0.75rem;
    margin-bottom: 2px;
    background: transparent;
    border-bottom: none;
    border-radius: 0.5rem;
    text-decoration: none;
    transition: all 0.15s ease;
    position: relative;
}

.spark-notification-item:hover {
    background: rgba(255, 255, 255, 0.1);
}

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

/* Notification Icon */
.spark-notification-icon {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border-radius: var(--radius-md);
    font-size: 0.875rem;
}

.spark-notification-icon-system,
.spark-notification-icon-report {
    background: rgba(255, 255, 255, 0.1);
    color: #38bdf8;
}

.spark-notification-icon-lock_request {
    background: rgba(255, 255, 255, 0.1);
    color: #fbbf24;
}

.spark-notification-icon-SUPPORT_TICKET {
    background: rgba(255, 255, 255, 0.1);
    color: #f87171;
}

.spark-notification-icon-task {
    background: rgba(255, 255, 255, 0.1);
    color: #34d399;
}

.spark-notification-icon-unlocked {
    background: rgba(255, 255, 255, 0.1);
    color: #10b981; /* Default to success green */
}

.spark-notification-icon-locked {
    background: rgba(255, 255, 255, 0.1);
    color: #f59e0b; /* Default to warning amber */
}

.spark-notification-icon-comment {
    background: rgba(255, 255, 255, 0.1);
    color: #8b5cf6; /* Default to purple */
}

.spark-notification-icon-deleted {
    background: rgba(255, 255, 255, 0.1);
    color: #ef4444; /* Default to danger red */
}

.spark-notification-icon-new-report {
    background: rgba(255, 255, 255, 0.1);
    color: #0ea5e9; /* Default to info blue */
}

/* Notification Content */
.spark-notification-content {
    flex: 1;
    min-width: 0;
}

.spark-notification-message {
    font-size: 0.8125rem;
    font-weight: var(--font-weight-medium);
    color: rgba(255, 255, 255, 0.9);
    line-height: 1.3;
    margin-bottom: 0.25rem;
}

.spark-notification-time {
    display: flex;
    align-items: center;
    gap: 0.25rem;
    font-size: 0.6875rem;
    color: rgba(255, 255, 255, 0.6);
}

.spark-notification-time i {
    font-size: 0.6875rem;
}

/* Mark as Read Button */
.spark-notification-mark-read {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    background: transparent;
    border: none;
    border-radius: 4px;
    color: rgba(255, 255, 255, 0.5);
    cursor: pointer;
    transition: all 0.15s ease;
    opacity: 0;
}

.spark-notification-item:hover .spark-notification-mark-read {
    opacity: 1;
}

.spark-notification-mark-read:hover {
    background: rgba(255, 255, 255, 0.15);
    color: #34d399;
}

/* Empty State */
.spark-notification-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 3rem 2rem;
    text-align: center;
    animation: fadeIn 0.5s ease-out;
}

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

.spark-notification-empty i {
    font-size: 3rem;
    color: rgba(255, 255, 255, 0.4);
    margin-bottom: var(--spacing-4);
    opacity: 0.5;
}

.spark-notification-empty p {
    margin: 0 0 0.25rem 0;
    font-size: 0.9375rem;
    font-weight: var(--font-weight-semibold);
    color: white;
}

.spark-notification-empty small {
    font-size: 0.8125rem;
    color: rgba(255, 255, 255, 0.6);
}

/* Footer */
.spark-notification-footer {
    padding: 0.75rem 0.5rem 0.25rem 0.5rem;
    margin-top: 0.5rem;
    background: transparent;
    border-top: 1px solid rgba(255, 255, 255, 0.05);
    text-align: center;
}

.spark-notification-footer-link {
    display: inline-flex;
    align-items: center;
    gap: var(--spacing-2);
    padding: var(--spacing-2) var(--spacing-4);
    background: transparent;
    border: none;
    border-radius: 4px;
    color: rgba(255, 255, 255, 0.9);
    font-size: 0.8125rem;
    font-weight: var(--font-weight-medium);
    text-decoration: none;
    transition: all 0.15s ease;
}

.spark-notification-footer-link:hover {
    background: rgba(255, 255, 255, 0.1);
    color: white;
}

.spark-notification-footer-link i {
    font-size: 0.75rem;
}

/* ============================================
   Toast Notifications
   ============================================ */

#toast-container {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 12px;
    width: calc(100vw - 48px);
    max-width: 28rem;
}

.spark-toast {
    display: flex;
    align-items: center;
    gap: 10px;
    background: #ffffff;
    border-radius: 2px;
    box-shadow: 0 8px 16px rgba(0, 0, 0, 0.12), 0 0 0 1px rgba(0, 0, 0, 0.04);
    padding: 10px 14px;
    min-height: 72px;
    width: 100%;
    border-left: 4px solid #0078d4;
    animation: slideInRight 0.3s cubic-bezier(0.16, 1, 0.3, 1) forwards;
    position: relative;
    color: #323130;
}

.spark-toast.hiding {
    animation: fadeOut 0.3s ease-in forwards;
}

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

@keyframes fadeOut {
    from {
        opacity: 1;
        transform: translateX(0);
    }
    to {
        opacity: 0;
        transform: translateX(48px);
    }
}

.spark-toast.success {
    border-left-color: #107c10;
}

.spark-toast.danger {
    border-left-color: #d13438;
}

.spark-toast.warning {
    border-left-color: #ffb900;
}

.spark-toast.info {
    border-left-color: #0078d4;
}

.toast-icon {
    flex-shrink: 0;
    font-size: 1.125rem;
    align-self: center;
}

.toast-icon.success {
    color: #107c10;
}

.toast-icon.danger {
    color: #d13438;
}

.toast-icon.warning {
    color: #ffb900;
}

.toast-icon.info {
    color: #0078d4;
}

.toast-content-wrapper {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 1px;
}

.toast-title {
    font-size: 14px;
    line-height: 18px;
    font-weight: 700;
    color: #201f1e;
}

.toast-message-row {
    display: flex;
    align-items: center;
    gap: 8px;
}

.toast-message {
    font-size: 13px;
    line-height: 18px;
    color: #323130;
    flex: 1;
    min-width: 0;
}

.toast-spinner {
    display: none;
    align-items: center;
    justify-content: center;
    color: #0078d4;
    flex-shrink: 0;
}

.spark-toast.is-loading .toast-spinner {
    display: inline-flex;
}

.toast-action-btn {
    align-self: flex-start;
    margin-top: 4px;
    background: #0078d4;
    color: #ffffff;
    border: none;
    border-radius: 2px;
    padding: 5px 10px;
    font-size: 11px;
    line-height: 1;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.15s ease;
}

.toast-action-btn:hover {
    background: #106ebe;
}

.toast-close {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    background: transparent;
    border: none;
    border-radius: 2px;
    color: #8a8886;
    cursor: pointer;
    transition: all 0.15s ease;
    align-self: center;
}

.toast-close:hover {
    background: #f3f2f1;
    color: #323130;
}

.toast-progress {
    position: absolute;
    bottom: 0;
    left: 0;
    height: 3px;
    background: var(--spark-primary);
    width: 100%;
    transform-origin: left;
}

.toast-progress.success {
    background: var(--spark-success);
}

.toast-progress.danger {
    background: var(--spark-danger);
}

.toast-progress.warning {
    background: var(--spark-warning);
}

.toast-progress.info {
    background: var(--spark-info);
}

/* ============================================
   WebSocket Status Indicator
   ============================================ */

.spark-ws-status {
    display: flex;
    align-items: center;
    gap: var(--spacing-2);
    font-size: 0.8125rem;
    color: var(--spark-text-secondary);
}

.spark-ws-status i {
    font-size: 0.625rem;
}

.spark-ws-status-inline {
    margin-left: 0.5rem;
    padding: 0;
    background: transparent;
    border: none;
    border-radius: 0;
    color: rgba(255, 255, 255, 0.9);
    flex-shrink: 0;
}

.spark-ws-status-inline .spark-ws-status-dot {
    font-size: 0.7rem;
    filter: drop-shadow(0 0 6px rgba(255, 255, 255, 0.18));
}

.spark-ws-status.connected i {
    color: var(--spark-success);
    animation: pulse-dot 2s infinite;
}

.spark-ws-status.disconnected i {
    color: var(--spark-danger);
}

.spark-ws-status.connecting i {
    color: var(--spark-warning);
    animation: pulse-dot 1s infinite;
}

.spark-ws-status-inline.connected {
    color: rgba(255, 255, 255, 0.9);
}

.spark-ws-status-inline.disconnected {
    color: rgba(255, 255, 255, 0.9);
}

.spark-ws-status-inline.connecting {
    color: rgba(255, 255, 255, 0.9);
}

@keyframes pulse-dot {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0.5;
    }
}

/* ============================================
   Responsive Design
   ============================================ */

@media (max-width: 768px) {
    .spark-notification-container {
        position: static;
    }
    
    .spark-notification-dropdown {
        position: absolute !important;
        top: 100% !important;
        left: 0 !important;
        right: 0 !important;
        width: 100% !important;
        max-width: none !important;
        border-radius: 0 0 8px 8px !important;
        border-left: none !important;
        border-right: none !important;
        margin-top: 0 !important;
    }
    
    #toast-container {
        right: 16px;
        left: 16px;
        bottom: 16px;
        width: auto;
        max-width: none;
    }
    
    .spark-toast {
        width: 100%;
    }

    .spark-ws-status-inline {
        margin-left: 0.35rem;
        padding: 0;
    }
}

/* ============================================
   Accessibility
   ============================================ */

.spark-notification-trigger:focus,
.btn-spark-text:focus,
.spark-notification-mark-read:focus,
.spark-notification-footer-link:focus {
    outline: 2px solid var(--spark-primary);
    outline-offset: 2px;
}

.spark-notification-trigger:focus:not(:focus-visible),
.btn-spark-text:focus:not(:focus-visible),
.spark-notification-mark-read:focus:not(:focus-visible),
.spark-notification-footer-link:focus:not(:focus-visible) {
    outline: none;
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    .spark-notification-item {
        border: 1px solid currentColor;
    }
    
    .spark-notification-icon {
        border: 2px solid currentColor;
    }
}

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {
    .spark-notification-badge,
    .spark-ws-status.connected i,
    .spark-ws-status.connecting i {
        animation: none;
    }
    
    .spark-toast {
        animation: none;
    }
    
    * {
        transition: none !important;
    }
}
