/* ============================================================
   ACCESSIBILITY PANEL CSS — v2.0
   O'zgarishlar:
     + Satr oralig'i tugmalari (.acc-line-control)
     + Rang ko'rlik tugmalari (.acc-cb-control)
     + SVG filter klasslari (deuteranopia, protanopia, mono)
     + TTS highlight (.acc-tts-highlight)
     + TTS hint (.acc-tts-hint)
     + Mobile CSS duplikatsiyasi tuzatildi
     + Dark mode yangilandi
   ============================================================ */

/* ── Toggle Button (o'ng tomondagi ♿ tugmasi) ── */
#accessibility-toggle {
    position: fixed;
    top: 50%;
    right: 0;
    transform: translateY(-50%);
    z-index: 999999;
    background: #005baa;
    color: #fff;
    border: none;
    border-radius: 8px 0 0 8px;
    width: 46px;
    height: 46px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 22px;
    box-shadow: -2px 0 10px rgba(0,0,0,0.22);
    transition: background 0.2s, width 0.2s;
}

#accessibility-toggle:hover,
#accessibility-toggle:focus {
    background: #003f7a;
    outline: 3px solid #ffdd00;
    outline-offset: 2px;
}

/* ── Panel ── */
#accessibility-panel {
    position: fixed;
    top: 50%;
    right: -320px;
    transform: translateY(-50%);
    z-index: 999998;
    width: 300px;
    background: #ffffff;
    border-radius: 12px 0 0 12px;
    box-shadow: -4px 0 30px rgba(0,0,0,0.18);
    transition: right 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    font-family: Arial, sans-serif;
    border: 2px solid #005baa;
    border-right: none;
}

#accessibility-panel.open {
    right: 0;
}

/* ── Header ── */
.acc-panel-header {
    background: #005baa;
    color: #fff;
    padding: 14px 16px;
    border-radius: 10px 0 0 0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}

.acc-panel-header h3 {
    margin: 0;
    font-size: 14px;
    font-weight: 700;
    letter-spacing: 0.3px;
}

.acc-panel-close {
    background: transparent;
    border: none;
    color: #fff;
    font-size: 20px;
    cursor: pointer;
    padding: 0 4px;
    line-height: 1;
    border-radius: 4px;
    flex-shrink: 0;
}

.acc-panel-close:hover,
.acc-panel-close:focus {
    background: rgba(255,255,255,0.2);
    outline: 2px solid #ffdd00;
}

/* ── Body ── */
.acc-panel-body {
    padding: 14px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    max-height: 72vh;
    overflow-y: auto;
    overflow-x: hidden;
}

/* ── Section Labels ── */
.acc-section-label {
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.9px;
    color: #888;
    margin: 4px 0 2px;
    padding-bottom: 4px;
    border-bottom: 1px solid #eee;
}

/* ── Sub labels ── */
.acc-sub-label {
    font-size: 12px;
    font-weight: 600;
    color: #555;
    white-space: nowrap;
}

/* ── Font Size Control ── */
.acc-font-control {
    display: flex;
    align-items: center;
    gap: 6px;
    background: #f5f7fa;
    border-radius: 8px;
    padding: 8px 10px;
}

.acc-font-control > span {
    flex: 1;
    font-size: 13px;
    color: #333;
    font-weight: 600;
}

.acc-font-btn {
    width: 32px;
    height: 32px;
    border-radius: 6px;
    border: 1.5px solid #005baa;
    background: #fff;
    color: #005baa;
    font-size: 17px;
    font-weight: 700;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s, color 0.15s;
    line-height: 1;
    flex-shrink: 0;
}

.acc-font-btn:hover,
.acc-font-btn:focus {
    background: #005baa;
    color: #fff;
    outline: 2px solid #ffdd00;
}

.acc-font-size-display {
    min-width: 38px;
    text-align: center;
    font-size: 13px;
    font-weight: 700;
    color: #005baa;
    background: #e8f0fb;
    border-radius: 4px;
    padding: 4px 5px;
}

/* ── Line Spacing Control ── */
.acc-line-control {
    display: flex;
    align-items: center;
    gap: 8px;
    background: #f5f7fa;
    border-radius: 8px;
    padding: 8px 10px;
}

.acc-line-btns {
    display: flex;
    gap: 4px;
    margin-left: auto;
}

.acc-line-btn {
    padding: 4px 8px;
    border-radius: 5px;
    border: 1.5px solid #ccd6e8;
    background: #fff;
    color: #555;
    font-size: 11px;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.15s;
    line-height: 1.4;
}

