﻿/* ============================================================
   notifications.css - TOAST NOTIFICATIONS
   ============================================================ */

/* ============================================================
   TOAST CONTAINER
   ============================================================ */
#toastContainer {
    position: fixed;
    bottom: var(--space-4);
    right: var(--space-4);
    z-index: var(--z-toast);
    display: flex;
    flex-direction: column-reverse;
    max-width: 420px;
    width: 100%;
    pointer-events: none;
    gap: var(--space-2);
}

    #toastContainer .toast-notification {
        pointer-events: auto;
    }

/* Toast positions */
#toastContainer--left {
    right: auto;
    left: var(--space-4);
}

    #toastContainer--left .toast-notification {
        animation-name: slideInLeft;
    }

    #toastContainer--left .toast-notification--slide-out {
        animation-name: slideOutLeft;
    }

#toastContainer--top {
    bottom: auto;
    top: calc(var(--header-height) + var(--space-4));
    flex-direction: column;
}

#toastContainer--center {
    right: 50%;
    transform: translateX(50%);
    max-width: 500px;
}

/* ============================================================
   TOAST NOTIFICATION
   ============================================================ */
.toast-notification {
    background: var(--color-surface);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    margin-bottom: var(--space-2);
    min-width: 300px;
    max-width: 420px;
    width: 100%;
    overflow: hidden;
    animation: slideInRight 0.3s ease;
    border: 1px solid var(--color-border-light);
    transition: background var(--transition), border-color var(--transition), box-shadow var(--transition);
}

.toast-notification--slide-out {
    animation: slideOutRight 0.3s ease forwards;
}

/* ============================================================
   TOAST HEADER
   ============================================================ */
.toast-notification__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--space-2) var(--space-3);
    border-bottom: 1px solid var(--color-border-light);
    gap: var(--space-2);
}

.toast-notification__header--primary {
    background: var(--color-primary);
    color: var(--color-text-inverse);
    border-bottom-color: var(--color-primary-dark);
}

.toast-notification__header--success {
    background: var(--color-success);
    color: var(--color-text-inverse);
    border-bottom-color: #4CAF50;
}

.toast-notification__header--warning {
    background: var(--color-warning);
    color: var(--color-text);
    border-bottom-color: #E09D3E;
}

.toast-notification__header--danger {
    background: var(--color-danger);
    color: var(--color-text-inverse);
    border-bottom-color: #B91C1C;
}

.toast-notification__header--info {
    background: var(--color-info);
    color: var(--color-text-inverse);
    border-bottom-color: #4AB0CE;
}

.toast-notification__icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: var(--font-size-lg);
    width: 24px;
    flex-shrink: 0;
}

.toast-notification__title {
    font-weight: var(--font-weight-semibold);
    font-size: var(--font-size-sm);
    margin: 0;
    flex: 1;
    line-height: var(--line-height-tight);
}

.toast-notification__close {
    background: transparent;
    border: none;
    color: inherit;
    padding: var(--space-1);
    cursor: pointer;
    border-radius: var(--radius-sm);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    transition: background var(--transition-fast), opacity var(--transition-fast);
    font-size: var(--font-size-lg);
    line-height: 1;
    opacity: 0.7;
    flex-shrink: 0;
}

    .toast-notification__close:hover {
        opacity: 1;
        background: rgba(0, 0, 0, 0.1);
    }

.toast-notification__header--primary .toast-notification__close:hover,
.toast-notification__header--success .toast-notification__close:hover,
.toast-notification__header--danger .toast-notification__close:hover,
.toast-notification__header--info .toast-notification__close:hover {
    background: rgba(255, 255, 255, 0.2);
}

.toast-notification__header--warning .toast-notification__close:hover {
    background: rgba(0, 0, 0, 0.1);
}

/* ============================================================
   TOAST BODY
   ============================================================ */
.toast-notification__body {
    padding: var(--space-3) var(--space-3);
    font-size: var(--font-size-sm);
    color: var(--color-text);
    line-height: var(--line-height-normal);
}

    .toast-notification__body strong {
        color: var(--color-text);
        font-weight: var(--font-weight-semibold);
    }

/* ============================================================
   TOAST ACTION
   ============================================================ */
