/* ========================================
   CROSS-PLATFORM OPTIMIZATION CSS
   Оптимизация для Windows, Mac, Android, iPhone
   ======================================== */

/* ========================================
   GLOBAL RESET & BASE STYLES
   ======================================== */
* {
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
    -webkit-touch-callout: none;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
}

html {
    -webkit-text-size-adjust: 100%;
    -ms-text-size-adjust: 100%;
    text-size-adjust: 100%;
    font-size: 16px;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

body {
    margin: 0;
    padding: 0;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background-color: #f8f9fa;
    color: #333;
    overflow-x: hidden;
    -webkit-overflow-scrolling: touch;
}

/* ========================================
   RESPONSIVE BREAKPOINTS
   ======================================== */
:root {
    --mobile: 480px;
    --tablet: 768px;
    --desktop: 1024px;
    --large: 1200px;
    --xlarge: 1400px;
}

/* ========================================
   MOBILE-FIRST APPROACH
   ======================================== */

/* Base mobile styles */
.container {
    width: 100%;
    padding: 0 15px;
    margin: 0 auto;
}

/* Tablet and up */
@media (min-width: 768px) {
    .container {
        max-width: 750px;
        padding: 0 20px;
    }
}

/* Desktop and up */
@media (min-width: 1024px) {
    .container {
        max-width: 970px;
        padding: 0 30px;
    }
}

/* Large desktop */
@media (min-width: 1200px) {
    .container {
        max-width: 1170px;
    }
}

/* ========================================
   iOS SPECIFIC OPTIMIZATIONS
   ======================================== */
@supports (-webkit-touch-callout: none) {
    /* iOS Safari specific */
    body {
        -webkit-overflow-scrolling: touch;
        -webkit-font-smoothing: antialiased;
    }
    
    /* Fix for iOS Safari 100vh issue */
    .full-height {
        height: 100vh;
        height: -webkit-fill-available;
    }
    
    /* iOS input styling */
    input, textarea, select {
        -webkit-appearance: none;
        border-radius: 0;
        font-size: 16px; /* Prevents zoom on focus */
    }
    
    /* iOS button styling */
    button {
        -webkit-appearance: none;
        border-radius: 0;
    }
    
    /* iOS scrollbar */
    ::-webkit-scrollbar {
        -webkit-appearance: none;
        width: 7px;
    }
    
    ::-webkit-scrollbar-thumb {
        border-radius: 4px;
        background-color: rgba(0,0,0,.5);
        -webkit-box-shadow: 0 0 1px rgba(255,255,255,.5);
    }
}

/* ========================================
   ANDROID SPECIFIC OPTIMIZATIONS
   ======================================== */
@supports not (-webkit-touch-callout: none) {
    /* Android specific */
    body {
        -webkit-overflow-scrolling: touch;
    }
    
    /* Android input styling */
    input, textarea, select {
        font-size: 16px; /* Prevents zoom on focus */
    }
}

/* ========================================
   WINDOWS/MAC DESKTOP OPTIMIZATIONS
   ======================================== */
@media (min-width: 1024px) {
    /* Desktop hover effects */
    .hover-effect {
        transition: all 0.3s ease;
    }
    
    .hover-effect:hover {
        transform: translateY(-2px);
        box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    }
    
    /* Desktop scrollbar */
    ::-webkit-scrollbar {
        width: 8px;
    }
    
    ::-webkit-scrollbar-track {
        background: #f1f1f1;
    }
    
    ::-webkit-scrollbar-thumb {
        background: #888;
        border-radius: 4px;
    }
    
    ::-webkit-scrollbar-thumb:hover {
        background: #555;
    }
}

/* ========================================
   TOUCH OPTIMIZATIONS
   ======================================== */
@media (hover: none) and (pointer: coarse) {
    /* Touch devices */
    .touch-target {
        min-height: 44px;
        min-width: 44px;
        padding: 12px;
    }
    
    /* Larger touch targets for buttons */
    button, .btn, input[type="submit"], input[type="button"] {
        min-height: 44px;
        min-width: 44px;
        padding: 12px 20px;
    }
    
    /* Touch-friendly spacing */
    .touch-spacing > * {
        margin-bottom: 16px;
    }
    
    /* Disable hover effects on touch devices */
    .hover-effect:hover {
        transform: none;
        box-shadow: none;
    }
}

/* ========================================
   PERFORMANCE OPTIMIZATIONS
   ======================================== */
/* Hardware acceleration for animations */
.accelerated {
    transform: translateZ(0);
    -webkit-transform: translateZ(0);
    will-change: transform;
}

/* Smooth animations */
.animate {
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ========================================
   ACCESSIBILITY IMPROVEMENTS
   ======================================== */
/* Focus indicators */
*:focus {
    outline: 2px solid #007bff;
    outline-offset: 2px;
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    body {
        background-color: #000;
        color: #fff;
    }
    
    .btn {
        border: 2px solid currentColor;
    }
}

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* ========================================
   DARK MODE SUPPORT
   ======================================== */
@media (prefers-color-scheme: dark) {
    :root {
        --bg-color: #1a1a1a;
        --text-color: #ffffff;
        --border-color: #333333;
        --card-bg: #2d2d2d;
    }
    
    body {
        background-color: var(--bg-color);
        color: var(--text-color);
    }
    
    .card, .modal, .dropdown-menu {
        background-color: var(--card-bg);
        border-color: var(--border-color);
    }
}

/* ========================================
   UTILITY CLASSES
   ======================================== */
/* Flexbox utilities */
.flex {
    display: flex;
}

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

.flex-center {
    justify-content: center;
    align-items: center;
}

.flex-between {
    justify-content: space-between;
}

.flex-wrap {
    flex-wrap: wrap;
}

/* Grid utilities */
.grid {
    display: grid;
}

.grid-2 {
    grid-template-columns: repeat(2, 1fr);
}

.grid-3 {
    grid-template-columns: repeat(3, 1fr);
}

.grid-4 {
    grid-template-columns: repeat(4, 1fr);
}

/* Responsive grid */
@media (max-width: 768px) {
    .grid-2, .grid-3, .grid-4 {
        grid-template-columns: 1fr;
    }
}

/* Spacing utilities */
.m-0 { margin: 0; }
.m-1 { margin: 0.25rem; }
.m-2 { margin: 0.5rem; }
.m-3 { margin: 1rem; }
.m-4 { margin: 1.5rem; }
.m-5 { margin: 3rem; }

.p-0 { padding: 0; }
.p-1 { padding: 0.25rem; }
.p-2 { padding: 0.5rem; }
.p-3 { padding: 1rem; }
.p-4 { padding: 1.5rem; }
.p-5 { padding: 3rem; }

/* Text utilities */
.text-center { text-align: center; }
.text-left { text-align: left; }
.text-right { text-align: right; }

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

/* Display utilities */
.d-none { display: none; }
.d-block { display: block; }
.d-inline { display: inline; }
.d-inline-block { display: inline-block; }
.d-flex { display: flex; }
.d-grid { display: grid; }

/* Responsive display */
@media (min-width: 768px) {
    .d-md-none { display: none; }
    .d-md-block { display: block; }
    .d-md-flex { display: flex; }
}

@media (min-width: 1024px) {
    .d-lg-none { display: none; }
    .d-lg-block { display: block; }
    .d-lg-flex { display: flex; }
}

/* ========================================
   COMPONENT STYLES
   ======================================== */
/* Button styles */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 12px 24px;
    border: none;
    border-radius: 8px;
    font-size: 16px;
    font-weight: 500;
    text-decoration: none;
    cursor: pointer;
    transition: all 0.3s ease;
    min-height: 44px;
    min-width: 44px;
}

.btn-primary {
    background-color: #007bff;
    color: white;
}

.btn-primary:hover {
    background-color: #0056b3;
}

.btn-secondary {
    background-color: #6c757d;
    color: white;
}

.btn-success {
    background-color: #28a745;
    color: white;
}

.btn-danger {
    background-color: #dc3545;
    color: white;
}

/* Card styles */
.card {
    background: white;
    border-radius: 12px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    padding: 20px;
    margin-bottom: 20px;
    transition: box-shadow 0.3s ease;
}

.card:hover {
    box-shadow: 0 4px 16px rgba(0,0,0,0.15);
}

/* Form styles */
.form-group {
    margin-bottom: 20px;
}

.form-label {
    display: block;
    margin-bottom: 8px;
    font-weight: 500;
    color: #333;
}

.form-input {
    width: 100%;
    padding: 12px 16px;
    border: 2px solid #e1e5e9;
    border-radius: 8px;
    font-size: 16px;
    transition: border-color 0.3s ease;
}

.form-input:focus {
    outline: none;
    border-color: #007bff;
}

/* Navigation styles */
.nav {
    display: flex;
    align-items: center;
    padding: 16px 0;
}

.nav-brand {
    font-size: 24px;
    font-weight: bold;
    text-decoration: none;
    color: #333;
}

.nav-menu {
    display: flex;
    list-style: none;
    margin: 0;
    padding: 0;
    gap: 24px;
}

.nav-link {
    text-decoration: none;
    color: #666;
    font-weight: 500;
    transition: color 0.3s ease;
}

.nav-link:hover {
    color: #007bff;
}

/* Mobile menu */
.nav-toggle {
    display: none;
    background: none;
    border: none;
    font-size: 24px;
    cursor: pointer;
}

@media (max-width: 768px) {
    .nav-toggle {
        display: block;
    }
    
    .nav-menu {
        display: none;
        position: absolute;
        top: 100%;
        left: 0;
        right: 0;
        background: white;
        flex-direction: column;
        padding: 20px;
        box-shadow: 0 4px 8px rgba(0,0,0,0.1);
    }
    
    .nav-menu.active {
        display: flex;
    }
}

/* ========================================
   LOADING STATES
   ======================================== */
.loading {
    opacity: 0.6;
    pointer-events: none;
}

.spinner {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 2px solid #f3f3f3;
    border-top: 2px solid #007bff;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

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

/* ========================================
   PRINT STYLES
   ======================================== */
@media print {
    .no-print {
        display: none !important;
    }
    
    body {
        background: white !important;
        color: black !important;
    }
    
    .card {
        box-shadow: none !important;
        border: 1px solid #ccc !important;
    }
}
