/* ============================================
   BASE.CSS - Базовые стили и переменные
   iOS Glass-morphism Design System
   ============================================ */

/* CSS Variables - Light Theme */
:root {
    /* Primary Colors - iOS Palette */
    --ios-blue: #007AFF;
    --ios-green: #34C759;
    --ios-orange: #FF9500;
    --ios-red: #FF3B30;
    --ios-purple: #AF52DE;
    --ios-pink: #FF2D55;
    --ios-teal: #5AC8FA;
    --ios-yellow: #FFCC00;
    --ios-gray: #8E8E93;
    
    /* Background Colors */
    --ios-bg-primary: #F2F2F7;
    --ios-bg-secondary: #FFFFFF;
    --ios-bg-tertiary: #F9F9F9;
    
    /* Glass Effects */
    --glass-bg: rgba(255, 255, 255, 0.72);
    --glass-bg-hover: rgba(255, 255, 255, 0.85);
    --glass-border: rgba(255, 255, 255, 0.18);
    --glass-shadow: rgba(31, 38, 135, 0.15);
    --glass-blur: 20px;
    
    /* Text Colors */
    --text-primary: #000000;
    --text-secondary: #8E8E93;
    --text-tertiary: #C7C7CC;
    --text-inverted: #FFFFFF;
    
    /* Border Colors */
    --border-light: #C6C6C8;
    --border-medium: #AEAEB2;
    --border-dark: #8E8E93;
    
    /* Shadow Definitions */
    --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.08);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.12);
    --shadow-xl: 0 12px 32px rgba(0, 0, 0, 0.15);
    
    /* Transition Timings */
    --transition-fast: 0.15s cubic-bezier(0.4, 0, 0.2, 1);
    --transition-base: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    --transition-slow: 0.5s cubic-bezier(0.4, 0, 0.2, 1);
    
    /* Border Radius */
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-xl: 20px;
    --radius-full: 9999px;
    
    /* Spacing Scale */
    --space-xs: 4px;
    --space-sm: 8px;
    --space-md: 12px;
    --space-lg: 16px;
    --space-xl: 20px;
    --space-2xl: 24px;
    --space-3xl: 32px;
    --space-4xl: 40px;
    
    /* Font Families */
    --font-system: -apple-system, BlinkMacSystemFont, 'SF Pro Display', 'SF Pro Text', 
                    'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
    --font-mono: 'SF Mono', Monaco, 'Cascadia Code', 'Roboto Mono', 
                 Consolas, 'Courier New', monospace;
    
    /* Font Sizes */
    --text-xs: 11px;
    --text-sm: 13px;
    --text-base: 14px;
    --text-md: 16px;
    --text-lg: 18px;
    --text-xl: 20px;
    --text-2xl: 24px;
    --text-3xl: 28px;
    --text-4xl: 32px;
    
    /* Font Weights */
    --font-regular: 400;
    --font-medium: 500;
    --font-semibold: 600;
    --font-bold: 700;
    
    /* Z-Index Scale */
    --z-base: 1;
    --z-dropdown: 1000;
    --z-sticky: 1020;
    --z-fixed: 1030;
    --z-modal-backdrop: 1040;
    --z-modal: 1050;
    --z-popover: 1060;
    --z-tooltip: 1070;
    --z-toast: 1080;
}

/* Dark Theme Support (Optional) */
@media (prefers-color-scheme: dark) {
    :root {
        --ios-bg-primary: #000000;
        --ios-bg-secondary: #1C1C1E;
        --ios-bg-tertiary: #2C2C2E;
        
        --glass-bg: rgba(28, 28, 30, 0.72);
        --glass-bg-hover: rgba(28, 28, 30, 0.85);
        --glass-border: rgba(255, 255, 255, 0.12);
        --glass-shadow: rgba(0, 0, 0, 0.3);
        
        --text-primary: #FFFFFF;
        --text-secondary: #98989D;
        --text-tertiary: #48484A;
        
        --border-light: #38383A;
        --border-medium: #48484A;
        --border-dark: #636366;
    }
}

/* Reset & Base Styles */
*,
*::before,
*::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    font-size: 16px;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-rendering: optimizeLegibility;
}

body {
    font-family: var(--font-system);
    font-size: var(--text-base);
    font-weight: var(--font-regular);
    line-height: 1.5;
    color: var(--text-primary);
    background: var(--ios-bg-primary);
    overflow-x: hidden;
    min-height: 100vh;
}

/* Typography */
h1, h2, h3, h4, h5, h6 {
    font-weight: var(--font-bold);
    line-height: 1.2;
    color: var(--text-primary);
    margin: 0;
}

h1 {
    font-size: var(--text-4xl);
    letter-spacing: -0.5px;
}

h2 {
    font-size: var(--text-3xl);
    letter-spacing: -0.3px;
}

h3 {
    font-size: var(--text-2xl);
    letter-spacing: -0.2px;
}

h4 {
    font-size: var(--text-xl);
}

h5 {
    font-size: var(--text-lg);
}

h6 {
    font-size: var(--text-md);
}

p {
    margin: 0;
    line-height: 1.6;
}

a {
    color: var(--ios-blue);
    text-decoration: none;
    transition: color var(--transition-fast);
}

a:hover {
    color: #0051D5;
}

strong, b {
    font-weight: var(--font-semibold);
}

em, i {
    font-style: italic;
}