.toast-notification__action {
    display: inline-block;
    margin-top: var(--space-2);
    padding: var(--space-1) var(--space-3);
    font-size: var(--font-size-xs);
    font-weight: var(--font-weight-medium);
    color: var(--color-text-inverse);
    background: var(--color-primary);
    border: none;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: background var(--transition-fast);
    text-decoration: none;
    text-align: center;
    min-height: var(--control-min-height-sm);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-1);
}

    .toast-notification__action:hover {
        background: var(--color-primary-dark);
        color: var(--color-text-inverse);
        text-decoration: none;
    }

.toast-notification__action--full {
    width: 100%;
}

/* ============================================================
   TOAST VARIANTS
   ============================================================ */
.toast-notification--no-header .toast-notification__body {
    padding-top: var(--space-3);
}

.toast-notification--accent {
    border-left: 4px solid var(--color-primary);
}

    .toast-notification--accent.toast-notification--success {
        border-left-color: var(--color-success);
    }

    .toast-notification--accent.toast-notification--warning {
        border-left-color: var(--color-warning);
    }

    .toast-notification--accent.toast-notification--danger {
        border-left-color: var(--color-danger);
    }

    .toast-notification--accent.toast-notification--info {
        border-left-color: var(--color-info);
    }

/* ============================================================
   TOAST PROGRESS
   ============================================================ */
.toast-notification__progress {
    height: 3px;
    background: var(--color-border);
    overflow: hidden;
    position: relative;
}

.toast-notification__progress-bar {
    height: 100%;
    background: var(--color-primary);
    border-radius: 0 2px 2px 0;
}

.toast-notification--success .toast-notification__progress-bar {
    background: var(--color-success);
}

.toast-notification--warning .toast-notification__progress-bar {
    background: var(--color-warning);
}

.toast-notification--danger .toast-notification__progress-bar {
    background: var(--color-danger);
}

.toast-notification--info .toast-notification__progress-bar {
    background: var(--color-info);
}

/* ============================================================
   TOAST PROGRESS BAR - Animation
   ============================================================ */
.toast-notification__progress-bar--animating {
    animation: toast-progress var(--toast-duration, 5000ms) linear forwards;
}

@keyframes toast-progress {
    from {
        width: 100%;
    }

    to {
        width: 0%;
    }
}

@media (prefers-reduced-motion: reduce) {
    .toast-notification__progress-bar--animating {
        animation: none;
        width: 0%;
    }
}

/* ============================================================
   TOAST ANIMATIONS
   ============================================================ */
@keyframes slideInRight {
    from {
        transform: translateX(calc(100% + var(--space-4)));
        opacity: 0;
    }

    to {
        transform: translateX(0);
        opacity: 1;
    }
}

@keyframes slideOutRight {
    from {
        transform: translateX(0);
        opacity: 1;
    }

    to {
        transform: translateX(calc(100% + var(--space-4)));
        opacity: 0;
    }
}

@keyframes slideInLeft {
    from {
        transform: translateX(calc(-100% - var(--space-4)));
        opacity: 0;
    }

    to {
        transform: translateX(0);
        opacity: 1;
    }
}

@keyframes slideOutLeft {
    from {
        transform: translateX(0);
        opacity: 1;
    }

    to {
        transform: translateX(calc(-100% - var(--space-4)));
        opacity: 0;
    }
}

/* ============================================================
   RESPONSIVE
   ============================================================ */
@media (max-width: 575.98px) {
    #toastContainer {
        bottom: var(--space-2);
        right: var(--space-2);
        max-width: calc(100vw - var(--space-4));
    }

    #toastContainer--left {
        left: var(--space-2);
        right: var(--space-2);
        max-width: calc(100vw - var(--space-4));
    }

    #toastContainer--center {
        right: var(--space-2);
        left: var(--space-2);
        transform: none;
        max-width: calc(100vw - var(--space-4));
    }

    .toast-notification {
        min-width: auto;
        max-width: 100%;
        border-radius: var(--radius-sm);
    }

    .toast-notification__header {
        padding: var(--space-2);
    }

    .toast-notification__body {
        padding: var(--space-2);
        font-size: var(--font-size-xs);
    }

    .toast-notification__action {
        font-size: var(--font-size-xs);
        min-height: var(--touch-target-min);
        padding: var(--space-1) var(--space-2);
    }
}

