/* =====================================================
   Базовые стили и CSS-переменные
   ===================================================== */

:root {
    /* ==================== ТЁМНАЯ ТЕМА (по умолчанию) ==================== */
    
    /* Основные фоны */
    --bg-primary: #0a0a0f;
    --bg-secondary: #12121a;
    --bg-card: #1a1a24;
    --bg-card-hover: #1e1e2a;
    --bg-hover: #252532;
    --bg-input: #16161e;
    --bg-elevated: #1e1e28;
    
    /* Границы */
    --border-color: #2a2a3a;
    --border-light: #222230;
    --border-focus: #4f7cff;
    
    /* Текст */
    --text-primary: #f8f8fc;
    --text-secondary: #a8a8b8;
    --text-muted: #6c6c7c;
    --text-disabled: #4a4a58;
    
    /* Акцентные цвета */
    --accent-primary: #5b8aff;
    --accent-primary-hover: #7ba3ff;
    --accent-primary-light: rgba(91, 138, 255, 0.15);
    --accent-primary-glow: rgba(91, 138, 255, 0.4);
    
    --accent-success: #36d399;
    --accent-success-light: rgba(54, 211, 153, 0.15);
    
    --accent-warning: #fbbd23;
    --accent-warning-light: rgba(251, 189, 35, 0.15);
    
    --accent-danger: #f87272;
    --accent-danger-light: rgba(248, 114, 114, 0.15);
    
    --accent-info: #6cb6ff;
    --accent-info-light: rgba(108, 182, 255, 0.15);
    
    --accent-purple: #a78bfa;
    --accent-purple-light: rgba(167, 139, 250, 0.15);
    
    /* Градиенты */
    --gradient-primary: linear-gradient(135deg, #5b8aff 0%, #a78bfa 100%);
    --gradient-success: linear-gradient(135deg, #36d399 0%, #22c55e 100%);
    --gradient-danger: linear-gradient(135deg, #f87272 0%, #ef4444 100%);
    --gradient-orange: linear-gradient(135deg, #f97316 0%, #ea580c 100%);
    --gradient-card: linear-gradient(180deg, rgba(255,255,255,0.03) 0%, transparent 100%);
    
    /* Тени */
    --shadow-xs: 0 1px 2px rgba(0, 0, 0, 0.4);
    --shadow-sm: 0 2px 4px rgba(0, 0, 0, 0.4);
    --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.5);
    --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.6);
    --shadow-xl: 0 16px 48px rgba(0, 0, 0, 0.7);
    --shadow-glow: 0 0 20px rgba(91, 138, 255, 0.3);
    --shadow-glow-success: 0 0 20px rgba(54, 211, 153, 0.3);
    --shadow-glow-danger: 0 0 20px rgba(248, 114, 114, 0.3);
    --shadow-inset: inset 0 1px 0 rgba(255, 255, 255, 0.05);
    
    /* Типографика */
    --font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    --font-mono: 'JetBrains Mono', 'Fira Code', 'SF Mono', monospace;
    
    /* Размеры */
    --sidebar-width: 280px;
    --sidebar-collapsed: 72px;
    --header-height: 68px;
    --content-max-width: 1400px;
    
    /* Радиусы */
    --radius-xs: 4px;
    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 14px;
    --radius-xl: 18px;
    --radius-2xl: 24px;
    --radius-full: 9999px;
    
    /* Переходы */
    --transition-fast: 150ms ease;
    --transition: 200ms ease;
    --transition-slow: 300ms ease;
    --transition-bounce: 300ms cubic-bezier(0.34, 1.56, 0.64, 1);
    
    /* Spacing */
    --space-1: 0.25rem;
    --space-2: 0.5rem;
    --space-3: 0.75rem;
    --space-4: 1rem;
    --space-5: 1.25rem;
    --space-6: 1.5rem;
    --space-8: 2rem;
    --space-10: 2.5rem;
    --space-12: 3rem;
}

/* ==================== СВЕТЛАЯ ТЕМА ==================== */
[data-theme="light"] {
    /* Основные фоны */
    --bg-primary: #f5f7fb;
    --bg-secondary: #ffffff;
    --bg-card: #ffffff;
    --bg-card-hover: #f8fafc;
    --bg-hover: #f1f5f9;
    --bg-input: #f8fafc;
    --bg-elevated: #ffffff;
    
    /* Границы */
    --border-color: #e2e8f0;
    --border-light: #f1f5f9;
    --border-focus: #5b8aff;
    
    /* Текст */
    --text-primary: #1e293b;
    --text-secondary: #64748b;
    --text-muted: #94a3b8;
    --text-disabled: #cbd5e1;
    
    /* Акцентные цвета немного темнее для читаемости */
    --accent-primary: #4f7cff;
    --accent-primary-hover: #3b6bf0;
    --accent-primary-light: rgba(79, 124, 255, 0.1);
    --accent-primary-glow: rgba(79, 124, 255, 0.25);
    
    --accent-success: #22c55e;
    --accent-success-light: rgba(34, 197, 94, 0.1);
    
    --accent-warning: #f59e0b;
    --accent-warning-light: rgba(245, 158, 11, 0.1);
    
    --accent-danger: #ef4444;
    --accent-danger-light: rgba(239, 68, 68, 0.1);
    
    --accent-info: #3b82f6;
    --accent-info-light: rgba(59, 130, 246, 0.1);
    
    --accent-purple: #8b5cf6;
    --accent-purple-light: rgba(139, 92, 246, 0.1);
    
    /* Градиенты */
    --gradient-card: linear-gradient(180deg, rgba(255,255,255,1) 0%, rgba(248,250,252,1) 100%);
    
    /* Тени для светлой темы */
    --shadow-xs: 0 1px 2px rgba(0, 0, 0, 0.04);
    --shadow-sm: 0 2px 4px rgba(0, 0, 0, 0.06);
    --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.08);
    --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.1);
    --shadow-xl: 0 16px 48px rgba(0, 0, 0, 0.12);
    --shadow-glow: 0 0 20px rgba(79, 124, 255, 0.2);
    --shadow-glow-success: 0 0 20px rgba(34, 197, 94, 0.2);
    --shadow-glow-danger: 0 0 20px rgba(239, 68, 68, 0.2);
    --shadow-inset: inset 0 1px 0 rgba(255, 255, 255, 1);
}

