/* universal-a11y-system.css - Единая система доступности для всех страниц */

/* Виджет доступности - универсальный */
.universal-a11y-widget {
    position: fixed;
    bottom: 150px;
    right: 25px;
    z-index: 1001;
    font-family: 'Manrope', sans-serif;
}

/* Кнопка открытия панели */
.universal-a11y-toggle-btn {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: linear-gradient(135deg, #0d9488, #0f766e);
    border: none;
    color: white;
    font-size: 24px;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.universal-a11y-toggle-btn:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.2);
}

.universal-a11y-toggle-btn:active {
    transform: scale(0.95);
}

/* Панель настроек */
.universal-a11y-panel {
    position: absolute;
    bottom: 70px;
    right: 0;
    width: 320px;
    max-height: 60vh;
    background: white;
    border-radius: 12px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.15);
    padding: 20px;
    display: none;
    z-index: 1002;
    overflow-y: auto;
    overflow-x: hidden;
}

.universal-a11y-panel.active {
    display: block;
    animation: universalSlideUp 0.3s ease;
}

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

/* Заголовок панели */
.universal-a11y-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
    padding-bottom: 12px;
    border-bottom: 1px solid #e5e7eb;
    position: sticky;
    top: 0;
    background: white;
    z-index: 1;
}

.universal-a11y-title {
    font-size: 18px;
    font-weight: 600;
    color: #0f766e;
    margin: 0;
}