@media (min-width: 576px) and (max-width: 767.98px) {
    .toast-notification {
        min-width: 280px;
    }
}

/* ============================================================
   DARK MODE
   ============================================================ */
[data-theme="dark"] .toast-notification {
    border-color: var(--color-border);
}

[data-theme="dark"] .toast-notification__header {
    border-bottom-color: var(--color-border);
}

[data-theme="dark"] .toast-notification__header--warning {
    color: var(--color-text);
}

[data-theme="dark"] .toast-notification__body {
    color: var(--color-text-secondary);
}

    [data-theme="dark"] .toast-notification__body strong {
        color: var(--color-text);
    }

[data-theme="dark"] .toast-notification__close:hover {
    background: rgba(255, 255, 255, 0.1);
}

[data-theme="dark"] .toast-notification__header--warning .toast-notification__close:hover {
    background: rgba(0, 0, 0, 0.2);
}

[data-theme="dark"] .toast-notification__progress {
    background: var(--color-border);
}

@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) .toast-notification {
        border-color: var(--color-border);
    }

    :root:not([data-theme="light"]) .toast-notification__header {
        border-bottom-color: var(--color-border);
    }

    :root:not([data-theme="light"]) .toast-notification__header--warning {
        color: var(--color-text);
    }

    :root:not([data-theme="light"]) .toast-notification__body {
        color: var(--color-text-secondary);
    }

        :root:not([data-theme="light"]) .toast-notification__body strong {
            color: var(--color-text);
        }

    :root:not([data-theme="light"]) .toast-notification__close:hover {
        background: rgba(255, 255, 255, 0.1);
    }

    :root:not([data-theme="light"]) .toast-notification__header--warning .toast-notification__close:hover {
        background: rgba(0, 0, 0, 0.2);
    }

    :root:not([data-theme="light"]) .toast-notification__progress {
        background: var(--color-border);
    }
}

/* ============================================================
   NOTIFICATION BADGE - Header
   ============================================================ */
.app-header__notification-link {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: var(--color-text-inverse);
    padding: var(--space-1);
    font-size: var(--font-size-lg);
    text-decoration: none;
    transition: opacity var(--transition-fast);
    min-height: var(--touch-target-min);
    min-width: var(--touch-target-min);
}

    .app-header__notification-link:hover {
        color: var(--color-text-inverse);
        opacity: 0.8;
    }

.notification-badge {
    position: absolute;
    top: -2px;
    right: -2px;
    background: var(--color-danger);
    color: var(--color-text-inverse);
    font-size: 0.6rem;
    font-weight: var(--font-weight-bold);
    min-width: 18px;
    height: 18px;
    border-radius: var(--radius-full);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 5px;
    line-height: 1;
    box-shadow: 0 2px 8px rgba(217, 83, 79, 0.3);
    animation: badge-pulse 2s ease-in-out infinite;
}

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

    50% {
        transform: scale(1.1);
    }
}

/* Reduced motion for badge */
@media (prefers-reduced-motion: reduce) {
    .notification-badge {
        animation: none;
    }
}


/* ============================================================
   DRAFT RECOVERY MODAL
   ============================================================ */

.draft-recovery-modal .modal-content {
    border: 1px solid var(--color-border-light);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-xl);
    overflow: hidden;
}

/* ---------- HEADER ---------- */
.draft-recovery-modal__header {
    background: var(--color-surface-alt);
    border-bottom: 1px solid var(--color-border-light);
    padding: var(--space-4) var(--space-4);
    align-items: flex-start;
}

.draft-recovery-modal__icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    border-radius: var(--radius-md);
    background: var(--color-warning-light);
    color: var(--color-warning);
    font-size: var(--font-size-lg);
    flex-shrink: 0;
}

[data-theme="dark"] .draft-recovery-modal__icon {
    background: rgba(240, 173, 78, 0.15);
    color: var(--color-warning);
}

.draft-recovery-modal__subtitle {
    font-size: var(--font-size-sm);
    color: var(--color-text-muted);
    margin-top: 2px;
}

