/* ============================================================================
 * WebTelega UI Improvements - Unified Loading & Enhanced System Health
 * UI/UX улучшения: унифицированные индикаторы и System Health grid
 * ============================================================================ */

/* ============================================================================ 
 * Unified Loading Spinner System
 * Унифицированная система индикаторов загрузки
 * ============================================================================ */

/* Base loading spinner */
.loading-spinner {
    display: inline-block;
    width: 2rem;
    height: 2rem;
    border: 0.25em solid rgba(var(--primary-600), 0.25);
    border-radius: 50%;
    border-top-color: var(--primary-600);
    animation: loading-spin 1s ease-in-out infinite;
    flex-shrink: 0;
}

/* Size variations */
.loading-spinner.sm {
    width: 1rem;
    height: 1rem;
    border-width: 0.125em;
}

.loading-spinner.lg {
    width: 3rem;
    height: 3rem;
    border-width: 0.375em;
}

.loading-spinner.xl {
    width: 4rem;
    height: 4rem;
    border-width: 0.5em;
}

/* Loading animation */
@keyframes loading-spin {
    to { 
        transform: rotate(360deg); 
    }
}

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

.loading-container.inline {
    flex-direction: row;
    min-height: auto;
    padding: 1rem;
}

.loading-container.compact {
    padding: 1rem;
    min-height: 100px;
}

.loading-text {
    color: var(--text-secondary);
    font-size: 0.9rem;
    font-weight: 500;
    text-align: center;
    margin: 0;
}

/* Different loading states */
.loading-container.success .loading-spinner {
    border-color: rgba(var(--success-500), 0.25);
    border-top-color: var(--success-500);
}

.loading-container.warning .loading-spinner {
    border-color: rgba(var(--warning-500), 0.25);
    border-top-color: var(--warning-500);
}

.loading-container.error .loading-spinner {
    border-color: rgba(var(--danger-500), 0.25);
    border-top-color: var(--danger-500);
}

/* ============================================================================
 * Enhanced System Health Grid
 * Улучшенная система отображения System Health
 * ============================================================================ */

.system-health-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1.5rem;
    margin-top: 1.5rem;
}

.health-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 1.5rem 1rem;
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-lg);
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
}

.health-item::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
    background: var(--gray-300);
    transition: background 0.3s ease;
}

.health-item.online::before {
    background: var(--success-500);
}

.health-item.warning::before {
    background: var(--warning-500);
}

.health-item.error::before {
    background: var(--danger-500);
}

.health-item.offline::before {
    background: var(--gray-400);
}

.health-item:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-lg);
    border-color: var(--primary-300);
}

.health-item-icon {
    width: 3rem;
    height: 3rem;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 1rem;
    font-size: 1.5rem;
    color: var(--primary-600);
    background: var(--primary-50);
    transition: all 0.3s ease;
}

.health-item.online .health-item-icon {
    color: var(--success-600);
    background: var(--success-50);
}

.health-item.warning .health-item-icon {
    color: var(--warning-600);
    background: var(--warning-50);
}

.health-item.error .health-item-icon {
    color: var(--danger-600);
    background: var(--danger-50);
}

.health-item.offline .health-item-icon {
    color: var(--gray-500);
    background: var(--gray-100);
}

.health-label {
    font-size: 0.875rem;
    color: var(--text-secondary);
    margin-bottom: 0.5rem;
    text-align: center;
    font-weight: 500;
}

.health-value {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--text-primary);
    text-align: center;
    margin: 0;
}

.health-item.online .health-value {
    color: var(--success-600);
}

.health-item.warning .health-value {
    color: var(--warning-600);
}

.health-item.error .health-value {
    color: var(--danger-600);
}

.health-item.offline .health-value {
    color: var(--gray-500);
}

.health-secondary {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-top: 0.25rem;
    text-align: center;
}

/* ============================================================================
 * API Docs Section Enhancements
 * Улучшения для секции API документации
 * ============================================================================ */

.api-docs-navigation {
    position: sticky;
    top: 1rem;
}

.docs-content {
    max-height: 70vh;
    overflow-y: auto;
    padding: 1.5rem;
}

.docs-content pre {
    background: var(--gray-50);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    padding: 1rem;
    font-size: 0.875rem;
    line-height: 1.5;
    overflow-x: auto;
}

.docs-content code {
    background: var(--gray-100);
    padding: 0.125rem 0.375rem;
    border-radius: 0.25rem;
    font-size: 0.875em;
    color: var(--danger-600);
}

.docs-content pre code {
    background: none;
    padding: 0;
    color: inherit;
}