.acc-line-btn.active,
.acc-line-btn:hover,
.acc-line-btn:focus {
    background: #005baa;
    color: #fff;
    border-color: #005baa;
    outline: 2px solid #ffdd00;
    outline-offset: 1px;
}

/* ── Toggle Buttons (asosiy) ── */
.acc-toggle-btn {
    display: flex;
    align-items: center;
    gap: 9px;
    width: 100%;
    padding: 9px 12px;
    border-radius: 8px;
    border: 1.5px solid #dde3ef;
    background: #f5f7fa;
    color: #333;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    text-align: left;
}

.acc-toggle-btn .acc-icon {
    font-size: 16px;
    width: 22px;
    text-align: center;
    flex-shrink: 0;
}

.acc-toggle-btn .acc-status {
    margin-left: auto;
    font-size: 10px;
    font-weight: 700;
    padding: 2px 7px;
    border-radius: 20px;
    background: #e0e0e0;
    color: #666;
    transition: all 0.2s;
    white-space: nowrap;
}

.acc-toggle-btn.active {
    background: #e8f0fb;
    border-color: #005baa;
    color: #005baa;
}

.acc-toggle-btn.active .acc-status {
    background: #005baa;
    color: #fff;
}

.acc-toggle-btn:hover,
.acc-toggle-btn:focus {
    border-color: #005baa;
    outline: 2px solid #ffdd00;
    outline-offset: 1px;
}

/* ── Color Blindness Control ── */
.acc-cb-control {
    display: flex;
    align-items: center;
    gap: 8px;
    background: #f5f7fa;
    border-radius: 8px;
    padding: 8px 10px;
    flex-wrap: wrap;
}

.acc-cb-btns {
    display: flex;
    gap: 3px;
    margin-left: auto;
    flex-wrap: wrap;
    justify-content: flex-end;
}

.acc-cb-btn {
    padding: 3px 7px;
    border-radius: 5px;
    border: 1.5px solid #ccd6e8;
    background: #fff;
    color: #555;
    font-size: 10px;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.15s;
    line-height: 1.5;
}

.acc-cb-btn.active,
.acc-cb-btn:hover,
.acc-cb-btn:focus {
    background: #005baa;
    color: #fff;
    border-color: #005baa;
    outline: 2px solid #ffdd00;
    outline-offset: 1px;
}

/* ── TTS Hint ── */
.acc-tts-hint {
    display: none;
    align-items: center;
    gap: 6px;
    font-size: 11px;
    color: #005baa;
    background: #e8f4ff;
    border: 1px dashed #005baa;
    border-radius: 6px;
    padding: 7px 10px;
    font-weight: 600;
    animation: acc-pulse 2s ease-in-out infinite;
}

@keyframes acc-pulse {
    0%, 100% { opacity: 1; }
    50%       { opacity: 0.6; }
}

/* ── Reset Button ── */
.acc-reset-btn {
    width: 100%;
    padding: 9px;
    border-radius: 8px;
    border: 1.5px solid #cc0000;
    background: #fff5f5;
    color: #cc0000;
    font-size: 13px;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.2s;
    margin-top: 2px;
}

.acc-reset-btn:hover,
.acc-reset-btn:focus {
    background: #cc0000;
    color: #fff;
    outline: 2px solid #ffdd00;
}

/* ============================================================
   ACCESSIBILITY MODES — GLOBAL STYLES
   ============================================================ */

/* ── 1. Yuqori Kontrast ── */
body.acc-high-contrast {
    background: #000000 !important;
    color: #ffffff !important;
}

body.acc-high-contrast *:not(#accessibility-panel):not(#accessibility-panel *):not(#accessibility-toggle) {
    background-color: #000000 !important;
    color: #ffffff !important;
    border-color: #ffffff !important;
}

body.acc-high-contrast a,
body.acc-high-contrast a * {
    color: #ffdd00 !important;
    text-decoration: underline !important;
}

body.acc-high-contrast img {
    filter: contrast(1.2) brightness(0.9);
}

/* ── 2. Havolalarni Ta'kidlash ── */
body.acc-highlight-links a {
    outline: 2px solid #ff6600 !important;
    background: #fff3e0 !important;
    color: #c43000 !important;
    text-decoration: underline !important;
    padding: 0 2px;
    border-radius: 2px;
}

body.acc-high-contrast.acc-highlight-links a {
    outline: 2px solid #ffdd00 !important;
    background: #2a2000 !important;
    color: #ffdd00 !important;
}

/* ── 3. Animatsiyalarni O'chirish ── */
body.acc-no-animation *,
body.acc-no-animation *::before,
body.acc-no-animation *::after {
    animation: none !important;
    transition: none !important;
    scroll-behavior: auto !important;
}

