/**
 * ALERTS & TOASTS - PharmData Design System v2.0
 * Notificações e mensagens de feedback ao usuário
 *
 * Inclui: Inline alerts, Toast notifications, Banners
 * Com suporte a auto-dismiss e animações.
 */

/* ===================
   CSS CUSTOM PROPERTIES
   =================== */

:root {
    /* Alert base */
    --alert-padding: 1rem;
    --alert-border-radius: 0.5rem;
    --alert-border-width: 1px;
    --alert-icon-size: 1.25rem;
    --alert-gap: 0.75rem;

    /* Info */
    --alert-info-bg: rgba(59, 130, 246, 0.08);
    --alert-info-border: rgba(59, 130, 246, 0.3);
    --alert-info-text: #1E40AF;
    --alert-info-icon: var(--info, #3B82F6);

    /* Success */
    --alert-success-bg: rgba(16, 185, 129, 0.08);
    --alert-success-border: rgba(16, 185, 129, 0.3);
    --alert-success-text: #065F46;
    --alert-success-icon: var(--success, #10B981);

    /* Warning */
    --alert-warning-bg: rgba(180, 83, 9, 0.08);
    --alert-warning-border: rgba(180, 83, 9, 0.3);
    --alert-warning-text: #78350F;
    --alert-warning-icon: var(--warning-dark, #B45309);

    /* Error/Danger */
    --alert-error-bg: rgba(239, 68, 68, 0.08);
    --alert-error-border: rgba(239, 68, 68, 0.3);
    --alert-error-text: #991B1B;
    --alert-error-icon: var(--error, #EF4444);

    /* Toast specific */
    --toast-width: 24rem;
    --toast-shadow: 0 10px 40px rgba(0, 0, 0, 0.15);
    --toast-z-index: 1100;

    /* Animation */
    --alert-transition: all 0.2s ease;
}

/* Dark mode */
:root.dark-mode {
    --alert-info-bg: rgba(59, 130, 246, 0.15);
    --alert-info-text: #93C5FD;

    --alert-success-bg: rgba(16, 185, 129, 0.15);
    --alert-success-text: #A7F3D0;

    --alert-warning-bg: rgba(180, 83, 9, 0.15);
    --alert-warning-text: #FDE68A;

    --alert-error-bg: rgba(239, 68, 68, 0.15);
    --alert-error-text: #FCA5A5;

    --toast-shadow: 0 10px 40px rgba(0, 0, 0, 0.4);
}

/* ===================
   INLINE ALERT BASE
   =================== */

.alert {
    display: flex;
    align-items: flex-start;
    gap: var(--alert-gap);
    padding: var(--alert-padding);
    border-radius: var(--alert-border-radius);
    border: var(--alert-border-width) solid transparent;
    transition: var(--alert-transition);
}

.alert-icon {
    flex-shrink: 0;
    width: var(--alert-icon-size);
    height: var(--alert-icon-size);
    display: flex;
    align-items: center;
    justify-content: center;
    margin-top: 0.125rem;
}

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

.alert-title {
    font-weight: 600;
    font-size: 0.9375rem;
    margin: 0 0 0.25rem;
    line-height: 1.4;
}

.alert-message {
    font-size: 0.875rem;
    line-height: 1.5;
    margin: 0;
}

.alert-message a {
    font-weight: 500;
    text-decoration: underline;
    text-underline-offset: 2px;
}

.alert-dismiss {
    flex-shrink: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 1.5rem;
    height: 1.5rem;
    border: none;
    background: transparent;
    border-radius: 0.25rem;
    cursor: pointer;
    opacity: 0.6;
    transition: all 0.15s ease;
    margin: -0.25rem -0.25rem -0.25rem 0;
}

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

.alert-dismiss:focus-visible {
    outline: none;
    box-shadow: 0 0 0 2px currentColor;
}

/* ===================
   ALERT VARIANTS
   =================== */

/* Info */
.alert-info {
    background: var(--alert-info-bg);
    border-color: var(--alert-info-border);
    color: var(--alert-info-text);
}

.alert-info .alert-icon {
    color: var(--alert-info-icon);
}

.alert-info a {
    color: var(--alert-info-icon);
}

/* Success */
.alert-success {
    background: var(--alert-success-bg);
    border-color: var(--alert-success-border);
    color: var(--alert-success-text);
}

.alert-success .alert-icon {
    color: var(--alert-success-icon);
}

.alert-success a {
    color: var(--alert-success-icon);
}

/* Warning */
.alert-warning {
    background: var(--alert-warning-bg);
    border-color: var(--alert-warning-border);
    color: var(--alert-warning-text);
}

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

.alert-warning a {
    color: var(--alert-warning-icon);
}

/* Error/Danger */
.alert-error,
.alert-danger {
    background: var(--alert-error-bg);
    border-color: var(--alert-error-border);
    color: var(--alert-error-text);
}

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

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

/* ===================
   ALERT SIZES
   =================== */

.alert-sm {
    padding: 0.625rem 0.875rem;
    gap: 0.5rem;
    font-size: 0.8125rem;
}

.alert-sm .alert-icon {
    width: 1rem;
    height: 1rem;
}

.alert-sm .alert-title {
    font-size: 0.8125rem;
}

.alert-sm .alert-message {
    font-size: 0.75rem;
}

.alert-lg {
    padding: 1.25rem 1.5rem;
    gap: 1rem;
}

.alert-lg .alert-icon {
    width: 1.5rem;
    height: 1.5rem;
}

.alert-lg .alert-title {
    font-size: 1.0625rem;
}

/* ===================
   ALERT WITH ACTIONS
   =================== */

.alert-actions {
    display: flex;
    gap: 0.5rem;
    margin-top: 0.75rem;
}

.alert-action {
    display: inline-flex;
    align-items: center;
    gap: 0.375rem;
    padding: 0.375rem 0.75rem;
    font-size: 0.8125rem;
    font-weight: 500;
    border-radius: 0.375rem;
    border: none;
    cursor: pointer;
    transition: all 0.15s ease;
}

.alert-action-primary {
    background: currentColor;
    color: white;
}

.alert-info .alert-action-primary {
    background: var(--alert-info-icon);
}

.alert-success .alert-action-primary {
    background: var(--alert-success-icon);
}

.alert-warning .alert-action-primary {
    background: var(--alert-warning-icon);
}

.alert-error .alert-action-primary {
    background: var(--alert-error-icon);
}

.alert-action-secondary {
    background: transparent;
    border: 1px solid currentColor;
}

/* ===================
   SOLID ALERTS
   Fundo sólido colorido
   =================== */

.alert-solid {
    border: none;
}

.alert-solid.alert-info {
    background: var(--info, #3B82F6);
    color: white;
}

.alert-solid.alert-success {
    background: var(--success, #10B981);
    color: white;
}

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

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

.alert-solid .alert-icon {
    color: rgba(255, 255, 255, 0.9);
}

.alert-solid a {
    color: white;
}

.alert-solid .alert-dismiss:hover {
    background: rgba(255, 255, 255, 0.15);
}

/* ===================
   BANNER
   Alert full-width
   =================== */

.banner {
    border-radius: 0;
    border-left: none;
    border-right: none;
    justify-content: center;
    text-align: center;
}

.banner .alert-content {
    flex: none;
    max-width: 48rem;
}

.banner-fixed {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: var(--toast-z-index);
}

.banner-bottom {
    top: auto;
    bottom: 0;
}

/* ===================
   TOAST CONTAINER
   =================== */

.toast-container {
    position: fixed;
    z-index: var(--toast-z-index);
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    pointer-events: none;
    padding: 1rem;
}

/* Position variants */
.toast-container-top-right {
    top: 0;
    right: 0;
}

.toast-container-top-left {
    top: 0;
    left: 0;
}

.toast-container-top-center {
    top: 0;
    left: 50%;
    transform: translateX(-50%);
}

.toast-container-bottom-right {
    bottom: 0;
    right: 0;
}

.toast-container-bottom-left {
    bottom: 0;
    left: 0;
}

.toast-container-bottom-center {
    bottom: 0;
    left: 50%;
    transform: translateX(-50%);
}

/* ===================
   TOAST
   =================== */

.toast {
    display: flex;
    align-items: flex-start;
    gap: var(--alert-gap);
    width: var(--toast-width);
    max-width: calc(100vw - 2rem);
    padding: 1rem 1.25rem;
    background: var(--modal-bg, white);
    border-radius: var(--alert-border-radius);
    box-shadow: var(--toast-shadow);
    pointer-events: auto;
    opacity: 0;
    transform: translateX(100%);
    transition: var(--alert-transition);
}

.toast.show,
.toast[data-state="visible"] {
    opacity: 1;
    transform: translateX(0);
}

.toast.hiding {
    opacity: 0;
    transform: translateX(100%);
}

/* Left positioned toasts */
.toast-container-top-left .toast,
.toast-container-bottom-left .toast {
    transform: translateX(-100%);
}

.toast-container-top-left .toast.show,
.toast-container-bottom-left .toast.show {
    transform: translateX(0);
}

.toast-container-top-left .toast.hiding,
.toast-container-bottom-left .toast.hiding {
    transform: translateX(-100%);
}

/* Center positioned toasts */
.toast-container-top-center .toast,
.toast-container-bottom-center .toast {
    transform: translateY(-20px);
}

.toast-container-top-center .toast.show,
.toast-container-bottom-center .toast.show {
    transform: translateY(0);
}

.toast-container-bottom-center .toast {
    transform: translateY(20px);
}

/* Toast icon */
.toast-icon {
    flex-shrink: 0;
    width: 1.5rem;
    height: 1.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
}

.toast-info .toast-icon {
    background: rgba(59, 130, 246, 0.1);
    color: var(--info, #3B82F6);
}

.toast-success .toast-icon {
    background: rgba(16, 185, 129, 0.1);
    color: var(--success, #10B981);
}

.toast-warning .toast-icon {
    background: rgba(180, 83, 9, 0.1);
    color: var(--warning-dark, #B45309);
}

.toast-error .toast-icon {
    background: rgba(239, 68, 68, 0.1);
    color: var(--error, #EF4444);
}

/* Toast content */
.toast-content {
    flex: 1;
    min-width: 0;
}

.toast-title {
    font-weight: 600;
    font-size: 0.9375rem;
    color: var(--graphite-depth, #1F2937);
    margin: 0 0 0.125rem;
}

.toast-message {
    font-size: 0.8125rem;
    color: var(--soft-steel, #374151);
    margin: 0;
    line-height: 1.4;
}

/* Toast dismiss */
.toast-dismiss {
    flex-shrink: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 1.5rem;
    height: 1.5rem;
    border: none;
    background: transparent;
    color: var(--soft-steel, #374151);
    border-radius: 0.25rem;
    cursor: pointer;
    transition: all 0.15s ease;
    margin: -0.25rem -0.375rem -0.25rem 0;
}

.toast-dismiss:hover {
    background: rgba(0, 0, 0, 0.05);
    color: var(--graphite-depth, #1F2937);
}

/* Toast progress bar */
.toast-progress {
    position: absolute;
    bottom: 0;
    left: 0;
    height: 3px;
    background: var(--teal-intense, #1a8b7d);
    border-radius: 0 0 var(--alert-border-radius) var(--alert-border-radius);
    animation: toast-progress linear forwards;
}

.toast-info .toast-progress {
    background: var(--info, #3B82F6);
}

.toast-success .toast-progress {
    background: var(--success, #10B981);
}

.toast-warning .toast-progress {
    background: var(--warning-dark, #B45309);
}

.toast-error .toast-progress {
    background: var(--error, #EF4444);
}

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

/* ===================
   TOAST WITH BORDER
   =================== */

.toast-bordered {
    border-left: 4px solid var(--teal-intense, #1a8b7d);
}

.toast-bordered.toast-info {
    border-left-color: var(--info, #3B82F6);
}

.toast-bordered.toast-success {
    border-left-color: var(--success, #10B981);
}

.toast-bordered.toast-warning {
    border-left-color: var(--warning-dark, #B45309);
}

.toast-bordered.toast-error {
    border-left-color: var(--error, #EF4444);
}

/* ===================
   TOAST ACTIONS
   =================== */

.toast-actions {
    display: flex;
    gap: 0.5rem;
    margin-top: 0.625rem;
}

.toast-action {
    font-size: 0.8125rem;
    font-weight: 500;
    padding: 0.25rem 0;
    background: none;
    border: none;
    cursor: pointer;
    transition: opacity 0.15s ease;
}

.toast-action:hover {
    opacity: 0.7;
}

.toast-action-primary {
    color: var(--teal-intense, #1a8b7d);
}

.toast-action-secondary {
    color: var(--soft-steel, #374151);
}

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

/* Screen reader announcements */
.alert[role="alert"],
.toast[role="alert"] {
    /* Automatically announced by screen readers */
}

/* Focus management */
.alert:focus-visible,
.toast:focus-visible {
    outline: 2px solid var(--teal-intense, #1a8b7d);
    outline-offset: 2px;
}

/* High contrast */
@media (prefers-contrast: high) {
    .alert,
    .toast {
        border-width: 2px;
    }
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
    .alert,
    .toast,
    .toast-progress {
        transition: none;
        animation: none;
    }

    .toast.show {
        transform: none;
    }
}

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

@media (max-width: 640px) {
    .toast-container {
        left: 0;
        right: 0;
        padding: 0.75rem;
    }

    .toast-container-top-right,
    .toast-container-top-left,
    .toast-container-top-center {
        transform: none;
    }

    .toast-container-bottom-right,
    .toast-container-bottom-left,
    .toast-container-bottom-center {
        transform: none;
    }

    .toast {
        width: 100%;
        max-width: none;
    }

    .alert-actions {
        flex-direction: column;
    }
}