/* ---------- SUMMARY STRIP ---------- */
.draft-recovery-modal__summary {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: var(--space-3);
    padding: var(--space-3) var(--space-4);
    background: var(--color-surface-alt);
    border: 1px solid var(--color-border-light);
    border-radius: var(--radius-md);
    margin-bottom: var(--space-4);
}

.draft-recovery-modal__summary-item {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
}

.draft-recovery-modal__summary-label {
    font-size: var(--font-size-xs);
    font-weight: var(--font-weight-semibold);
    letter-spacing: var(--letter-spacing-wide);
    text-transform: uppercase;
    color: var(--color-text-muted);
}

.draft-recovery-modal__summary-value {
    font-size: var(--font-size-sm);
    font-weight: var(--font-weight-semibold);
    color: var(--color-text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* ---------- PREVIEW TABLE ---------- */
.draft-recovery-modal__preview-wrap {
    border: 1px solid var(--color-border-light);
    border-radius: var(--radius-md);
    overflow: hidden;
    margin-bottom: var(--space-4);
}

.draft-recovery-modal__preview-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--space-2) var(--space-3);
    background: var(--color-surface-alt);
    border-bottom: 1px solid var(--color-border-light);
    gap: var(--space-2);
}

.draft-recovery-modal__preview-body {
    max-height: 260px;
    overflow-y: auto;
}

    .draft-recovery-modal__preview-body .table {
        margin-bottom: 0;
        font-size: var(--font-size-sm);
    }

    .draft-recovery-modal__preview-body thead th {
        position: sticky;
        top: 0;
        background: var(--color-surface);
        z-index: 1;
        font-size: var(--font-size-xs);
        font-weight: var(--font-weight-semibold);
        letter-spacing: var(--letter-spacing-wide);
        text-transform: uppercase;
        color: var(--color-text-muted);
        border-bottom: 1px solid var(--color-border-light);
    }

    .draft-recovery-modal__preview-body tbody td {
        padding: var(--space-2) var(--space-3);
        vertical-align: middle;
    }

    .draft-recovery-modal__preview-body tbody tr:last-child td {
        border-bottom: 0;
    }

    .draft-recovery-modal__preview-body .draft-value {
        font-family: var(--font-family-monospace);
        font-size: var(--font-size-sm);
        font-weight: var(--font-weight-semibold);
        color: var(--color-primary);
        background: var(--color-primary-light);
        padding: 2px 6px;
        border-radius: var(--radius-xs);
        display: inline-block;
        min-width: 32px;
    }

    .draft-recovery-modal__preview-body .draft-value--empty {
        color: var(--color-text-light);
        background: transparent;
        font-weight: var(--font-weight-regular);
    }

/* ---------- INFO NOTE ---------- */
.draft-recovery-modal__note {
    display: flex;
    align-items: flex-start;
    gap: var(--space-2);
    padding: var(--space-3);
    background: var(--color-info-light);
    border-left: 3px solid var(--color-info);
    border-radius: var(--radius-sm);
    font-size: var(--font-size-sm);
    color: var(--color-text-secondary);
    line-height: var(--line-height-normal);
}

[data-theme="dark"] .draft-recovery-modal__note {
    background: rgba(91, 192, 222, 0.1);
}

.draft-recovery-modal__note i {
    color: var(--color-info);
    margin-top: 2px;
    flex-shrink: 0;
}

/* ---------- FOOTER ---------- */
.draft-recovery-modal__footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: var(--space-2);
    padding: var(--space-3) var(--space-4);
    border-top: 1px solid var(--color-border-light);
    background: var(--color-surface-alt);
}

    .draft-recovery-modal__footer .btn {
        min-width: 0;
    }

/* ---------- RESPONSIVE ---------- */
@media (max-width: 575.98px) {
    .draft-recovery-modal__summary {
        grid-template-columns: 1fr 1fr;
    }

    .draft-recovery-modal__summary-item:last-child {
        grid-column: 1 / -1;
    }

    .draft-recovery-modal__footer {
        flex-direction: column-reverse;
        align-items: stretch;
    }

        .draft-recovery-modal__footer .btn {
            width: 100%;
        }
}

/* ---------- REDUCED MOTION ---------- */
@media (prefers-reduced-motion: reduce) {
    .draft-recovery-modal .modal-content {
        transition: none;
    }
}