/* ── 4. Rang Ko'rlik Filtrlari (SVG orqali) ── */
body.acc-deuteranopia {
    filter: url(#acc-f-deuter);
}

body.acc-protanopia {
    filter: url(#acc-f-protan);
}

body.acc-mono {
    filter: grayscale(100%);
}

/* Rang ko'rlik aktiv bo'lganda panel filter'dan mustasno bo'lsin
   (filter: none ishlamaydi — bu brauzer cheklov, panel biroz
   o'zgarishi normaldir va foydalanuvchi biladi) */

/* ── 5. Katta Kursor ── */
body.acc-big-cursor,
body.acc-big-cursor * {
    cursor: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='40' height='40' viewBox='0 0 40 40'%3E%3Cpolygon points='0,0 0,30 8,24 14,38 18,36 12,22 22,22' fill='black' stroke='white' stroke-width='2'/%3E%3C/svg%3E") 0 0, auto !important;
}

/* ── 6. Oqish Chizig'i ── */
body.acc-reading-guide::after {
    content: '';
    position: fixed;
    left: 0;
    width: 100%;
    height: 42px;
    background: rgba(0, 91, 170, 0.11);
    border-top: 2px solid rgba(0, 91, 170, 0.45);
    border-bottom: 2px solid rgba(0, 91, 170, 0.45);
    pointer-events: none;
    z-index: 999990;
    top: var(--reading-guide-y, 200px);
    transition: top 0.04s linear;
}

/* ── 7. Focus Ta'kidlash ── */
body.acc-focus-highlight *:focus {
    outline: 4px solid #ff6600 !important;
    outline-offset: 3px !important;
    box-shadow: 0 0 0 6px rgba(255, 102, 0, 0.25) !important;
}

/* ── 8. Satr Oralig'i ── */
body.acc-line-md p,
body.acc-line-md li,
body.acc-line-md td,
body.acc-line-md th,
body.acc-line-md label,
body.acc-line-md span,
body.acc-line-md div {
    line-height: 1.7 !important;
}

body.acc-line-lg p,
body.acc-line-lg li,
body.acc-line-lg td,
body.acc-line-lg th,
body.acc-line-lg label,
body.acc-line-lg span,
body.acc-line-lg div {
    line-height: 2.1 !important;
}

/* ── 9. TTS — O'qilayotgan element highlight ── */
.acc-tts-highlight {
    outline: 2px dashed #005baa !important;
    outline-offset: 3px !important;
    background: rgba(255, 240, 120, 0.45) !important;
    border-radius: 3px;
    transition: background 0.2s !important;
}

/* ============================================================
   DARK THEME COMPATIBILITY
   ============================================================ */
body.dark-theme #accessibility-panel {
    background: #1e1e2e;
    border-color: #4a9eff;
}

body.dark-theme .acc-font-control,
body.dark-theme .acc-line-control,
body.dark-theme .acc-cb-control,
body.dark-theme .acc-toggle-btn {
    background: #2a2a3e;
    border-color: #3a3a5e;
    color: #e0e0e0;
}

body.dark-theme .acc-section-label {
    color: #aaa;
    border-color: #3a3a5e;
}

body.dark-theme .acc-sub-label {
    color: #ccc;
}

body.dark-theme .acc-toggle-btn.active {
    background: #1a3a6e;
    border-color: #4a9eff;
    color: #4a9eff;
}

body.dark-theme .acc-line-btn,
body.dark-theme .acc-cb-btn {
    background: #2a2a3e;
    border-color: #3a3a5e;
    color: #ccc;
}

body.dark-theme .acc-font-size-display {
    background: #1a2a4e;
    color: #4a9eff;
}

body.dark-theme .acc-tts-hint {
    background: #0a1a2e;
    border-color: #4a9eff;
    color: #4a9eff;
}

/* ============================================================
   MOBILE
   ============================================================ */
@media (max-width: 600px) {
    #accessibility-panel {
        width: 260px;
        top: auto;
        bottom: 40px;
        transform: none;
    }

    #accessibility-panel.open {
        right: 0;
    }

    #accessibility-toggle {
        top: auto;
        bottom: 80px;
        transform: none;
        border-radius: 8px 0 0 8px;
    }

    .acc-panel-body {
        max-height: 60vh;
    }

    .acc-cb-btns {
        gap: 2px;
    }

    .acc-cb-btn {
        padding: 3px 5px;
        font-size: 9px;
    }
}

/* ============================================================
   PRINT
   ============================================================ */
@media print {
    #accessibility-panel,
    #accessibility-toggle,
    #acc-svg-filters {
        display: none !important;
    }
}
