/**
 * HXCode Web Interface - Error Handling Styles
 * Toast notifications, modals, and inline error states
 */

/* ============================================
   Toast Container
   ============================================ */

.toast-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 10000;
    display: flex;
    flex-direction: column;
    gap: 12px;
    max-width: 420px;
    pointer-events: none;
}

/* ============================================
   Toast Notifications
   ============================================ */

.toast {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 16px;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15), 0 0 0 1px rgba(0, 0, 0, 0.05);
    background: white;
    pointer-events: auto;
    opacity: 0;
    transform: translateX(100%);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    min-width: 320px;
}

.toast-show {
    opacity: 1;
    transform: translateX(0);
}

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

/* Toast Icons */
.toast-icon {
    flex-shrink: 0;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-top: 2px;
}

.toast-info .toast-icon {
    color: #0066cc;
}

.toast-warning .toast-icon {
    color: #ff9500;
}

.toast-error .toast-icon,
.toast-critical .toast-icon {
    color: #dc3545;
}

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

.toast-title {
    font-weight: 600;
    font-size: 14px;
    line-height: 1.4;
    margin-bottom: 4px;
    color: #1a1a1a;
}

.toast-message {
    font-size: 13px;
    line-height: 1.5;
    color: #666;
}

/* Toast Actions */
.toast-actions {
    display: flex;
    gap: 8px;
    margin-top: 12px;
}

.toast-action-btn,
.toast-retry-btn {
    padding: 6px 12px;
    font-size: 12px;
    font-weight: 500;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.toast-action-btn {
    background: #0066cc;
    color: white;
}

.toast-action-btn:hover {
    background: #0052a3;
}

.toast-retry-btn {
    background: #f0f0f0;
    color: #333;
}

.toast-retry-btn:hover {
    background: #e0e0e0;
}

/* Toast Close Button */
.toast-close {
    flex-shrink: 0;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: none;
    border: none;
    font-size: 20px;
    line-height: 1;
    color: #999;
    cursor: pointer;
    transition: color 0.2s ease;
    padding: 0;
    margin-left: 4px;
}

.toast-close:hover {
    color: #333;
}

/* Toast Color Variants */
.toast-info {
    border-left: 4px solid #0066cc;
}

.toast-warning {
    border-left: 4px solid #ff9500;
    background: #fffbf0;
}

.toast-error {
    border-left: 4px solid #dc3545;
    background: #fff5f5;
}

.toast-critical {
    border-left: 4px solid #c82333;
    background: #ffe0e0;
}

/* ============================================
   Error Modal
   ============================================ */

.error-modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.6);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10001;
    padding: 20px;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.error-modal-overlay.show {
    opacity: 1;
}

.error-modal {
    background: white;
    border-radius: 12px;
    padding: 32px;
    max-width: 480px;
    width: 100%;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    text-align: center;
    transform: scale(0.9);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.error-modal-overlay.show .error-modal {
    transform: scale(1);
}

/* Modal Icon */
.error-modal-icon {
    width: 64px;
    height: 64px;
    margin: 0 auto 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    background: #fff0f0;
    color: #dc3545;
}

.error-modal-icon svg {
    width: 32px;
    height: 32px;
}

/* Modal Content */
.error-modal-title {
    font-size: 24px;
    font-weight: 600;
    color: #1a1a1a;
    margin-bottom: 12px;
    line-height: 1.3;
}

.error-modal-message {
    font-size: 15px;
    line-height: 1.6;
    color: #666;
    margin-bottom: 32px;
}

/* Modal Actions */
.error-modal-actions {
    display: flex;
    gap: 12px;
    justify-content: center;
}

.error-modal-btn {
    padding: 12px 24px;
    font-size: 14px;
    font-weight: 500;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s ease;
    min-width: 100px;
}

.error-modal-btn.primary {
    background: #dc3545;
    color: white;
}

.error-modal-btn.primary:hover {
    background: #c82333;
}

.error-modal-btn.secondary {
    background: #f0f0f0;
    color: #333;
}

.error-modal-btn.secondary:hover {
    background: #e0e0e0;
}

/* ============================================
   Inline Errors
   ============================================ */

.inline-error {
    margin-top: 6px;
    padding: 8px 12px;
    background: #fff5f5;
    border-left: 3px solid #dc3545;
    border-radius: 4px;
    font-size: 13px;
    color: #c82333;
    line-height: 1.4;
}

.has-error {
    border-color: #dc3545 !important;
    box-shadow: 0 0 0 3px rgba(220, 53, 69, 0.1) !important;
}

/* Input Field Error State */
input.has-error,
textarea.has-error {
    border: 2px solid #dc3545;
}

input.has-error:focus,
textarea.has-error:focus {
    outline: none;
    border-color: #c82333;
    box-shadow: 0 0 0 3px rgba(220, 53, 69, 0.15);
}

/* ============================================
   Responsive Design
   ============================================ */

@media (max-width: 480px) {
    .toast-container {
        top: 10px;
        right: 10px;
        left: 10px;
        max-width: none;
    }

    .toast {
        min-width: 0;
        width: 100%;
    }

    .error-modal {
        padding: 24px;
    }

    .error-modal-title {
        font-size: 20px;
    }

    .error-modal-actions {
        flex-direction: column;
    }

    .error-modal-btn {
        width: 100%;
    }
}

/* ============================================
   Loading State (for error recovery)
   ============================================ */

.error-loading {
    display: inline-block;
    width: 16px;
    height: 16px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-top-color: white;
    border-radius: 50%;
    animation: error-spin 0.6s linear infinite;
}

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

/* ============================================
   Dark Mode Support (future enhancement)
   ============================================ */

@media (prefers-color-scheme: dark) {
    .toast {
        background: #2a2a2a;
        box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4), 0 0 0 1px rgba(255, 255, 255, 0.1);
    }

    .toast-title {
        color: #ffffff;
    }

    .toast-message {
        color: #b0b0b0;
    }

    .toast-warning {
        background: #3a2f1a;
    }

    .toast-error,
    .toast-critical {
        background: #3a1a1a;
    }

    .error-modal {
        background: #2a2a2a;
        color: #ffffff;
    }

    .error-modal-title {
        color: #ffffff;
    }

    .error-modal-message {
        color: #b0b0b0;
    }

    .error-modal-icon {
        background: #3a1a1a;
    }

    .error-modal-btn.secondary {
        background: #3a3a3a;
        color: #ffffff;
    }

    .error-modal-btn.secondary:hover {
        background: #4a4a4a;
    }

    .inline-error {
        background: #3a1a1a;
        color: #ff6b6b;
    }
}