.api-endpoint {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    padding: 1rem;
    margin: 1rem 0;
}

.api-method {
    display: inline-block;
    padding: 0.25rem 0.75rem;
    border-radius: 0.375rem;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    margin-right: 0.5rem;
}

.api-method.get {
    background: var(--success-100);
    color: var(--success-700);
}

.api-method.post {
    background: var(--primary-100);
    color: var(--primary-700);
}

.api-method.put {
    background: var(--warning-100);
    color: var(--warning-700);
}

.api-method.delete {
    background: var(--danger-100);
    color: var(--danger-700);
}

/* ============================================================================
 * Dark Mode Enhancements
 * Улучшения темной темы
 * ============================================================================ */

[data-theme="dark"] {
    --bg-primary: var(--gray-900);
    --bg-secondary: var(--gray-800);
    --bg-tertiary: var(--gray-700);
    --text-primary: var(--gray-100);
    --text-secondary: var(--gray-300);
    --text-muted: var(--gray-400);
    --border-color: var(--gray-700);
}

[data-theme="dark"] .loading-spinner {
    border-color: rgba(255, 255, 255, 0.25);
    border-top-color: var(--primary-400);
}

[data-theme="dark"] .health-item {
    background: var(--gray-800);
    border-color: var(--gray-700);
}

[data-theme="dark"] .health-item:hover {
    border-color: var(--primary-500);
}

[data-theme="dark"] .docs-content pre {
    background: var(--gray-800);
    border-color: var(--gray-700);
}

[data-theme="dark"] .docs-content code {
    background: var(--gray-700);
    color: var(--danger-400);
}

[data-theme="dark"] .api-endpoint {
    background: var(--gray-800);
    border-color: var(--gray-700);
}

/* ============================================================================
 * Responsive Design Enhancements
 * Улучшения адаптивного дизайна
 * ============================================================================ */

@media (max-width: 768px) {
    .system-health-grid {
        grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
        gap: 1rem;
    }
    
    .health-item {
        padding: 1rem 0.75rem;
    }
    
    .health-item-icon {
        width: 2.5rem;
        height: 2.5rem;
        font-size: 1.25rem;
    }
    
    .loading-container {
        padding: 1.5rem 1rem;
        min-height: 150px;
    }
    
    .docs-content {
        max-height: 50vh;
        padding: 1rem;
    }
}

@media (max-width: 576px) {
    .system-health-grid {
        grid-template-columns: 1fr 1fr;
        gap: 0.75rem;
    }
    
    .health-item {
        padding: 0.75rem 0.5rem;
    }
    
    .health-value {
        font-size: 1.125rem;
    }
    
    .loading-container {
        padding: 1rem;
        min-height: 120px;
    }
    
    .loading-spinner {
        width: 1.5rem;
        height: 1.5rem;
    }
}

/* ============================================================================
 * Animation & Micro-interactions
 * Анимации и микровзаимодействия
 * ============================================================================ */

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

.fade-in {
    animation: fadeIn 0.3s ease-out;
}

@keyframes slideInUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.slide-in-up {
    animation: slideInUp 0.4s ease-out;
}

/* Stagger animation for grid items */
.system-health-grid .health-item {
    animation: slideInUp 0.4s ease-out;
    animation-fill-mode: both;
}

.system-health-grid .health-item:nth-child(1) { animation-delay: 0.1s; }
.system-health-grid .health-item:nth-child(2) { animation-delay: 0.2s; }
.system-health-grid .health-item:nth-child(3) { animation-delay: 0.3s; }
.system-health-grid .health-item:nth-child(4) { animation-delay: 0.4s; }
.system-health-grid .health-item:nth-child(5) { animation-delay: 0.5s; }
.system-health-grid .health-item:nth-child(6) { animation-delay: 0.6s; }

/* ============================================================================
 * Accessibility Improvements
 * Улучшения доступности
 * ============================================================================ */

.loading-spinner {
    /* Screen reader accessibility */
    background-image: none;
}

.loading-container[aria-busy="true"] {
    /* Indicate busy state for screen readers */
}

.health-item:focus {
    outline: 2px solid var(--primary-500);
    outline-offset: 2px;
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    .loading-spinner {
        border-width: 0.375em;
    }
    
    .health-item {
        border-width: 2px;
    }
    
    .health-item::before {
        height: 6px;
    }
}

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {
    .loading-spinner {
        animation: none;
    }
    
    .health-item {
        transition: none;
    }
    
    .slide-in-up,
    .fade-in {
        animation: none;
    }
}