.universal-a11y-close {
    background: none;
    border: none;
    color: #6b7280;
    cursor: pointer;
    padding: 4px;
    border-radius: 4px;
    transition: background-color 0.2s;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.universal-a11y-close:hover {
    background-color: #f3f4f6;
}

/* Категории настроек */
.universal-a11y-category {
    margin-bottom: 15px;
}

.universal-a11y-category-title {
    font-size: 14px;
    font-weight: 600;
    color: #374151;
    margin-bottom: 10px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.universal-a11y-category-title i {
    width: 16px;
    height: 16px;
}

/* Контролы */
.universal-a11y-controls {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.universal-a11y-btn {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 14px;
    background: #f9fafb;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
    font-size: 14px;
    color: #374151;
    text-align: left;
    width: 100%;
    border-left: 4px solid transparent;
}

.universal-a11y-btn:hover {
    background: #f3f4f6;
    border-color: #d1d5db;
    border-left-color: #0d9488;
}

.universal-a11y-btn.active {
    background: #d1fae5 !important;
    border-color: #10b981 !important;
    color: #065f46 !important;
    border-left-color: #065f46 !important;
}

.universal-a11y-btn i {
    width: 18px;
    height: 18px;
    flex-shrink: 0;
}

/* Слайдеры */
.universal-a11y-slider {
    padding: 10px 0;
}

.universal-a11y-slider label {
    display: block;
    font-size: 14px;
    color: #374151;
    margin-bottom: 8px;
}

.universal-a11y-range {
    width: 100%;
    height: 6px;
    -webkit-appearance: none;
    appearance: none;
    background: #e5e7eb;
    border-radius: 3px;
    outline: none;
}

.universal-a11y-range::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: #0d9488;
    cursor: pointer;
    border: 2px solid white;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.universal-a11y-range::-moz-range-thumb {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: #0d9488;
    cursor: pointer;
    border: 2px solid white;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

/* ===== СТИЛИ РЕЖИМОВ ДОСТУПНОСТИ ===== */

/* Высокая контрастность */
.universal-high-contrast {
    background: #000 !important;
    color: #fff !important;
}

.universal-high-contrast * {
    background-color: #000 !important;
    color: #fff !important;
    border-color: #fff !important;
}

.universal-high-contrast a {
    color: #ffff00 !important;
    text-decoration: underline !important;
}

.universal-high-contrast button,
.universal-high-contrast .universal-a11y-btn {
    background: #000 !important;
    color: #fff !important;
    border: 2px solid #fff !important;
}

/* Тёмная тема */
.universal-dark-theme {
    background: #1f2937 !important;
    color: #f9fafb !important;
}

.universal-dark-theme * {
    background-color: #1f2937 !important;
    color: #f9fafb !important;
}

.universal-dark-theme a {
    color: #93c5fd !important;
}

/* Инверсия цветов */
.universal-inverted-theme {
    filter: invert(1) hue-rotate(180deg) !important;
}

.universal-inverted-theme img,
.universal-inverted-theme video,
.universal-inverted-theme iframe {
    filter: invert(1) hue-rotate(180deg) !important;
}

/* Оттенки серого */
.universal-grayscale-theme {
    filter: grayscale(1) !important;
}

.universal-grayscale-theme img,
.universal-grayscale-theme video,
.universal-grayscale-theme iframe {
    filter: grayscale(1) !important;
}

/* Увеличенный курсор */
.universal-big-cursor * {
    cursor: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="32" height="32" viewBox="0 0 32 32"><circle cx="16" cy="16" r="14" fill="%230d9488" opacity="0.7"/><circle cx="16" cy="16" r="8" fill="white"/></svg>') 16 16, pointer !important;
}

/* Увеличенный текст */
.universal-large-text {
    font-size: 120% !important;
}

.universal-very-large-text {
    font-size: 150% !important;
}

.universal-very-large-text * {
    font-size: inherit !important;
}

/* Простой режим */
.universal-simple-mode * {
    animation: none !important;
    transition: none !important;
    background-image: none !important;
    box-shadow: none !important;
    text-shadow: none !important;
}

/* Подсветка фокуса */
.universal-highlight-focus :focus {
    outline: 3px solid #f59e0b !important;
    outline-offset: 2px !important;
}

/* Подсветка ссылок */
.universal-highlight-links a {
    background: #fffbeb !important;
    padding: 2px 4px !important;
    border-radius: 4px !important;
    border: 1px solid #f59e0b !important;
}

/* Режим чтения */
.universal-reading-mode {
    max-width: 800px !important;
    margin: 0 auto !important;
    background: #fef3c7 !important;
    color: #000 !important;
    padding: 20px !important;
}

.universal-reading-mode * {
    font-family: 'Georgia', serif !important;
    line-height: 1.8 !important;
}

/* Тултипы */
.universal-a11y-tooltip {
    position: fixed;
    background: rgba(0, 0, 0, 0.8);
    color: white;
    padding: 8px 12px;
    border-radius: 6px;
    font-size: 14px;
    z-index: 10000;
    pointer-events: none;
    max-width: 300px;
    display: none;
}

.universal-a11y-tooltip.active {
    display: block;
    animation: universalFadeIn 0.2s ease;
}

@keyframes universalFadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

/* ===== АДАПТИВНОСТЬ ===== */

@media (max-width: 768px) {
    .universal-a11y-widget {
        bottom: 90px;
        right: 25px;
    }
    
    .universal-a11y-toggle-btn {
        width: 50px;
        height: 50px;
        font-size: 20px;
    }
    
    .universal-a11y-panel {
        width: 280px;
        max-height: 55vh;
        right: -20px;
        bottom: 60px;
        padding: 16px;
    }
    
    .universal-a11y-btn {
        padding: 12px 14px;
        min-height: 48px;
        font-size: 14px;
    }
    
    .universal-a11y-btn i {
        width: 20px;
        height: 20px;
    }
    
    .universal-a11y-category-title {
        font-size: 14px;
    }
}

@media (max-width: 480px) {
    .universal-a11y-widget {
        bottom: 90px;
        right: 25px;
    }
    
    .universal-a11y-panel {
        width: calc(100vw - 32px);
        max-height: 50vh;
        right: 16px;
        left: 16px;
        bottom: 65px;
        margin: 0 auto;
    }
}

/* ===== ИСПРАВЛЕНИЯ ДЛЯ IPHONE ===== */

/* Для очень маленьких экранов (iPhone) */
@media (max-width: 480px) and (max-height: 900px) {
    .universal-a11y-panel {
        width: 95vw;
        max-width: 95vw;
        max-height: 70vh;
        right: 2.5vw;
        left: 2.5vw;
        bottom: 70px;
        padding: 15px;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch; /* Плавный скролл на iOS */
    }
    
    .universal-a11y-widget {
        bottom: 90px;
        right: 25px;
    }
}

/* Для iPhone с "чёлкой" (notch) */
@supports (padding: max(0px)) {
    .universal-a11y-widget {
        bottom: max(90px, env(safe-area-inset-bottom) + 10px);
        right: max(25px, env(safe-area-inset-right) + 10px);
    }
}

/* Исправление для Safari на iOS */
@supports (-webkit-touch-callout: none) {
    .universal-a11y-panel {
        position: fixed;
        transform: translateX(-50%) translateZ(0); /* Аппаратное ускорение */
        -webkit-transform: translateX(-50%) translateZ(0);
    }
    
    .universal-a11y-btn {
        -webkit-tap-highlight-color: rgba(0, 0, 0, 0.1); /* Убрать синее подсвечивание */
    }
}

/* Экстренное исправление для меню на iOS */
@media (max-width: 430px) {
    .universal-a11y-panel {
        transform: none !important;
        left: 10px !important;
        right: 10px !important;
        width: calc(100vw - 20px) !important;
        max-height: 60vh !important;
        overflow-y: auto !important;
    }
    
    .universal-a11y-widget {
        bottom: 90px !important;
        right: 25px !important;
        z-index: 10010 !important;
    }
}

/* Предотвращаем выезд за экран */
.universal-a11y-panel {
    overscroll-behavior: contain; /* Предотвращает скролл родителя */
    -webkit-overflow-scrolling: touch;
}

/* Фикс для кнопки закрытия на iOS */
.universal-a11y-close {
    padding: 8px !important;
    width: 44px !important; /* Минимальный размер для iOS */
    height: 44px !important;
}

/* Класс для iOS устройств */
body.ios-device .universal-a11y-panel {
    position: fixed !important;
    bottom: 80px !important;
    left: 10px !important;
    right: 10px !important;
    width: calc(100vw - 20px) !important;
    max-height: 60vh !important;
}