/* ================================================
   DJANGO MESSAGES - Toast Notifications
   Hiển thị thông báo từ Django messages framework
   ================================================ */

/* ================================================
   MESSAGE CONTAINER
   ================================================ */

.messages-container {
    position: fixed;
    top: 80px;
    right: 20px;
    z-index: 115; /* Same as notification toasts - managed by z-index-system.css */
    display: flex;
    flex-direction: column;
    gap: 12px;
    pointer-events: none;
    max-width: 420px;
}

/* ================================================
   MESSAGE ITEM (TOAST STYLE)
   ================================================ */

.alert {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    min-width: 320px;
    padding: 16px;
    background: white;
    border-radius: 12px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.15);
    border-left: 4px solid #3b82f6;
    pointer-events: auto;
    opacity: 0;
    transform: translateX(400px);
    animation: slideInMessage 0.4s cubic-bezier(0.4, 0, 0.2, 1) forwards;
    position: relative;
}

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

/* Dark mode */
:is(.dark) .alert {
    background: #1e293b;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.4);
}

/* ================================================
   MESSAGE TYPES - Colors & Icons
   ================================================ */

/* Debug - Gray */
.alert-debug {
    border-left-color: #6b7280;
}

.alert-debug .message-icon {
    background: #f3f4f6;
    color: #6b7280;
}

:is(.dark) .alert-debug .message-icon {
    background: #374151;
    color: #9ca3af;
}

/* Info - Blue */
.alert-info {
    border-left-color: #3b82f6;
}

.alert-info .message-icon {
    background: #eff6ff;
    color: #3b82f6;
}

:is(.dark) .alert-info .message-icon {
    background: #1e3a8a;
    color: #93c5fd;
}

/* Success - Green */
.alert-success {
    border-left-color: #10b981;
}

.alert-success .message-icon {
    background: #d1fae5;
    color: #10b981;
}

:is(.dark) .alert-success .message-icon {
    background: #065f46;
    color: #6ee7b7;
}

/* Warning - Yellow */
.alert-warning {
    border-left-color: #f59e0b;
}

.alert-warning .message-icon {
    background: #fef3c7;
    color: #f59e0b;
}

:is(.dark) .alert-warning .message-icon {
    background: #78350f;
    color: #fcd34d;
}

/* Error/Danger - Red */
.alert-error,
.alert-danger {
    border-left-color: #ef4444;
}

.alert-error .message-icon,
.alert-danger .message-icon {
    background: #fee2e2;
    color: #ef4444;
}

:is(.dark) .alert-error .message-icon,
:is(.dark) .alert-danger .message-icon {
    background: #7f1d1d;
    color: #fca5a5;
}

/* ================================================
   MESSAGE ICON
   ================================================ */

.message-icon {
    flex-shrink: 0;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    font-size: 1.25rem;
}

/* Icon variants based on message type */
.alert-debug .message-icon::before {
    content: "🐛";
}

.alert-info .message-icon::before {
    content: "ℹ️";
}

.alert-success .message-icon::before {
    content: "✓";
    font-weight: bold;
    font-size: 1.5rem;
}

.alert-warning .message-icon::before {
    content: "⚠️";
}

.alert-error .message-icon::before,
.alert-danger .message-icon::before {
    content: "✕";
    font-weight: bold;
    font-size: 1.25rem;
}

/* ================================================
   MESSAGE CONTENT
   ================================================ */

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

.message-title {
    font-size: 0.9375rem;
    font-weight: 700;
    color: #0f172a;
    margin-bottom: 4px;
    line-height: 1.4;
}

:is(.dark) .message-title {
    color: #f1f5f9;
}

.message-text {
    font-size: 0.8125rem;
    color: #64748b;
    line-height: 1.5;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

:is(.dark) .message-text {
    color: #94a3b8;
}

/* ================================================
   CLOSE BUTTON
   ================================================ */

.message-close {
    flex-shrink: 0;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: none;
    background: transparent;
    color: #94a3b8;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s;
    font-size: 1.25rem;
    line-height: 1;
    padding: 0;
}

.message-close:hover {
    background: #f1f5f9;
    color: #0f172a;
}

:is(.dark) .message-close:hover {
    background: #334155;
    color: #f1f5f9;
}

.message-close:focus-visible {
    outline: 2px solid #3b82f6;
    outline-offset: 2px;
}

/* ================================================
   AUTO-DISMISS ANIMATION
   ================================================ */

.alert.dismissing {
    animation: slideOutMessage 0.3s ease-out forwards;
}

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

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

@media (max-width: 640px) {
    .messages-container {
        top: 60px;
        right: 12px;
        left: 12px;
        max-width: none;
    }

    .alert {
        min-width: auto;
        max-width: none;
        width: 100%;
    }

    .message-icon {
        width: 36px;
        height: 36px;
    }

    .message-title {
        font-size: 0.875rem;
    }

    .message-text {
        font-size: 0.75rem;
    }
}

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

/* Screen reader only text */
.alert .sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border-width: 0;
}

/* Focus trap for keyboard navigation */
.alert:focus-within {
    outline: 2px solid #3b82f6;
    outline-offset: 2px;
}

/* ================================================
   PROGRESS BAR (Auto-dismiss indicator)
   ================================================ */

.alert-progress {
    position: absolute;
    bottom: 0;
    left: 0;
    height: 3px;
    background: linear-gradient(90deg,
        rgba(59, 130, 246, 0.3) 0%,
        rgba(59, 130, 246, 0.8) 100%);
    border-radius: 0 0 12px 12px;
    transform-origin: left;
    animation: progress 5s linear forwards;
}

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

.alert-success .alert-progress {
    background: linear-gradient(90deg,
        rgba(16, 185, 129, 0.3) 0%,
        rgba(16, 185, 129, 0.8) 100%);
}

.alert-warning .alert-progress {
    background: linear-gradient(90deg,
        rgba(245, 158, 11, 0.3) 0%,
        rgba(245, 158, 11, 0.8) 100%);
}

.alert-error .alert-progress,
.alert-danger .alert-progress {
    background: linear-gradient(90deg,
        rgba(239, 68, 68, 0.3) 0%,
        rgba(239, 68, 68, 0.8) 100%);
}
