/**
 * Standardized Error Display Styles for Shakti Frontend
 */

/* Base error message container */
.error-message {
    display: flex;
    align-items: flex-start;
    padding: 12px 16px;
    margin: 8px 0;
    border-radius: 6px;
    border-left: 4px solid;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    font-size: 14px;
    line-height: 1.4;
    position: relative;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

/* Error icon */
.error-message .error-icon {
    margin-right: 12px;
    font-size: 18px;
    flex-shrink: 0;
    margin-top: 1px;
}

/* Error content area */
.error-message .error-content {
    flex: 1;
    min-width: 0;
}

/* Main error message */
.error-message .error-main {
    font-weight: 500;
    margin-bottom: 4px;
    color: #333;
}

/* Error details */
.error-message .error-details {
    margin-top: 8px;
    font-size: 13px;
    opacity: 0.8;
}

.error-message .error-details ul {
    margin: 4px 0 0 16px;
    padding: 0;
}

.error-message .error-details li {
    margin-bottom: 2px;
}

/* Trace ID */
.error-message .error-trace {
    margin-top: 8px;
    font-size: 11px;
    font-family: monospace;
    opacity: 0.6;
    word-break: break-all;
}

/* Close button */
.error-message .error-close {
    position: absolute;
    top: 8px;
    right: 8px;
    background: none;
    border: none;
    font-size: 18px;
    cursor: pointer;
    color: inherit;
    opacity: 0.6;
    padding: 4px;
    line-height: 1;
    border-radius: 3px;
    transition: opacity 0.2s, background-color 0.2s;
}

.error-message .error-close:hover {
    opacity: 1;
    background-color: rgba(0, 0, 0, 0.1);
}

/* Validation errors (yellow/orange theme) */
.error-validation {
    background-color: #fff8e1;
    border-left-color: #ff9800;
    color: #e65100;
}

.error-validation .error-icon {
    color: #ff9800;
}

/* Authentication/Authorization errors (red theme) */
.error-auth {
    background-color: #ffebee;
    border-left-color: #f44336;
    color: #c62828;
}

.error-auth .error-icon {
    color: #f44336;
}

/* Not found errors (blue theme) */
.error-not-found {
    background-color: #e3f2fd;
    border-left-color: #2196f3;
    color: #1565c0;
}

.error-not-found .error-icon {
    color: #2196f3;
}

/* Rate limit errors (purple theme) */
.error-rate-limit {
    background-color: #f3e5f5;
    border-left-color: #9c27b0;
    color: #7b1fa2;
}

.error-rate-limit .error-icon {
    color: #9c27b0;
}

/* Service unavailable/timeout errors (orange theme) */
.error-service {
    background-color: #fff3e0;
    border-left-color: #ff9800;
    color: #ef6c00;
}

.error-service .error-icon {
    color: #ff9800;
}

/* External API errors (teal theme) */
.error-external {
    background-color: #e0f2f1;
    border-left-color: #009688;
    color: #00695c;
}

.error-external .error-icon {
    color: #009688;
}

/* General/internal errors (gray theme) */
.error-general {
    background-color: #f5f5f5;
    border-left-color: #757575;
    color: #424242;
}

.error-general .error-icon {
    color: #757575;
}

/* Desktop responsive adjustments */
@media (max-width: 768px) {
    .error-message {
        padding: 10px 12px;
        margin: 6px 0;
        font-size: 13px;
    }
    
    .error-message .error-icon {
        font-size: 16px;
        margin-right: 10px;
    }
    
    .error-message .error-close {
        top: 6px;
        right: 6px;
        font-size: 16px;
    }
    
    .error-message .error-details {
        font-size: 12px;
    }
    
    .error-message .error-trace {
        font-size: 10px;
    }
}

/* Animation for error appearance */
.error-message {
    animation: errorSlideIn 0.3s ease-out;
}

@keyframes errorSlideIn {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Global Error Container - Fixed position at top */
.error-container {
    position: fixed;
    top: 70px; /* Below header */
    left: 50%;
    transform: translateX(-50%);
    width: 90%;
    max-width: 800px;
    z-index: 9999;
    display: none; /* Hidden by default, shown when error occurs */
    pointer-events: none; /* Allow clicks through container */
}

.error-container.visible {
    display: block;
}

.error-container .error-message {
    pointer-events: all; /* But errors themselves are clickable */
    margin: 8px auto;
    transition: opacity 0.3s ease-out, transform 0.3s ease-out;
}

/* Mobile responsive */
@media (max-width: 768px) {
    .error-container {
        top: 60px;
        width: 95%;
        max-width: none;
    }
}

/* Inline error display for form fields */
.field-error {
    display: block;
    margin-top: 4px;
    font-size: 12px;
    color: #f44336;
    font-weight: 500;
}

/* Loading state with error fallback */
.loading-error {
    text-align: center;
    padding: 20px;
    color: #666;
}

.loading-error .retry-button {
    margin-top: 12px;
    padding: 8px 16px;
    background-color: #2196f3;
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
    transition: background-color 0.2s;
}

.loading-error .retry-button:hover {
    background-color: #1976d2;
}

/* Dark theme support */
@media (prefers-color-scheme: dark) {
    .error-message {
        background-color: rgba(255, 255, 255, 0.05);
        box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
    }
    
    .error-message .error-main {
        color: #fff;
    }
    
    .error-validation {
        background-color: rgba(255, 152, 0, 0.1);
        color: #ffb74d;
    }
    
    .error-auth {
        background-color: rgba(244, 67, 54, 0.1);
        color: #ef5350;
    }
    
    .error-not-found {
        background-color: rgba(33, 150, 243, 0.1);
        color: #64b5f6;
    }
    
    .error-rate-limit {
        background-color: rgba(156, 39, 176, 0.1);
        color: #ba68c8;
    }
    
    .error-service {
        background-color: rgba(255, 152, 0, 0.1);
        color: #ffb74d;
    }
    
    .error-external {
        background-color: rgba(0, 150, 136, 0.1);
        color: #4db6ac;
    }
    
    .error-general {
        background-color: rgba(117, 117, 117, 0.1);
        color: #bdbdbd;
    }
}
