/* Enhanced Error and Loading States Styles */

/* Loading States */
.loading-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 3rem 2rem;
    text-align: center;
    min-height: 200px;
}

.loading-spinner {
    width: 40px;
    height: 40px;
    border: 4px solid #f3f3f3;
    border-top: 4px solid #3498db;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-bottom: 1rem;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.loading-content {
    max-width: 400px;
    width: 100%;
}

.loading-message {
    color: #6c757d;
    font-size: 1rem;
    margin-bottom: 1rem;
    font-weight: 500;
}

.loading-progress {
    width: 100%;
    margin-top: 1rem;
}

.progress-bar {
    width: 100%;
    height: 4px;
    background-color: #e9ecef;
    border-radius: 2px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, #3498db, #2ecc71);
    border-radius: 2px;
    transition: width 0.3s ease;
    animation: progress-pulse 2s ease-in-out infinite;
}

@keyframes progress-pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.7; }
}

/* Error States */
.error-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 3rem 2rem;
    text-align: center;
    min-height: 200px;
    background: #fff;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    border: 1px solid #f8d7da;
}

.error-icon {
    font-size: 3rem;
    margin-bottom: 1rem;
    opacity: 0.8;
}

.error-content {
    max-width: 500px;
    width: 100%;
}

.error-content h3 {
    color: #721c24;
    margin-bottom: 1rem;
    font-size: 1.5rem;
    font-weight: 600;
}

.error-message {
    color: #721c24;
    font-size: 1rem;
    margin-bottom: 1rem;
    line-height: 1.5;
}

.error-code {
    color: #856404;
    font-size: 0.875rem;
    font-family: 'Courier New', monospace;
    background: #fff3cd;
    padding: 0.5rem;
    border-radius: 4px;
    margin-bottom: 1rem;
    border: 1px solid #ffeaa7;
}

.error-attempts {
    color: #6c757d;
    font-size: 0.875rem;
    margin-bottom: 1.5rem;
    font-style: italic;
}

.error-actions {
    display: flex;
    gap: 1rem;
    justify-content: center;
    flex-wrap: wrap;
}

.error-actions .btn {
    min-width: 120px;
}

/* Specific Error Types */
.error-container.network-error {
    border-color: #dc3545;
}

.error-container.network-error .error-icon::before {
    content: '🌐';
}

.error-container.timeout-error {
    border-color: #fd7e14;
}

.error-container.timeout-error .error-icon::before {
    content: '⏱️';
}

.error-container.data-error {
    border-color: #6f42c1;
}

.error-container.data-error .error-icon::before {
    content: '📄';
}

/* Enhanced Button Styles for Error Actions */
.btn-primary {
    background: #3498db;
    border-color: #3498db;
    color: white;
    transition: all 0.2s ease;
}

.btn-primary:hover {
    background: #2980b9;
    border-color: #2980b9;
    transform: translateY(-1px);
}

.btn-primary:active {
    transform: translateY(0);
}

.retry-btn {
    position: relative;
    overflow: hidden;
}

.retry-btn:hover::after {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.2), transparent);
    animation: shimmer 0.6s ease-out;
}

@keyframes shimmer {
    0% { left: -100%; }
    100% { left: 100%; }
}

/* Empty States */
.empty-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 3rem 2rem;
    text-align: center;
    min-height: 200px;
    color: #6c757d;
}

.empty-container .empty-icon {
    font-size: 4rem;
    margin-bottom: 1rem;
    opacity: 0.5;
}

.empty-container h3 {
    color: #6c757d;
    margin-bottom: 1rem;
    font-weight: 500;
}

.empty-container p {
    color: #868e96;
    margin-bottom: 1.5rem;
    max-width: 400px;
}

/* Notification Styles */
.notification {
    position: fixed;
    top: 20px;
    right: 20px;
    padding: 1rem 1.5rem;
    border-radius: 4px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    z-index: 1000;
    max-width: 400px;
    animation: slideIn 0.3s ease-out;
}

