/**
 * Messaging System Styles
 * Toast notifications and inline contextual messages
 */

/* Toast Container - Fixed at top-center */
.app-toast-container {
    position: fixed;
    top: 20px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 10000;
    display: flex;
    flex-direction: column;
    gap: 12px;
    max-width: 90%;
    width: 100%;
    max-width: 500px;
    pointer-events: none; /* Allow clicks through container */
}

/* Individual Toast */
.app-toast {
    background: white;
    border-radius: 10px;
    padding: 16px 20px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.25);
    display: flex;
    align-items: flex-start;
    gap: 12px;
    opacity: 0;
    transform: translateY(-20px);
    transition: opacity 0.3s ease, transform 0.3s ease;
    pointer-events: auto; /* Re-enable clicks on toast itself */
    border: 2px solid transparent;
}

.app-toast--visible {
    opacity: 1;
    transform: translateY(0);
}

/* Toast Message Text */
.app-toast-message {
    flex: 1;
    line-height: 1.5;
    white-space: pre-line; /* Preserve line breaks */
}

/* Toast Dismiss Button */
.app-toast-dismiss {
    background: none;
    border: none;
    font-size: 24px;
    line-height: 1;
    color: #666;
    cursor: pointer;
    padding: 0;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: color 0.2s ease;
}

.app-toast-dismiss:hover {
    color: #333;
}

/* Toast Variants - solid backgrounds for readability */
.app-toast--error {
    background: #fef2f2;
    border-color: #dc3545;
    color: #991b1b;
}

.app-toast--error .app-toast-message {
    color: #991b1b;
}

.app-toast--error .app-toast-dismiss {
    color: #991b1b;
}

.app-toast--warning {
    background: #fffbeb;
    border-color: #f59e0b;
    color: #92400e;
}

.app-toast--warning .app-toast-message {
    color: #92400e;
}

.app-toast--warning .app-toast-dismiss {
    color: #92400e;
}

.app-toast--success {
    background: #f0fdf4;
    border-color: #22c55e;
    color: #166534;
}

.app-toast--success .app-toast-message {
    color: #166534;
}

.app-toast--success .app-toast-dismiss {
    color: #166534;
}

/* Inline Messages - Contextual to form fields/sections */
.app-inline-message {
    padding: 12px 15px;
    border-radius: 8px;
    margin-top: 8px;
    margin-bottom: 12px;
    font-size: 0.95em;
    line-height: 1.4;
}

.app-inline-message--error {
    background: rgba(255, 107, 107, 0.1);
    border: 1px solid var(--error-color);
    color: var(--error-color);
}

.app-inline-message--info {
    background: rgba(33, 150, 243, 0.1);
    border: 1px solid #2196f3;
    color: #1976d2;
}

.app-inline-message--success {
    background: rgba(81, 207, 102, 0.15);
    border: 1px solid var(--success-color);
    color: var(--success-color);
}

/* Mobile Responsiveness */
@media (max-width: 768px) {
    .app-toast-container {
        top: 10px;
        left: 10px;
        right: 10px;
        transform: none;
        max-width: none;
        width: auto;
    }
    
    .app-toast {
        padding: 14px 16px;
    }
    
    .app-inline-message {
        padding: 10px 12px;
        font-size: 0.9em;
    }
}

/* Blocking busy overlay (save / long-running actions) */
.app-busy-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.45);
    z-index: 20000;
    display: flex;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(2px);
}

.app-busy-overlay-card {
    background: #fff;
    border-radius: 12px;
    padding: 2rem 2.5rem;
    text-align: center;
    min-width: 260px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.25);
}

.app-busy-overlay-spinner {
    width: 36px;
    height: 36px;
    margin: 0 auto 0.85rem;
    border: 3px solid #e5e7eb;
    border-top-color: var(--primary-color, #2d6a4f);
    border-radius: 50%;
    animation: app-busy-spin 0.8s linear infinite;
}

.app-busy-overlay-message {
    font-weight: 600;
    font-size: 1rem;
    color: #1a1a1a;
}

.app-busy-overlay-hint {
    color: #888;
    font-size: 0.8rem;
    margin-top: 0.4rem;
}

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

body.app-busy {
    overflow: hidden;
}