/* Reset */
*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    font-size: 14px;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    scroll-behavior: smooth;
    /* Поддержка safe area для iPhone с вырезом */
    padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}

body {
    font-family: var(--font-family);
    line-height: 1.6;
    color: var(--text-primary);
    background: var(--bg-primary);
    min-height: 100vh;
    transition: background-color var(--transition), color var(--transition);
    overflow-x: hidden;
    width: 100%;
    max-width: 100vw;
}

a {
    color: var(--accent-primary);
    text-decoration: none;
    transition: color var(--transition);
}

a:hover {
    color: var(--accent-primary-hover);
}

img {
    max-width: 100%;
    height: auto;
}

/* Скроллбар */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: var(--bg-secondary);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 4px;
    transition: background var(--transition);
}

::-webkit-scrollbar-thumb:hover {
    background: var(--text-muted);
}

/* Для Firefox */
* {
    scrollbar-width: thin;
    scrollbar-color: var(--border-color) var(--bg-secondary);
}

/* Выделение */
::selection {
    background: var(--accent-primary);
    color: white;
}

/* ==================== УТИЛИТЫ ==================== */

/* Текст */
.text-center { text-align: center; }
.text-right { text-align: right; }
.text-left { text-align: left; }
.text-muted { color: var(--text-muted); }
.text-secondary { color: var(--text-secondary); }
.text-primary { color: var(--accent-primary) !important; }
.text-success { color: var(--accent-success) !important; }
.text-warning { color: var(--accent-warning) !important; }
.text-danger { color: var(--accent-danger) !important; }
.text-info { color: var(--accent-info) !important; }

.font-medium { font-weight: 500; }
.font-semibold { font-weight: 600; }
.font-bold { font-weight: 700; }

.text-xs { font-size: 0.75rem; }
.text-sm { font-size: 0.875rem; }
.text-base { font-size: 1rem; }
.text-lg { font-size: 1.125rem; }
.text-xl { font-size: 1.25rem; }
.text-2xl { font-size: 1.5rem; }