@keyframes slideIn {
    from {
        transform: translateX(100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

.notification.success {
    background: #d4edda;
    color: #155724;
    border: 1px solid #c3e6cb;
}

.notification.error {
    background: #f8d7da;
    color: #721c24;
    border: 1px solid #f5c6cb;
}

.notification.warning {
    background: #fff3cd;
    color: #856404;
    border: 1px solid #ffeaa7;
}

.notification.info {
    background: #cce7ff;
    color: #004085;
    border: 1px solid #b3d7ff;
}

/* Responsive Design */
@media (max-width: 768px) {
    .loading-container,
    .error-container,
    .empty-container {
        padding: 2rem 1rem;
        min-height: 150px;
    }

    .error-content h3 {
        font-size: 1.25rem;
    }

    .error-message {
        font-size: 0.9rem;
    }

    .error-actions {
        flex-direction: column;
        align-items: center;
    }

    .error-actions .btn {
        width: 100%;
        max-width: 200px;
    }

    .notification {
        top: 10px;
        right: 10px;
        left: 10px;
        max-width: none;
    }
}

@media (max-width: 480px) {
    .loading-spinner {
        width: 32px;
        height: 32px;
        border-width: 3px;
    }

    .error-icon {
        font-size: 2.5rem;
    }

    .empty-container .empty-icon {
        font-size: 3rem;
    }

    .loading-container,
    .error-container,
    .empty-container {
        padding: 1.5rem 0.5rem;
    }
}

/* Accessibility Improvements */
@media (prefers-reduced-motion: reduce) {
    .loading-spinner {
        animation: none;
        border-top-color: #3498db;
    }

    .progress-fill {
        animation: none;
    }

    .retry-btn:hover::after {
        animation: none;
    }

    .notification {
        animation: none;
    }
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    .error-container {
        border-width: 2px;
    }

    .loading-spinner {
        border-width: 3px;
    }

    .progress-bar {
        border: 1px solid #333;
    }
}

/* Focus styles for accessibility */
.retry-btn:focus,
.reload-btn:focus {
    outline: 2px solid #3498db;
    outline-offset: 2px;
}

/* Notification System Styles */
.notification-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 10000;
    pointer-events: none;
}

.notification {
    display: flex;
    align-items: flex-start;
    background: white;
    border-radius: 8px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.15);
    margin-bottom: 10px;
    max-width: 400px;
    min-width: 300px;
    opacity: 0;
    transform: translateX(100%);
    transition: all 0.3s ease;
    pointer-events: auto;
    border-left: 4px solid #3498db;
}

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

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

.notification.success {
    border-left-color: #28a745;
}

.notification.error {
    border-left-color: #dc3545;
}

.notification.warning {
    border-left-color: #ffc107;
}

.notification.info {
    border-left-color: #17a2b8;
}

.notification-content {
    flex: 1;
    padding: 1rem;
}

.notification-title {
    font-weight: 600;
    margin-bottom: 0.5rem;
    color: #2c3e50;
}

.notification-message {
    color: #6c757d;
    font-size: 0.9rem;
    line-height: 1.4;
}

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

.notification-btn {
    padding: 0.25rem 0.75rem;
    border: 1px solid #dee2e6;
    background: white;
    color: #495057;
    border-radius: 4px;
    font-size: 0.8rem;
    cursor: pointer;
    transition: all 0.2s ease;
}

.notification-btn:hover {
    background: #f8f9fa;
}

.notification-btn.primary {
    background: #3498db;
    color: white;
    border-color: #3498db;
}

.notification-btn.primary:hover {
    background: #2980b9;
}

.notification-close {
    background: none;
    border: none;
    font-size: 1.5rem;
    color: #6c757d;
    cursor: pointer;
    padding: 0.5rem;
    line-height: 1;
    transition: color 0.2s ease;
}

.notification-close:hover {
    color: #495057;
}

/* Enhanced Loading States */
.loading-state {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 200px;
    padding: 2rem;
}

.loading-overlay {
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(2px);
}

.loading-fade-out {
    opacity: 0;
    transition: opacity 0.3s ease;
}

/* Button Loading States */
.btn-loading {
    position: relative;
    color: transparent !important;
    pointer-events: none;
}

.btn-loading::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 16px;
    height: 16px;
    margin: -8px 0 0 -8px;
    border: 2px solid transparent;
    border-top-color: currentColor;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

.btn-loading.btn-primary::after {
    border-top-color: white;
}

.btn-loading.btn-secondary::after {
    border-top-color: white;
}

/* Global Loading State */
body.app-loading {
    cursor: wait;
}

body.app-loading * {
    pointer-events: none;
}

body.app-loading .loading-state,
body.app-loading .notification {
    pointer-events: auto;
}

/* Interactive Feedback */
.interactive-feedback {
    position: relative;
    overflow: hidden;
}

.interactive-feedback::after {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.3), transparent);
    transition: left 0.5s ease;
}

.interactive-feedback:hover::after {
    left: 100%;
}

/* Touch Feedback */
.touch-feedback {
    transition: transform 0.1s ease, box-shadow 0.1s ease;
}

.touch-feedback:active {
    transform: scale(0.98);
    box-shadow: 0 2px 8px rgba(0,0,0,0.2);
}

/* Skeleton Loading */
.skeleton {
    background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
    background-size: 200% 100%;
    animation: skeleton-loading 1.5s infinite;
}

@keyframes skeleton-loading {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

.skeleton-text {
    height: 1em;
    border-radius: 4px;
    margin-bottom: 0.5em;
}

.skeleton-text.short {
    width: 60%;
}

.skeleton-text.medium {
    width: 80%;
}

.skeleton-text.long {
    width: 100%;
}

/* Responsive Notifications */
@media (max-width: 768px) {
    .notification-container {
        top: 10px;
        right: 10px;
        left: 10px;
    }

    .notification {
        min-width: auto;
        max-width: none;
    }

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

    .notification-btn {
        width: 100%;
        text-align: center;
    }
}

/* Print styles */
@media print {
    .loading-container,
    .error-container,
    .notification,
    .notification-container {
        display: none;
    }
}