/**
 * Notification Toast Styles for DocuTrak
 * Unified toast system for all operations
 */

/* ─────────────────────────────────────────────────────────────────────
   Container
   ───────────────────────────────────────────────────────────────────── */

.notification-container {
    position: fixed;
    bottom: 1rem;
    right: 1rem;
    z-index: 9999;
    max-width: 420px;
    width: calc(100vw - 2rem);
}

/* Mobile adjustments */
@media (max-width: 576px) {
    .notification-container {
        left: 1rem;
        right: 1rem;
        bottom: 0;
        max-width: 100%;
        width: auto;
    }
}

/* ─────────────────────────────────────────────────────────────────────
   Toast Base
   ───────────────────────────────────────────────────────────────────── */

.notification-toast {
    margin-bottom: 0.75rem;
    animation: slideInRight 0.3s ease-out;
    border-left: 4px solid transparent;
    min-width: 300px;
}

.notification-toast:last-child {
    margin-bottom: 0;
}

/* ─────────────────────────────────────────────────────────────────────
   Animations
   ───────────────────────────────────────────────────────────────────── */

@keyframes slideInRight {
    from {
        transform: translateX(120%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

@keyframes slideOutRight {
    from {
        transform: translateX(0);
        opacity: 1;
    }
    to {
        transform: translateX(120%);
        opacity: 0;
    }
}

.notification-toast.hide {
    animation: slideOutRight 0.3s ease-in;
}

/* Respect reduced motion preference */
@media (prefers-reduced-motion: reduce) {
    .notification-toast {
        animation: none !important;
        transition: none !important;
    }
}

/* ─────────────────────────────────────────────────────────────────────
   Toast Types - Color Schemes
   ───────────────────────────────────────────────────────────────────── */

/* Success - Green */
.notification-toast-success {
    background: linear-gradient(135deg, #d4edda 0%, #c3e6cb 100%);
    border-left-color: #28a745;
    color: #155724;
}

.notification-toast-success .notification-icon {
    color: #28a745;
}

.notification-toast-success .btn-close {
    filter: invert(0.4) sepia(1) saturate(5) hue-rotate(85deg);
}

/* Error/Danger - Red */
.notification-toast-danger {
    background: linear-gradient(135deg, #f8d7da 0%, #f5c6cb 100%);
    border-left-color: #dc3545;
    color: #721c24;
}

.notification-toast-danger .notification-icon {
    color: #dc3545;
}

.notification-toast-danger .btn-close {
    filter: invert(0.3) sepia(1) saturate(5) hue-rotate(315deg);
}

/* Warning - Yellow/Orange */
.notification-toast-warning {
    background: linear-gradient(135deg, #fff3cd 0%, #ffeeba 100%);
    border-left-color: #ffc107;
    color: #856404;
}

.notification-toast-warning .notification-icon {
    color: #ffc107;
}

.notification-toast-warning .btn-close {
    filter: invert(0.4) sepia(1) saturate(5) hue-rotate(20deg);
}

/* Info - Blue */
.notification-toast-info {
    background: linear-gradient(135deg, #d1ecf1 0%, #bee5eb 100%);
    border-left-color: #17a2b8;
    color: #0c5460;
}

.notification-toast-info .notification-icon {
    color: #17a2b8;
}

.notification-toast-info .btn-close {
    filter: invert(0.4) sepia(1) saturate(5) hue-rotate(160deg);
}

/* Loading - Blue with subtle pulse */
.notification-toast-loading {
    background: linear-gradient(135deg, #e3f2fd 0%, #bbdefb 100%);
    border-left-color: #2196F3;
    color: #0d47a1;
}

.notification-toast-loading .notification-icon {
    color: #2196F3;
}

.notification-toast-loading {
    animation: slideInRight 0.3s ease-out, pulse 2s infinite;
}

@keyframes pulse {
    0%, 100% {
        box-shadow: 0 0 0 0 rgba(33, 150, 243, 0.4);
    }
    50% {
        box-shadow: 0 0 0 4px rgba(33, 150, 243, 0);
    }
}

/* ─────────────────────────────────────────────────────────────────────
   Toast Content
   ───────────────────────────────────────────────────────────────────── */

.notification-toast .toast-body {
    padding: 0.75rem 1rem;
}

.notification-icon {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
}

.notification-content {
    min-width: 0; /* Allow text truncation */
}

.notification-message {
    word-break: break-word;
    line-height: 1.4;
}

/* ─────────────────────────────────────────────────────────────────────
   Progress Bar
   ───────────────────────────────────────────────────────────────────── */

.notification-progress {
    margin-top: 0.5rem;
    height: 6px;
    background-color: rgba(0, 0, 0, 0.1);
    border-radius: 3px;
    overflow: hidden;
}

.notification-progress .progress-bar {
    background: linear-gradient(90deg, #2196F3 0%, #1976D2 100%);
    transition: width 0.3s ease;
}

.notification-toast-success .notification-progress .progress-bar {
    background: linear-gradient(90deg, #28a745 0%, #218838 100%);
}

.notification-toast-danger .notification-progress .progress-bar {
    background: linear-gradient(90deg, #dc3545 0%, #c82333 100%);
}

/* ─────────────────────────────────────────────────────────────────────
   Action Buttons
   ───────────────────────────────────────────────────────────────────── */

.notification-actions {
    display: flex;
    gap: 0.5rem;
    margin-top: 0.75rem;
}

.notification-actions .btn {
    padding: 0.25rem 0.75rem;
    font-size: 0.875rem;
    font-weight: 600;
}

.notification-toast-success .notification-actions .btn-link {
    color: #155724;
    text-decoration: underline;
}

.notification-toast-success .notification-actions .btn-link:hover {
    color: #0a3d17;
}

.notification-toast-danger .notification-actions .btn-link {
    color: #721c24;
    text-decoration: underline;
}

.notification-toast-danger .notification-actions .btn-link:hover {
    color: #491217;
}

.notification-toast-warning .notification-actions .btn-link {
    color: #856404;
    text-decoration: underline;
}

.notification-toast-warning .notification-actions .btn-link:hover {
    color: #533f03;
}

.notification-toast-info .notification-actions .btn-link {
    color: #0c5460;
    text-decoration: underline;
}

.notification-toast-info .notification-actions .btn-link:hover {
    color: #062a30;
}

/* ─────────────────────────────────────────────────────────────────────
   Close Button
   ───────────────────────────────────────────────────────────────────── */

.notification-toast .btn-close {
    flex-shrink: 0;
    padding: 0.5rem;
    opacity: 0.6;
}

.notification-toast .btn-close:hover {
    opacity: 1;
}

/* ─────────────────────────────────────────────────────────────────────
   Stacking & Overflow
   ───────────────────────────────────────────────────────────────────── */

.notification-container .notification-toast:nth-child(n+6) {
    /* Hide toasts beyond the 5th one */
    display: none;
}

/* Show count badge when toasts are hidden */
.notification-container.has-overflow::before {
    content: attr(data-overflow-count) " more";
    display: block;
    background: rgba(0, 0, 0, 0.75);
    color: white;
    padding: 0.5rem 1rem;
    border-radius: 0.25rem;
    text-align: center;
    font-size: 0.875rem;
    margin-bottom: 0.75rem;
}

/* ─────────────────────────────────────────────────────────────────────
   Dark Mode Support (optional)
   ───────────────────────────────────────────────────────────────────── */

@media (prefers-color-scheme: dark) {
    .notification-toast-success {
        background: linear-gradient(135deg, #1e4620 0%, #2d5a2e 100%);
        color: #c3e6cb;
    }

    .notification-toast-danger {
        background: linear-gradient(135deg, #4a1c1c 0%, #5a2a2a 100%);
        color: #f5c6cb;
    }

    .notification-toast-warning {
        background: linear-gradient(135deg, #4a3d0f 0%, #5a4b1a 100%);
        color: #ffeeba;
    }

    .notification-toast-info {
        background: linear-gradient(135deg, #1a3a4a 0%, #2a4a5a 100%);
        color: #bee5eb;
    }

    .notification-toast-loading {
        background: linear-gradient(135deg, #1e3a5f 0%, #2d4a6f 100%);
        color: #bbdefb;
    }
}

/* ─────────────────────────────────────────────────────────────────────
   High Contrast Mode
   ───────────────────────────────────────────────────────────────────── */

@media (prefers-contrast: high) {
    .notification-toast {
        border: 2px solid currentColor;
    }

    .notification-toast-success {
        background: #d4edda;
        color: #000;
    }

    .notification-toast-danger {
        background: #f8d7da;
        color: #000;
    }

    .notification-toast-warning {
        background: #fff3cd;
        color: #000;
    }

    .notification-toast-info {
        background: #d1ecf1;
        color: #000;
    }

    .notification-toast-loading {
        background: #e3f2fd;
        color: #000;
    }
}

/* ─────────────────────────────────────────────────────────────────────
   Print Styles - Hide toasts when printing
   ───────────────────────────────────────────────────────────────────── */

@media print {
    .notification-container {
        display: none !important;
    }
}

/* ============================================
   NOTIFICATION PANEL STYLES
   Enterprise-grade notification dropdown panel
   inspired by Azure Portal & GitHub
   ============================================ */

/* ─── Notification Badge ─────────────────── */
.notification-badge {
    position: absolute;
    top: 2px;
    right: 2px;
    min-width: 18px;
    height: 18px;
    padding: 0 5px;
    font-size: 0.65rem;
    font-weight: 600;
    line-height: 18px;
    text-align: center;
    color: white;
    background-color: var(--color-danger, #dc3545);
    border-radius: 9px;
    animation: badge-pulse 2s infinite;
}

.notification-badge.has-many {
    min-width: 24px;
}

@keyframes badge-pulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.1); }
}

/* ─── Notification Bell Button ──────────── */
.notification-bell-btn {
    position: relative;
}

.notification-bell-btn::after {
    display: none !important; /* Hide dropdown caret */
}

.notification-bell-btn:hover {
    background-color: var(--color-surface-hover, rgba(0,0,0,0.05));
}

/* ─── Notification Dropdown ─────────────── */
.notification-dropdown .dropdown-toggle::after {
    display: none;
}

/* ─── Notification Panel ────────────────── */
.notification-panel {
    width: 380px;
    max-width: calc(100vw - 2rem);
    padding: 0;
    border: 1px solid var(--color-border, #e5e5e5);
    border-radius: 8px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.12);
    overflow: hidden;
}

[data-bs-theme="dark"] .notification-panel {
    background-color: var(--color-surface, #1f1f1f);
    border-color: var(--color-border, #333);
}

/* ─── Panel Header ──────────────────────── */
.notification-panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    border-bottom: 1px solid var(--color-border, #e5e5e5);
    background-color: var(--color-surface, #fff);
}

.notification-panel-title {
    margin: 0;
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--color-text-primary, #333);
}

#mark-all-read-btn {
    color: var(--color-text-secondary, #666);
    text-decoration: none;
}

#mark-all-read-btn:hover {
    color: var(--color-primary, #0078d4);
}

/* ─── Filter Tabs ───────────────────────── */
.notification-tabs {
    display: flex;
    padding: 8px 16px;
    gap: 8px;
    border-bottom: 1px solid var(--color-border, #e5e5e5);
    background-color: var(--color-surface-alt, #f8f9fa);
}

.notification-tab {
    padding: 6px 12px;
    font-size: 0.8rem;
    font-weight: 500;
    color: var(--color-text-secondary, #666);
    background: none;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.15s ease;
}

.notification-tab:hover {
    background-color: var(--color-surface-hover, rgba(0,0,0,0.05));
}

.notification-tab.active {
    color: var(--color-primary, #0078d4);
    background-color: var(--color-primary-bg, rgba(0, 120, 212, 0.1));
}

/* ─── Notification List ─────────────────── */
.notification-list {
    max-height: 400px;
    overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-color: var(--color-border) transparent;
}

.notification-list::-webkit-scrollbar {
    width: 6px;
}

.notification-list::-webkit-scrollbar-track {
    background: transparent;
}

.notification-list::-webkit-scrollbar-thumb {
    background-color: var(--color-border, #ccc);
    border-radius: 3px;
}

/* ─── Empty State ───────────────────────── */
.notification-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 40px 20px;
    color: var(--color-text-secondary, #666);
}

.notification-empty i {
    font-size: 2.5rem;
    margin-bottom: 12px;
    opacity: 0.4;
}

.notification-empty p {
    margin: 0;
    font-size: 0.875rem;
}

/* ─── Notification Item ─────────────────── */
.notification-item {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 12px 16px;
    border-bottom: 1px solid var(--color-border-light, #f0f0f0);
    cursor: pointer;
    transition: background-color 0.15s ease;
    position: relative;
}

.notification-item:hover {
    background-color: var(--color-surface-hover, rgba(0,0,0,0.02));
}

.notification-item:last-child {
    border-bottom: none;
}

.notification-item.unread {
    background-color: var(--color-primary-bg, rgba(0, 120, 212, 0.04));
}

.notification-item.unread::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 3px;
    background-color: var(--color-primary, #0078d4);
}

/* ─── Notification Icon (Panel) ─────────── */
.notification-item .notification-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    flex-shrink: 0;
    font-size: 1rem;
}

.notification-icon.category-document,
.notification-icon.category-Document {
    background-color: rgba(0, 120, 212, 0.1);
    color: #0078d4;
}

.notification-icon.category-workflow,
.notification-icon.category-Workflow {
    background-color: rgba(16, 124, 16, 0.1);
    color: #107c10;
}

.notification-icon.category-directory,
.notification-icon.category-Directory {
    background-color: rgba(255, 140, 0, 0.1);
    color: #ff8c00;
}

.notification-icon.category-user,
.notification-icon.category-User {
    background-color: rgba(136, 23, 152, 0.1);
    color: #881798;
}

.notification-icon.category-admin,
.notification-icon.category-Admin {
    background-color: rgba(117, 117, 117, 0.1);
    color: #757575;
}

.notification-icon.category-system,
.notification-icon.category-System {
    background-color: rgba(196, 43, 28, 0.1);
    color: #c42b1c;
}

.notification-icon.category-collaboration,
.notification-icon.category-Collaboration {
    background-color: rgba(0, 183, 195, 0.1);
    color: #00b7c3;
}

/* ─── Notification Content (Panel) ──────── */
.notification-item .notification-content {
    flex: 1;
    min-width: 0;
}

.notification-title {
    margin: 0 0 4px;
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--color-text-primary, #333);
    line-height: 1.3;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.notification-item.unread .notification-title {
    font-weight: 600;
}

.notification-description {
    margin: 0 0 4px;
    font-size: 0.8rem;
    color: var(--color-text-secondary, #666);
    line-height: 1.4;
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
}

.notification-meta {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.75rem;
    color: var(--color-text-tertiary, #999);
}

.notification-actor {
    display: flex;
    align-items: center;
    gap: 4px;
}

.notification-time {
    display: flex;
    align-items: center;
    gap: 4px;
}

/* ─── Notification Item Actions ─────────── */
.notification-item-actions {
    display: flex;
    align-items: center;
    gap: 4px;
    opacity: 0;
    transition: opacity 0.15s ease;
}

.notification-item:hover .notification-item-actions {
    opacity: 1;
}

.notification-action-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    padding: 0;
    font-size: 0.85rem;
    color: var(--color-text-secondary, #666);
    background: none;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.15s ease;
}

.notification-action-btn:hover {
    color: var(--color-primary, #0078d4);
    background-color: var(--color-surface-hover, rgba(0,0,0,0.05));
}

/* ─── Panel Footer ──────────────────────── */
.notification-panel-footer {
    padding: 8px 16px;
    border-top: 1px solid var(--color-border, #e5e5e5);
    background-color: var(--color-surface-alt, #f8f9fa);
}

.notification-panel-footer .btn {
    font-size: 0.8rem;
    color: var(--color-primary, #0078d4);
}

/* ─── Priority Indicators ───────────────── */
.notification-item.priority-urgent .notification-title::before,
.notification-item.priority-Urgent .notification-title::before {
    content: '';
    display: inline-block;
    width: 8px;
    height: 8px;
    margin-right: 6px;
    background-color: var(--color-danger, #dc3545);
    border-radius: 50%;
}

.notification-item.priority-high .notification-title::before,
.notification-item.priority-High .notification-title::before {
    content: '';
    display: inline-block;
    width: 8px;
    height: 8px;
    margin-right: 6px;
    background-color: var(--color-warning, #ffc107);
    border-radius: 50%;
}

/* ─── Loading State ─────────────────────── */
.notification-loading {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 30px;
}

.notification-loading .spinner-border {
    width: 1.5rem;
    height: 1.5rem;
}

/* ─── Animation for new notifications ───── */
@keyframes notification-slide-in {
    from {
        opacity: 0;
        transform: translateX(20px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

.notification-item.new {
    animation: notification-slide-in 0.3s ease;
}

/* ─── Responsive Adjustments (Panel) ────── */
@media (max-width: 576px) {
    .notification-panel {
        width: 100%;
        max-width: none;
        border-radius: 0;
        position: fixed;
        top: 60px;
        left: 0;
        right: 0;
        max-height: calc(100vh - 60px);
    }

    .notification-list {
        max-height: calc(100vh - 200px);
    }
}

/* ─── Full Notification Center Page ─────── */
.notification-center {
    max-width: 800px;
    margin: 0 auto;
}

.notification-center .notification-item {
    border-radius: 8px;
    margin-bottom: 8px;
    border: 1px solid var(--color-border, #e5e5e5);
}

.notification-center .notification-item:hover {
    border-color: var(--color-primary, #0078d4);
}

/* ─── Dark Mode Adjustments (Panel) ─────── */
[data-bs-theme="dark"] .notification-panel-header,
[data-bs-theme="dark"] .notification-tabs,
[data-bs-theme="dark"] .notification-panel-footer {
    background-color: var(--color-surface-alt, #2d2d2d);
}

[data-bs-theme="dark"] .notification-item:hover {
    background-color: rgba(255, 255, 255, 0.03);
}

[data-bs-theme="dark"] .notification-item.unread {
    background-color: rgba(0, 120, 212, 0.08);
}
