/* ==========================================================================
   USER APP — ALERTS
   File: user_app/assets/css/alerts.css
   Purpose:
   - Global alert/message components
   - Success, error, warning, info states
   - Inline validation messages
   - Dismissible alerts
   - Banners and toast-style notifications
   - Loading/status alerts
   - Responsive + accessibility support

   Depends on:
   - variables.css
   - reset.css
   - base.css
   - buttons.css
   ========================================================================== */


/* ==========================================================================
   1. ALERT ROOT
   ========================================================================== */

.alert {
    position: relative;
    display: flex;
    align-items: flex-start;
    gap: var(--space-3, 12px);

    width: 100%;
    padding: var(--space-4, 16px);

    color: var(--color-text, #1f2937);
    background: var(--color-surface, #ffffff);

    border: 1px solid var(--color-border, #e5e7eb);
    border-radius: var(--radius-md, 8px);

    font-size: var(--font-size-sm, 14px);
    line-height: 1.5;

    box-sizing: border-box;
}

.alert + .alert {
    margin-top: var(--space-3, 12px);
}


/* ==========================================================================
   2. ALERT CONTENT
   ========================================================================== */

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

.alert-title {
    display: block;

    margin: 0 0 var(--space-1, 4px);

    color: inherit;
    font-size: var(--font-size-md, 15px);
    font-weight: var(--font-weight-semibold, 600);
    line-height: 1.4;
}

.alert-message {
    margin: 0;

    color: inherit;
    font-size: inherit;
    line-height: inherit;
}

.alert-message p {
    margin: 0;
}

.alert-message p + p {
    margin-top: var(--space-2, 8px);
}

.alert-message a {
    color: inherit;
    font-weight: var(--font-weight-semibold, 600);
    text-decoration: underline;
    text-underline-offset: 2px;
}

.alert-message a:hover {
    text-decoration-thickness: 2px;
}


/* ==========================================================================
   3. ALERT ICON
   ========================================================================== */

.alert-icon {
    flex: 0 0 auto;

    display: inline-flex;
    align-items: center;
    justify-content: center;

    width: 20px;
    height: 20px;

    color: currentColor;
    font-size: 18px;
    line-height: 1;

    margin-top: 1px;
}

.alert-icon svg {
    display: block;

    width: 100%;
    height: 100%;

    fill: none;
    stroke: currentColor;
    stroke-width: 2;
}

.alert-icon img {
    display: block;

    width: 100%;
    height: 100%;

    object-fit: contain;
}


/* ==========================================================================
   4. ALERT CLOSE BUTTON
   ========================================================================== */

.alert-close {
    flex: 0 0 auto;

    display: inline-flex;
    align-items: center;
    justify-content: center;

    width: 32px;
    height: 32px;

    margin: -4px -4px 0 0;
    padding: 0;

    color: currentColor;
    background: transparent;

    border: 0;
    border-radius: var(--radius-sm, 6px);

    font-size: 18px;
    line-height: 1;

    cursor: pointer;

    opacity: 0.75;

    transition:
        background-color 160ms ease,
        opacity 160ms ease,
        transform 160ms ease;
}

.alert-close:hover {
    opacity: 1;
    background: rgba(0, 0, 0, 0.06);
}

.alert-close:active {
    transform: scale(0.96);
}

.alert-close:focus-visible {
    outline: 2px solid currentColor;
    outline-offset: 2px;
}


/* ==========================================================================
   5. SUCCESS
   ========================================================================== */

.alert-success {
    color: var(--color-success-text, #166534);
    background: var(--color-success-bg, #f0fdf4);
    border-color: var(--color-success-border, #bbf7d0);
}

.alert-success .alert-icon {
    color: var(--color-success, #16a34a);
}


/* ==========================================================================
   6. ERROR / DANGER
   ========================================================================== */

.alert-error,
.alert-danger {
    color: var(--color-danger-text, #991b1b);
    background: var(--color-danger-bg, #fef2f2);
    border-color: var(--color-danger-border, #fecaca);
}

.alert-error .alert-icon,
.alert-danger .alert-icon {
    color: var(--color-danger, #dc2626);
}


/* ==========================================================================
   7. WARNING
   ========================================================================== */

.alert-warning {
    color: var(--color-warning-text, #92400e);
    background: var(--color-warning-bg, #fffbeb);
    border-color: var(--color-warning-border, #fde68a);
}

.alert-warning .alert-icon {
    color: var(--color-warning, #d97706);
}


/* ==========================================================================
   8. INFO
   ========================================================================== */

.alert-info {
    color: var(--color-info-text, #1e40af);
    background: var(--color-info-bg, #eff6ff);
    border-color: var(--color-info-border, #bfdbfe);
}

.alert-info .alert-icon {
    color: var(--color-info, #2563eb);
}


/* ==========================================================================
   9. NEUTRAL
   ========================================================================== */

.alert-neutral {
    color: var(--color-text, #374151);
    background: var(--color-surface-muted, #f9fafb);
    border-color: var(--color-border, #e5e7eb);
}

.alert-neutral .alert-icon {
    color: var(--color-text-muted, #6b7280);
}


/* ==========================================================================
   10. LIGHT / SOFT VARIANTS
   ========================================================================== */

.alert-soft {
    border-color: transparent;
}

.alert-success.alert-soft {
    background: var(--color-success-bg, #f0fdf4);
}

.alert-error.alert-soft,
.alert-danger.alert-soft {
    background: var(--color-danger-bg, #fef2f2);
}

.alert-warning.alert-soft {
    background: var(--color-warning-bg, #fffbeb);
}

.alert-info.alert-soft {
    background: var(--color-info-bg, #eff6ff);
}


/* ==========================================================================
   11. OUTLINE VARIANTS
   ========================================================================== */

.alert-outline {
    background: transparent;
}

.alert-success.alert-outline {
    color: var(--color-success-text, #166534);
    border-color: var(--color-success, #16a34a);
}

.alert-error.alert-outline,
.alert-danger.alert-outline {
    color: var(--color-danger-text, #991b1b);
    border-color: var(--color-danger, #dc2626);
}

.alert-warning.alert-outline {
    color: var(--color-warning-text, #92400e);
    border-color: var(--color-warning, #d97706);
}

.alert-info.alert-outline {
    color: var(--color-info-text, #1e40af);
    border-color: var(--color-info, #2563eb);
}


/* ==========================================================================
   12. SOLID ALERTS
   ========================================================================== */

.alert-solid {
    color: var(--color-white, #ffffff);
    border-color: transparent;
}

.alert-success.alert-solid {
    background: var(--color-success, #16a34a);
}

.alert-error.alert-solid,
.alert-danger.alert-solid {
    background: var(--color-danger, #dc2626);
}

.alert-warning.alert-solid {
    background: var(--color-warning, #d97706);
}

.alert-info.alert-solid {
    background: var(--color-info, #2563eb);
}

.alert-solid .alert-icon,
.alert-solid .alert-close {
    color: inherit;
}


/* ==========================================================================
   13. COMPACT ALERT
   ========================================================================== */

.alert-compact {
    gap: var(--space-2, 8px);
    padding: var(--space-2, 8px) var(--space-3, 12px);

    font-size: var(--font-size-xs, 13px);
}

.alert-compact .alert-icon {
    width: 18px;
    height: 18px;
    font-size: 16px;
}

.alert-compact .alert-close {
    width: 28px;
    height: 28px;
}


/* ==========================================================================
   14. LARGE ALERT
   ========================================================================== */

.alert-large {
    gap: var(--space-4, 16px);
    padding: var(--space-5, 20px);

    font-size: var(--font-size-base, 16px);
}

.alert-large .alert-icon {
    width: 24px;
    height: 24px;
    font-size: 20px;
}

.alert-large .alert-title {
    font-size: var(--font-size-lg, 18px);
}


/* ==========================================================================
   15. ALERT WITH ACTIONS
   ========================================================================== */

.alert-actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: var(--space-2, 8px);

    margin-top: var(--space-3, 12px);
}

.alert-actions .btn {
    flex: 0 0 auto;
}

.alert-actions a {
    font-weight: var(--font-weight-medium, 500);
}


/* ==========================================================================
   16. ALERT ACTION LINK
   ========================================================================== */

.alert-action {
    display: inline-flex;
    align-items: center;

    margin-top: var(--space-2, 8px);

    color: inherit;
    font-weight: var(--font-weight-semibold, 600);
    text-decoration: underline;
    text-underline-offset: 2px;
}

.alert-action:hover {
    text-decoration-thickness: 2px;
}


/* ==========================================================================
   17. FULL-WIDTH TOP BANNER
   ========================================================================== */

.alert-banner {
    width: 100%;

    display: flex;
    align-items: center;
    justify-content: center;

    min-height: 44px;
    padding: var(--space-3, 12px) var(--space-5, 20px);

    border-width: 0 0 1px;
    border-radius: 0;

    text-align: center;
}

.alert-banner .alert-content {
    flex: 0 1 auto;
}

.alert-banner .alert-actions {
    margin: 0 0 0 var(--space-3, 12px);
}


/* ==========================================================================
   18. INLINE ALERT
   ========================================================================== */

.alert-inline {
    display: inline-flex;
    width: auto;

    padding: var(--space-2, 8px) var(--space-3, 12px);

    vertical-align: middle;
}


/* ==========================================================================
   19. FORM VALIDATION ALERTS
   ========================================================================== */

.form-alert {
    margin-bottom: var(--space-4, 16px);
}

.field-alert {
    display: flex;
    align-items: flex-start;
    gap: var(--space-2, 8px);

    margin-top: var(--space-2, 8px);

    color: var(--color-danger-text, #991b1b);

    font-size: var(--font-size-xs, 13px);
    line-height: 1.4;
}

.field-alert::before {
    content: "!";
    
    flex: 0 0 auto;

    display: inline-flex;
    align-items: center;
    justify-content: center;

    width: 16px;
    height: 16px;

    margin-top: 1px;

    color: var(--color-danger, #dc2626);
    border: 1px solid currentColor;
    border-radius: 50%;

    font-size: 10px;
    font-weight: var(--font-weight-bold, 700);
    line-height: 1;
}

.field-alert-success {
    color: var(--color-success-text, #166534);
}

.field-alert-success::before {
    content: "✓";
    color: var(--color-success, #16a34a);
}

.field-alert-warning {
    color: var(--color-warning-text, #92400e);
}

.field-alert-warning::before {
    color: var(--color-warning, #d97706);
}


/* ==========================================================================
   20. FORM ERROR SUMMARY
   ========================================================================== */

.alert-error-summary {
    color: var(--color-danger-text, #991b1b);
    background: var(--color-danger-bg, #fef2f2);
    border: 1px solid var(--color-danger-border, #fecaca);
    border-radius: var(--radius-md, 8px);
    padding: var(--space-4, 16px);
}

.alert-error-summary .alert-title {
    margin-bottom: var(--space-2, 8px);
}

.alert-error-summary ul {
    margin: 0;
    padding-left: var(--space-5, 20px);
}

.alert-error-summary li + li {
    margin-top: var(--space-1, 4px);
}

.alert-error-summary a {
    color: inherit;
    text-decoration: underline;
}


/* ==========================================================================
   21. TOAST CONTAINER
   ========================================================================== */

.alert-toast-container {
    position: fixed;
    z-index: var(--z-toast, 1100);

    top: var(--space-5, 20px);
    right: var(--space-5, 20px);

    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: var(--space-3, 12px);

    width: min(
        calc(100vw - 40px),
        var(--toast-width, 420px)
    );

    pointer-events: none;
}

.alert-toast-container-bottom {
    top: auto;
    bottom: var(--space-5, 20px);
}

.alert-toast-container-left {
    right: auto;
    left: var(--space-5, 20px);

    align-items: flex-start;
}

.alert-toast-container-center {
    right: 50%;
    left: auto;

    transform: translateX(50%);

    align-items: center;
}


/* ==========================================================================
   22. TOAST ALERT
   ========================================================================== */

.alert-toast {
    width: 100%;

    box-shadow:
        var(--shadow-lg, 0 10px 25px rgba(0, 0, 0, 0.12));

    pointer-events: auto;

    animation: alert-toast-in 180ms ease-out both;
}

.alert-toast.is-leaving {
    animation: alert-toast-out 160ms ease-in both;
}

@keyframes alert-toast-in {
    from {
        opacity: 0;
        transform: translateY(-8px);
    }

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

@keyframes alert-toast-out {
    from {
        opacity: 1;
        transform: translateY(0);
    }

    to {
        opacity: 0;
        transform: translateY(-8px);
    }
}


/* ==========================================================================
   23. TOAST PROGRESS
   ========================================================================== */

.alert-progress {
    position: absolute;

    right: 0;
    bottom: 0;
    left: 0;

    height: 3px;

    overflow: hidden;

    background: rgba(0, 0, 0, 0.08);
}

.alert-progress-bar {
    display: block;

    width: 100%;
    height: 100%;

    transform-origin: left center;

    background: currentColor;

    animation: alert-progress-shrink linear forwards;
}

@keyframes alert-progress-shrink {
    from {
        transform: scaleX(1);
    }

    to {
        transform: scaleX(0);
    }
}


/* ==========================================================================
   24. STATUS MESSAGE
   ========================================================================== */

.status-alert {
    display: flex;
    align-items: center;
    justify-content: center;

    min-height: 120px;

    padding: var(--space-6, 24px);

    text-align: center;
}

.status-alert .alert-content {
    flex: 0 1 auto;
    max-width: 560px;
}


/* ==========================================================================
   25. EMPTY / NO DATA MESSAGE
   ========================================================================== */

.alert-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;

    min-height: 180px;

    padding: var(--space-8, 32px);

    color: var(--color-text-muted, #6b7280);
    background: var(--color-surface-muted, #f9fafb);

    border: 1px dashed var(--color-border, #e5e7eb);
    border-radius: var(--radius-lg, 10px);

    text-align: center;
}

.alert-empty .alert-icon {
    width: 40px;
    height: 40px;

    margin-bottom: var(--space-3, 12px);

    font-size: 30px;
}

.alert-empty .alert-title {
    color: var(--color-text, #1f2937);
}


/* ==========================================================================
   26. LOADING ALERT
   ========================================================================== */

.alert-loading {
    display: flex;
    align-items: center;
}

.alert-spinner {
    flex: 0 0 auto;

    width: 18px;
    height: 18px;

    border: 2px solid currentColor;
    border-right-color: transparent;

    border-radius: 50%;

    animation: alert-spin 700ms linear infinite;
}

@keyframes alert-spin {
    to {
        transform: rotate(360deg);
    }
}


/* ==========================================================================
   27. ALERT LIST
   ========================================================================== */

.alert-list {
    display: flex;
    flex-direction: column;
    gap: var(--space-3, 12px);

    margin: 0;
    padding: 0;

    list-style: none;
}

.alert-list > .alert {
    margin: 0;
}


/* ==========================================================================
   28. ALERT GROUP
   ========================================================================== */

.alert-group {
    display: flex;
    flex-direction: column;
    gap: var(--space-2, 8px);
}

.alert-group .alert {
    margin: 0;
}


/* ==========================================================================
   29. ALERT WITH BORDER ACCENT
   ========================================================================== */

.alert-accent {
    border-left-width: 4px;
}

.alert-success.alert-accent {
    border-left-color: var(--color-success, #16a34a);
}

.alert-error.alert-accent,
.alert-danger.alert-accent {
    border-left-color: var(--color-danger, #dc2626);
}

.alert-warning.alert-accent {
    border-left-color: var(--color-warning, #d97706);
}

.alert-info.alert-accent {
    border-left-color: var(--color-info, #2563eb);
}


/* ==========================================================================
   30. ALERT WITH TOP ACCENT
   ========================================================================== */

.alert-top-accent {
    border-top-width: 4px;
}

.alert-success.alert-top-accent {
    border-top-color: var(--color-success, #16a34a);
}

.alert-error.alert-top-accent,
.alert-danger.alert-top-accent {
    border-top-color: var(--color-danger, #dc2626);
}

.alert-warning.alert-top-accent {
    border-top-color: var(--color-warning, #d97706);
}

.alert-info.alert-top-accent {
    border-top-color: var(--color-info, #2563eb);
}


/* ==========================================================================
   31. DISMISSIBLE STATE
   ========================================================================== */

.alert[data-dismissible="true"] {
    padding-right: var(--space-12, 48px);
}

.alert[data-dismissible="true"] .alert-close {
    position: absolute;

    top: var(--space-3, 12px);
    right: var(--space-3, 12px);

    margin: 0;
}


/* ==========================================================================
   32. HIDDEN / REMOVED STATE
   ========================================================================== */

.alert[hidden],
.alert.is-hidden {
    display: none !important;
}

.alert.is-removing {
    opacity: 0;
    pointer-events: none;

    transition:
        opacity 160ms ease,
        transform 160ms ease;

    transform: translateY(-4px);
}


/* ==========================================================================
   33. STICKY ALERT
   ========================================================================== */

.alert-sticky {
    position: sticky;

    top: 0;

    z-index: var(--z-sticky, 100);

    box-shadow:
        var(--shadow-sm, 0 1px 3px rgba(0, 0, 0, 0.08));
}


/* ==========================================================================
   34. AUTHENTICATION ALERT
   ========================================================================== */

.auth-alert {
    margin-bottom: var(--space-4, 16px);
}

.auth-alert .alert-title {
    font-size: var(--font-size-sm, 14px);
}


/* ==========================================================================
   35. DASHBOARD SYSTEM ALERT
   ========================================================================== */

.dashboard-alert {
    margin-bottom: var(--space-5, 20px);
}

.dashboard-alert:last-child {
    margin-bottom: 0;
}


/* ==========================================================================
   36. NETWORK / API ALERT
   ========================================================================== */

.api-alert {
    display: flex;
    align-items: flex-start;
}

.api-alert .alert-code {
    display: inline-block;

    margin-top: var(--space-2, 8px);

    padding: var(--space-1, 4px) var(--space-2, 8px);

    color: inherit;
    background: rgba(0, 0, 0, 0.05);

    border-radius: var(--radius-sm, 6px);

    font-family: var(
        --font-family-mono,
        ui-monospace,
        SFMono-Regular,
        Menlo,
        Monaco,
        Consolas,
        monospace
    );

    font-size: var(--font-size-xs, 12px);
}


/* ==========================================================================
   37. OFFLINE ALERT
   ========================================================================== */

.alert-offline {
    color: var(--color-danger-text, #991b1b);
    background: var(--color-danger-bg, #fef2f2);
    border-color: var(--color-danger-border, #fecaca);

    text-align: center;
}

.alert-offline .alert-content {
    flex: 0 1 auto;
}


/* ==========================================================================
   38. ONLINE ALERT
   ========================================================================== */

.alert-online {
    color: var(--color-success-text, #166534);
    background: var(--color-success-bg, #f0fdf4);
    border-color: var(--color-success-border, #bbf7d0);

    text-align: center;
}

.alert-online .alert-content {
    flex: 0 1 auto;
}


/* ==========================================================================
   39. SESSION EXPIRING ALERT
   ========================================================================== */

.alert-session-expiring {
    display: flex;
    align-items: center;
    justify-content: space-between;

    gap: var(--space-4, 16px);
}

.alert-session-expiring .alert-actions {
    flex: 0 0 auto;

    margin: 0;
}


/* ==========================================================================
   40. SECURITY ALERT
   ========================================================================== */

.alert-security {
    color: var(--color-danger-text, #991b1b);
    background: var(--color-danger-bg, #fef2f2);
    border-color: var(--color-danger-border, #fecaca);
}

.alert-security .alert-icon {
    color: var(--color-danger, #dc2626);
}


/* ==========================================================================
   41. VERIFICATION ALERT
   ========================================================================== */

.alert-verification {
    color: var(--color-info-text, #1e40af);
    background: var(--color-info-bg, #eff6ff);
    border-color: var(--color-info-border, #bfdbfe);
}


/* ==========================================================================
   42. ALERT CARD
   ========================================================================== */

.alert-card {
    display: block;

    padding: var(--space-5, 20px);

    box-shadow:
        var(--shadow-sm, 0 1px 3px rgba(0, 0, 0, 0.08));
}

.alert-card .alert-header {
    display: flex;
    align-items: flex-start;
    gap: var(--space-3, 12px);
}

.alert-card .alert-body {
    margin-top: var(--space-3, 12px);
}

.alert-card .alert-footer {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: var(--space-2, 8px);

    margin-top: var(--space-4, 16px);
}


/* ==========================================================================
   43. RESPONSIVE — TABLET
   ========================================================================== */

@media (max-width: 768px) {
    .alert {
        padding: var(--space-3, 12px);
    }

    .alert-large {
        padding: var(--space-4, 16px);
    }

    .alert-banner {
        padding-right: var(--space-4, 16px);
        padding-left: var(--space-4, 16px);
    }

    .alert-banner {
        flex-wrap: wrap;
    }

    .alert-banner .alert-actions {
        width: 100%;
        justify-content: center;

        margin: var(--space-2, 8px) 0 0;
    }

    .alert-session-expiring {
        flex-direction: column;
        align-items: flex-start;
    }

    .alert-session-expiring .alert-actions {
        width: 100%;
    }

    .alert-toast-container {
        top: var(--space-3, 12px);
        right: var(--space-3, 12px);

        width: calc(100vw - 24px);
    }

    .alert-toast-container-bottom {
        top: auto;
        bottom: var(--space-3, 12px);
    }

    .alert-toast-container-left {
        left: var(--space-3, 12px);
    }
}


/* ==========================================================================
   44. RESPONSIVE — MOBILE
   ========================================================================== */

@media (max-width: 480px) {
    .alert {
        gap: var(--space-2, 8px);
        padding: var(--space-3, 12px);

        font-size: var(--font-size-xs, 13px);
    }

    .alert-title {
        font-size: var(--font-size-sm, 14px);
    }

    .alert-actions {
        align-items: stretch;
        flex-direction: column;
    }

    .alert-actions .btn {
        width: 100%;
    }

    .alert-card {
        padding: var(--space-4, 16px);
    }

    .alert-card .alert-footer {
        align-items: stretch;
        flex-direction: column;
    }

    .alert-card .alert-footer .btn {
        width: 100%;
    }

    .alert-banner {
        text-align: left;
    }

    .alert-banner .alert-content {
        flex: 1 1 100%;
    }

    .alert-banner .alert-actions {
        justify-content: flex-start;
    }

    .status-alert {
        min-height: 140px;
        padding: var(--space-5, 20px);
    }

    .alert-empty {
        min-height: 160px;
        padding: var(--space-6, 24px);
    }
}


/* ==========================================================================
   45. ACCESSIBILITY
   ========================================================================== */

.alert[role="alert"] {
    /* Keep alert semantics without changing visual layout. */
}

.alert :focus-visible {
    outline: 2px solid currentColor;
    outline-offset: 2px;
}

@media (prefers-reduced-motion: reduce) {
    .alert,
    .alert-close,
    .alert-toast,
    .alert-toast.is-leaving,
    .alert-progress-bar,
    .alert-spinner {
        animation: none !important;
        transition: none !important;
    }
}


/* ==========================================================================
   46. PRINT
   ========================================================================== */

@media print {
    .alert {
        color: #000 !important;
        background: #fff !important;

        border: 1px solid #000 !important;

        box-shadow: none !important;

        break-inside: avoid;
    }

    .alert-close,
    .alert-progress,
    .alert-spinner {
        display: none !important;
    }

    .alert-toast-container {
        position: static;

        width: 100%;

        display: block;
    }

    .alert-toast {
        margin-bottom: 10px;

        animation: none !important;
    }
}