code {
    font-family: var(--font-mono);
    font-size: 0.9em;
    padding: 2px 6px;
    background: var(--ios-bg-tertiary);
    border-radius: var(--radius-sm);
    color: var(--ios-purple);
}

pre {
    font-family: var(--font-mono);
    font-size: var(--text-sm);
    padding: var(--space-lg);
    background: var(--ios-bg-tertiary);
    border-radius: var(--radius-md);
    overflow-x: auto;
}

/* Lists */
ul, ol {
    list-style: none;
}

ul.styled,
ol.styled {
    padding-left: var(--space-xl);
}

ul.styled {
    list-style: disc;
}

ol.styled {
    list-style: decimal;
}

/* Images */
img {
    max-width: 100%;
    height: auto;
    display: block;
}

/* Scrollbar Styling */
::-webkit-scrollbar {
    width: 10px;
    height: 10px;
}

::-webkit-scrollbar-track {
    background: var(--ios-bg-tertiary);
    border-radius: var(--radius-full);
}

::-webkit-scrollbar-thumb {
    background: var(--border-medium);
    border-radius: var(--radius-full);
    transition: background var(--transition-fast);
}

::-webkit-scrollbar-thumb:hover {
    background: var(--border-dark);
}

/* Selection */
::selection {
    background: rgba(0, 122, 255, 0.2);
    color: var(--text-primary);
}

::-moz-selection {
    background: rgba(0, 122, 255, 0.2);
    color: var(--text-primary);
}

/* Focus Styles */
:focus {
    outline: none;
}

:focus-visible {
    outline: 2px solid var(--ios-blue);
    outline-offset: 2px;
}

/* Utility Classes */
.text-center { text-align: center; }
.text-left { text-align: left; }
.text-right { text-align: right; }

.font-regular { font-weight: var(--font-regular); }
.font-medium { font-weight: var(--font-medium); }
.font-semibold { font-weight: var(--font-semibold); }
.font-bold { font-weight: var(--font-bold); }

.text-xs { font-size: var(--text-xs); }
.text-sm { font-size: var(--text-sm); }
.text-base { font-size: var(--text-base); }
.text-md { font-size: var(--text-md); }
.text-lg { font-size: var(--text-lg); }
.text-xl { font-size: var(--text-xl); }
.text-2xl { font-size: var(--text-2xl); }
.text-3xl { font-size: var(--text-3xl); }
.text-4xl { font-size: var(--text-4xl); }

.text-primary { color: var(--text-primary); }
.text-secondary { color: var(--text-secondary); }
.text-tertiary { color: var(--text-tertiary); }

.bg-primary { background-color: var(--ios-bg-primary); }
.bg-secondary { background-color: var(--ios-bg-secondary); }
.bg-tertiary { background-color: var(--ios-bg-tertiary); }

/* Layout Utilities */
.container {
    width: 100%;
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 var(--space-xl);
}

.container-fluid {
    width: 100%;
    padding: 0 var(--space-xl);
}

.flex { display: flex; }
.inline-flex { display: inline-flex; }
.grid { display: grid; }
.hidden { display: none; }
.block { display: block; }
.inline-block { display: inline-block; }

.flex-row { flex-direction: row; }
.flex-col { flex-direction: column; }
.flex-wrap { flex-wrap: wrap; }
.flex-nowrap { flex-wrap: nowrap; }

.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; }

.flex-1 { flex: 1; }
.flex-auto { flex: auto; }
.flex-none { flex: none; }

/* Spacing Utilities */
.gap-xs { gap: var(--space-xs); }
.gap-sm { gap: var(--space-sm); }
.gap-md { gap: var(--space-md); }
.gap-lg { gap: var(--space-lg); }
.gap-xl { gap: var(--space-xl); }
.gap-2xl { gap: var(--space-2xl); }

/* Overflow */
.overflow-auto { overflow: auto; }
.overflow-hidden { overflow: hidden; }
.overflow-x-auto { overflow-x: auto; }
.overflow-y-auto { overflow-y: auto; }

/* Position */
.relative { position: relative; }
.absolute { position: absolute; }
.fixed { position: fixed; }
.sticky { position: sticky; }

/* Main Layout */
.ios-main {
    max-width: 1200px;
    margin: 0 auto;
    padding: var(--space-2xl);
    animation: fadeIn 0.4s ease;
}

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

.ios-container {
    display: flex;
    flex-direction: column;
    gap: var(--space-2xl);
}

.ios-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: var(--space-lg);
    margin-bottom: var(--space-md);
}

.ios-header h2 {
    font-size: var(--text-3xl);
    font-weight: var(--font-bold);
    letter-spacing: -0.3px;
}

/* Responsive Design */
@media (max-width: 1024px) {
    .container {
        max-width: 960px;
    }
}

@media (max-width: 768px) {
    html {
        font-size: 15px;
    }
    
    .ios-main {
        padding: var(--space-lg);
    }
    
    .ios-header {
        flex-direction: column;
        align-items: flex-start;
    }
    
    .container,
    .container-fluid {
        padding: 0 var(--space-md);
    }
}

@media (max-width: 480px) {
    html {
        font-size: 14px;
    }
    
    .ios-main {
        padding: var(--space-md);
    }
}

/* Print Styles */
@media print {
    body {
        background: white;
        color: black;
    }
    
    .ios-nav,
    .btn,
    .modal {
        display: none !important;
    }
}