.truncate {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Отступы */
.mt-1 { margin-top: var(--space-2); }
.mt-2 { margin-top: var(--space-4); }
.mt-3 { margin-top: var(--space-6); }
.mt-4 { margin-top: var(--space-8); }
.mt-5 { margin-top: var(--space-10); }

.mb-1 { margin-bottom: var(--space-2); }
.mb-2 { margin-bottom: var(--space-4); }
.mb-3 { margin-bottom: var(--space-6); }
.mb-4 { margin-bottom: var(--space-8); }
.mb-5 { margin-bottom: var(--space-10); }

.ml-auto { margin-left: auto; }
.mr-auto { margin-right: auto; }
.mx-auto { margin-left: auto; margin-right: auto; }

.p-0 { padding: 0; }
.p-1 { padding: var(--space-2); }
.p-2 { padding: var(--space-4); }
.p-3 { padding: var(--space-6); }
.p-4 { padding: var(--space-8); }

/* Display */
.hidden { display: none !important; }
.block { display: block; }
.inline-block { display: inline-block; }
.flex { display: flex; }
.inline-flex { display: inline-flex; }
.grid { display: grid; }

/* Flexbox */
.flex-col { flex-direction: column; }
.flex-row { flex-direction: row; }
.flex-wrap { flex-wrap: wrap; }
.flex-1 { flex: 1; }
.flex-shrink-0 { flex-shrink: 0; }

.items-start { align-items: flex-start; }
.items-center { align-items: center; }
.items-end { align-items: flex-end; }
.items-stretch { align-items: stretch; }

.justify-start { justify-content: flex-start; }
.justify-center { justify-content: center; }
.justify-end { justify-content: flex-end; }
.justify-between { justify-content: space-between; }
.justify-around { justify-content: space-around; }

.gap-1 { gap: var(--space-2); }
.gap-2 { gap: var(--space-4); }
.gap-3 { gap: var(--space-6); }
.gap-4 { gap: var(--space-8); }

/* Размеры */
.w-full { width: 100%; }
.h-full { height: 100%; }
.min-h-screen { min-height: 100vh; }

/* Позиционирование */
.relative { position: relative; }
.absolute { position: absolute; }
.fixed { position: fixed; }
.sticky { position: sticky; }

/* Overflow */
.overflow-hidden { overflow: hidden; }
.overflow-auto { overflow: auto; }
.overflow-x-auto { overflow-x: auto; }
.overflow-y-auto { overflow-y: auto; }

/* Cursor */
.cursor-pointer { cursor: pointer; }
.cursor-not-allowed { cursor: not-allowed; }

/* Opacity */
.opacity-0 { opacity: 0; }
.opacity-50 { opacity: 0.5; }
.opacity-75 { opacity: 0.75; }
.opacity-100 { opacity: 1; }

/* Transitions */
.transition-all { transition: all var(--transition); }
.transition-colors { transition: color var(--transition), background-color var(--transition), border-color var(--transition); }

/* Pointer events */
.pointer-events-none { pointer-events: none; }
.pointer-events-auto { pointer-events: auto; }

/* ==================== КОНТЕЙНЕРЫ ==================== */

.container {
    width: 100%;
    max-width: var(--content-max-width);
    margin: 0 auto;
    padding: 0 var(--space-6);
}

.container-sm { max-width: 640px; }
.container-md { max-width: 768px; }
.container-lg { max-width: 1024px; }
.container-xl { max-width: 1280px; }

/* ==================== СЕТКА ==================== */

.grid {
    display: grid;
    gap: var(--space-6);
}

.grid-cols-1 { grid-template-columns: repeat(1, 1fr); }
.grid-cols-2 { grid-template-columns: repeat(2, 1fr); }
.grid-cols-3 { grid-template-columns: repeat(3, 1fr); }
.grid-cols-4 { grid-template-columns: repeat(4, 1fr); }
.grid-cols-5 { grid-template-columns: repeat(5, 1fr); }
.grid-cols-6 { grid-template-columns: repeat(6, 1fr); }

/* Совместимость со старыми классами */
.grid-2 { grid-template-columns: repeat(2, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-4 { grid-template-columns: repeat(4, 1fr); }

@media (max-width: 1200px) {
    .grid-cols-5 { grid-template-columns: repeat(4, 1fr); }
    .grid-cols-6 { grid-template-columns: repeat(4, 1fr); }
}

@media (max-width: 1024px) {
    .grid-cols-4, .grid-4 { grid-template-columns: repeat(2, 1fr); }
    .grid-cols-3, .grid-3 { grid-template-columns: repeat(2, 1fr); }
    .grid-cols-5 { grid-template-columns: repeat(2, 1fr); }
    .grid-cols-6 { grid-template-columns: repeat(3, 1fr); }
}

@media (max-width: 640px) {
    .grid-cols-2, .grid-2,
    .grid-cols-3, .grid-3,
    .grid-cols-4, .grid-4,
    .grid-cols-5,
    .grid-cols-6 { 
        grid-template-columns: 1fr; 
    }
}

/* Классы для адаптивного скрытия */
@media (max-width: 768px) {
    .hide-mobile {
        display: none !important;
    }
}

@media (min-width: 769px) {
    .hide-desktop {
        display: none !important;
    }
}

/* ==================== АНИМАЦИИ ==================== */

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes fadeInDown {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes slideInRight {
    from {
        opacity: 0;
        transform: translateX(20px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

@keyframes slideInLeft {
    from {
        opacity: 0;
        transform: translateX(-20px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

@keyframes scaleIn {
    from {
        opacity: 0;
        transform: scale(0.95);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

@keyframes bounce {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-5px); }
}

@keyframes shimmer {
    0% { background-position: -200% 0; }
    100% { background-position: 200% 0; }
}

.animate-fadeIn { animation: fadeIn var(--transition-slow) ease; }
.animate-fadeInUp { animation: fadeInUp var(--transition-slow) ease; }
.animate-fadeInDown { animation: fadeInDown var(--transition-slow) ease; }
.animate-slideInRight { animation: slideInRight var(--transition-slow) ease; }
.animate-slideInLeft { animation: slideInLeft var(--transition-slow) ease; }
.animate-scaleIn { animation: scaleIn var(--transition-slow) ease; }
.animate-pulse { animation: pulse 2s ease infinite; }
.animate-spin { animation: spin 0.8s linear infinite; }
.animate-bounce { animation: bounce 1s ease infinite; }

/* Skeleton loading */
.skeleton {
    background: linear-gradient(90deg, var(--bg-hover) 25%, var(--border-color) 50%, var(--bg-hover) 75%);
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
    border-radius: var(--radius-sm);
}
