/* ===================================================
   MAXSUS IMKONIYATLAR (Accessibility) Widget
   =================================================== */

/* --- Floating Button (HIDDEN - now in navigation) --- */
#acc-btn {
    display: none !important;
}

/* --- Navigation Accessibility Button --- */
#acc-btn-nav {
    background: none;
    border: none;
    cursor: pointer;
    font-family: inherit;
}

.nav-btn-accessibility {
    background: linear-gradient(135deg, #7c4dff, #651fff) !important;
    border: 2px solid rgba(255, 255, 255, 0.2) !important;
}

.nav-btn-accessibility:hover {
    background: linear-gradient(135deg, #651fff, #5e35b1) !important;
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(124, 77, 255, 0.4);
}

/* --- Panel Overlay --- */
#acc-overlay {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 9998;
    background: rgba(0, 0, 0, 0.22);
}

#acc-overlay.open {
    display: block;
}

/* --- Panel --- */
#acc-panel {
    position: fixed;
    top: 0;
    right: -380px;
    width: 340px;
    height: 100vh;
    z-index: 9999;
    background: #fff;
    box-shadow: -4px 0 32px rgba(0, 0, 0, 0.18);
    display: flex;
    flex-direction: column;
    transition: right 0.32s cubic-bezier(.4, 0, .2, 1);
    overflow-y: auto;
    font-family: 'Segoe UI', Arial, sans-serif;
}

#acc-panel.open {
    right: 0;
}

#acc-panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 22px 20px 16px;
    border-bottom: 1px solid #eee;
}

#acc-panel-header h2 {
    font-size: 18px;
    font-weight: 700;
    color: #1a1a2e;
    margin: 0;
}

#acc-close {
    background: none;
    border: none;
    font-size: 22px;
    cursor: pointer;
    color: #555;
    line-height: 1;
    padding: 0 4px;
}

#acc-close:hover {
    color: #e53935;
}

#acc-panel-body {
    padding: 18px 20px 30px;
}

.acc-section {
    margin-bottom: 22px;
}

.acc-section-title {
    font-size: 12px;
    font-weight: 700;
    color: #888;
    text-transform: uppercase;
    letter-spacing: 0.07em;
    margin-bottom: 10px;
}

/* --- Voice Selector --- */
.acc-voice-selector {
    margin-bottom: 8px;
}

.acc-select {
    width: 100%;
    padding: 10px 12px;
    border: 1.5px solid #d0d0d0;
    border-radius: 10px;
    background: #fafafa;
    font-size: 14px;
    color: #333;
    cursor: pointer;
    transition: border-color 0.2s, background 0.2s;
    font-family: 'Segoe UI', Arial, sans-serif;
}

.acc-select:hover {
    border-color: #1a73e8;
    background: #fff;
}

.acc-select:focus {
    outline: none;
    border-color: #1a73e8;
    background: #fff;
    box-shadow: 0 0 0 3px rgba(26, 115, 232, 0.1);
}

/* --- Theme Cards --- */
.acc-themes {
    display: flex;
    gap: 10px;
}

.acc-theme-card {
    flex: 1;
    border: 2px solid #e0e0e0;
    border-radius: 12px;
    padding: 8px 6px 6px;
    text-align: center;
    cursor: pointer;
    background: #f7f7f7;
    transition: border-color 0.2s, background 0.2s;
    font-size: 12px;
    color: #444;
}

.acc-theme-card:hover {
    border-color: #1a73e8;
}

.acc-theme-card.active {
    border-color: #1a73e8;
    background: #e8f0fe;
    color: #1a73e8;
    font-weight: 700;
}

.acc-theme-card .theme-preview {
    width: 100%;
    height: 38px;
    border-radius: 7px;
    margin-bottom: 5px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
}

.theme-preview-light {
    background: #f0f4ff;
    border: 1px solid #c5cff5;
}

.theme-preview-dark {
    background: #23233a;
    border: 1px solid #3b3b5c;
}

.theme-preview-night {
    background: #0a0a15;
    border: 1px solid #2a2a40;
}

.theme-preview-bar {
    width: 18px;
    height: 6px;
    border-radius: 3px;
}

/* --- Font Size --- */
.acc-font-row {
    display: flex;
    align-items: center;
    gap: 10px;
}

.acc-font-row .a-small {
    font-size: 13px;
    color: #888;
    font-weight: 700;
}

.acc-font-row .a-large {
    font-size: 20px;
    color: #555;
    font-weight: 700;
}

.acc-font-row input[type=range] {
    flex: 1;
    accent-color: #1a73e8;
    height: 4px;
}

.acc-font-label {
    text-align: center;
    font-size: 12px;
    color: #888;
    margin-top: 4px;
}

/* --- Action Buttons --- */
.acc-btn-row {
    display: flex;
    gap: 10px;
    margin-bottom: 10px;
}

.acc-action-btn {
    flex: 1;
    padding: 10px 8px;
    border: 1.5px solid #d0d0d0;
    border-radius: 10px;
    background: #fafafa;
    font-size: 13px;
    color: #333;
    cursor: pointer;
    transition: border-color 0.2s, background 0.2s, color 0.2s;
    text-align: center;
    font-weight: 500;
}

.acc-action-btn:hover {
    border-color: #1a73e8;
    color: #1a73e8;
}

.acc-action-btn.active {
    border-color: #1a73e8;
    background: #e8f0fe;
    color: #1a73e8;
}

/* --- Toggle --- */
.acc-toggle-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 0;
    border-bottom: 1px solid #f0f0f0;
}

.acc-toggle-info {
    font-size: 14px;
    color: #222;
    font-weight: 600;
}

.acc-toggle-desc {
    font-size: 11px;
    color: #999;
    margin-top: 2px;
}

.acc-toggle-hint {
    font-size: 11px;
    color: #aaa;
    margin-top: 6px;
}

.acc-toggle-hint code {
    background: #f0f0f0;
    padding: 1px 4px;
    border-radius: 4px;
    font-size: 10px;
}

.acc-switch {
    position: relative;
    display: inline-block;
    width: 44px;
    height: 24px;
    flex-shrink: 0;
}

.acc-switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.acc-switch-slider {
    position: absolute;
    inset: 0;
    background: #ccc;
    border-radius: 24px;
    cursor: pointer;
    transition: 0.3s;
}

.acc-switch-slider:before {
    content: '';
    position: absolute;
    width: 18px;
    height: 18px;
    left: 3px;
    bottom: 3px;
    background: #fff;
    border-radius: 50%;
    transition: 0.3s;
}

.acc-switch input:checked+.acc-switch-slider {
    background: #1a73e8;
}

.acc-switch input:checked+.acc-switch-slider:before {
    transform: translateX(20px);
}

/* --- TTS Selection Icon (Always Active) --- */
#acc-tts-icon {
    position: fixed;
    z-index: 99999;
    background: linear-gradient(135deg, #1a73e8, #1558b0);
    color: #fff;
    border-radius: 50%;
    width: 48px;
    height: 48px;
    display: none;
    align-items: center;
    justify-content: center;
    font-size: 22px;
    box-shadow: 0 4px 20px rgba(26, 115, 232, 0.6), 0 0 0 4px rgba(26, 115, 232, 0.1);
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    pointer-events: auto;
    border: 3px solid rgba(255, 255, 255, 0.3);
}

#acc-tts-icon.show {
    display: flex;
    animation: ttsIconFadeIn 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

#acc-tts-icon:hover {
    background: linear-gradient(135deg, #1558b0, #0d47a1);
    transform: scale(1.15);
    box-shadow: 0 6px 28px rgba(26, 115, 232, 0.8), 0 0 0 6px rgba(26, 115, 232, 0.15);
}

#acc-tts-icon:active {
    transform: scale(1.05);
    box-shadow: 0 2px 12px rgba(26, 115, 232, 0.5);
}

@keyframes ttsIconFadeIn {
    from {
        opacity: 0;
        transform: scale(0.5) translateY(10px);
    }
    to {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

/* TTS Loading Spinner */
.tts-spinner {
    width: 24px;
    height: 24px;
    border: 3px solid rgba(255, 255, 255, 0.3);
    border-top-color: #fff;
    border-radius: 50%;
    animation: ttsSpinnerRotate 0.8s linear infinite;
}

@keyframes ttsSpinnerRotate {
    to { transform: rotate(360deg); }
}

/* Pulse animation for icon */
#acc-tts-icon::before {
    content: '';
    position: absolute;
    inset: -8px;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(26, 115, 232, 0.3) 0%, transparent 70%);
    animation: ttsPulse 2s ease-in-out infinite;
    z-index: -1;
}

@keyframes ttsPulse {
    0%, 100% {
        transform: scale(1);
        opacity: 0.5;
    }
    50% {
        transform: scale(1.2);
        opacity: 0;
    }
}

/* --- Reader Hover Mode Highlight --- */
.acc-tts-hover-active {
    box-shadow: inset 0 -2px 0 0 rgba(26, 115, 232, 0.6) !important;
    outline: 2px solid rgba(26, 115, 232, 0.3) !important;
    outline-offset: 2px;
    border-radius: 3px;
    transition: all 0.2s;
    position: relative;
}

.acc-tts-hover-active::before {
    content: '';
    position: absolute;
    inset: 0;
    background: rgba(26, 115, 232, 0.08);
    border-radius: 3px;
    pointer-events: none;
    z-index: -1;
}

/* --- Reset --- */
#acc-reset {
    width: 100%;
    padding: 11px;
    border: none;
    border-radius: 10px;
    background: #f0f0f0;
    color: #555;
    font-size: 14px;
    cursor: pointer;
    margin-top: 8px;
    transition: background 0.2s;
}

#acc-reset:hover {
    background: #e0e0e0;
}

/* --- Developer Credit --- */
.acc-developer {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 16px 12px 8px;
    margin-top: 20px;
    border-top: 1px solid #e8e8e8;
    font-size: 12px;
    color: #888;
}

.acc-dev-icon {
    font-size: 16px;
    animation: devIconPulse 2s ease-in-out infinite;
}

@keyframes devIconPulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.1); }
}

.acc-dev-text {
    line-height: 1.4;
}

.acc-dev-text strong {
    color: #1a73e8;
    font-weight: 600;
}


/* ===================================================
   DARK THEME — Full Coverage
   =================================================== */
body.acc-theme-dark {
    background: #0f0f1a !important;
    color: #e0e0f0 !important;
}

body.acc-theme-dark * {
    color: inherit;
}

/* Kill gradient background layers */
body.acc-theme-dark::before {
    background: #0f0f1a !important;
}

body.acc-theme-dark::after {
    opacity: 0 !important;
}

/* Background shapes */
body.acc-theme-dark .geometric-background,
body.acc-theme-dark .shape {
    opacity: 0.05 !important;
    filter: brightness(0.2) !important;
}

/* Header */
body.acc-theme-dark .main-header {
    background: #12122a !important;
    border-bottom-color: #2a2a4a !important;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.5) !important;
}

body.acc-theme-dark .main-header h1,
body.acc-theme-dark .main-header h1 * {
    background: linear-gradient(135deg, #90caf9, #ce93d8) !important;
    -webkit-background-clip: text !important;
    background-clip: text !important;
    -webkit-text-fill-color: transparent !important;
    color: transparent !important;
}

body.acc-theme-dark .nav-btn {
    background: #1e1e38 !important;
    color: #c0c0d8 !important;
    border-color: #3a3a5a !important;
}

body.acc-theme-dark .nav-btn:hover {
    background: #2a2a50 !important;
    color: #fff !important;
}

/* Main content */
body.acc-theme-dark .main-content {
    background: transparent !important;
}

/* Page title */
body.acc-theme-dark .page-title,
body.acc-theme-dark .page-title * {
    background: linear-gradient(135deg, #90caf9, #ce93d8) !important;
    -webkit-background-clip: text !important;
    background-clip: text !important;
    -webkit-text-fill-color: transparent !important;
    color: transparent !important;
}

/* Site cards */
body.acc-theme-dark .site-card {
    background: #1a1a30 !important;
    border-color: #2e2e50 !important;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.4) !important;
}

body.acc-theme-dark .site-card:hover {
    background: #22223a !important;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.5) !important;
}

body.acc-theme-dark .site-card-title,
body.acc-theme-dark .site-card-title * {
    color: #e8e8f8 !important;
}

body.acc-theme-dark .site-card-description,
body.acc-theme-dark .site-card-description * {
    color: #b0b0d0 !important;
}

body.acc-theme-dark .site-card-image,
body.acc-theme-dark .site-card-video {
    background: #12122a !important;
}

/* Empty state */
body.acc-theme-dark .empty-state {
    background: #1a1a30 !important;
    color: #9090b0 !important;
    border-color: #2e2e50 !important;
}

/* Footer */
body.acc-theme-dark .main-footer {
    background: #0a0a1a !important;
    color: #6060a0 !important;
    border-top-color: #2a2a4a !important;
}

body.acc-theme-dark .developer-credit {
    color: #7070b0 !important;
}

body.acc-theme-dark .developer-credit strong {
    background: linear-gradient(135deg, #90caf9, #ce93d8) !important;
    -webkit-background-clip: text !important;
    -webkit-text-fill-color: transparent !important;
    background-clip: text !important;
}

/* Admin containers */
body.acc-theme-dark .admin-container,
body.acc-theme-dark .admin-table,
body.acc-theme-dark .login-card,
body.acc-theme-dark .form-group input,
body.acc-theme-dark .form-group select,
body.acc-theme-dark .form-group textarea {
    background: #1a1a30 !important;
    color: #d0d0e0 !important;
    border-color: #2e2e50 !important;
}

/* ===================================================
   NIGHT (YELLOW) THEME
   =================================================== */
body.acc-theme-night {
    background: #050508 !important;
    color: #ffd700 !important;
}

body.acc-theme-night * {
    color: inherit;
}

body.acc-theme-night::before {
    background: #050508 !important;
}

body.acc-theme-night::after {
    opacity: 0 !important;
}

body.acc-theme-night .geometric-background,
body.acc-theme-night .shape {
    opacity: 0 !important;
}

body.acc-theme-night .main-header {
    background: #0a0a0d !important;
    border-bottom-color: #3a3000 !important;
}

body.acc-theme-night .main-header h1,
body.acc-theme-night .main-header h1 * {
    background: linear-gradient(135deg, #ffd700, #ffed4e) !important;
    -webkit-background-clip: text !important;
    background-clip: text !important;
    -webkit-text-fill-color: transparent !important;
    color: transparent !important;
}

body.acc-theme-night .nav-btn {
    background: #111108 !important;
    color: #ffd700 !important;
    border-color: #3a3000 !important;
}

body.acc-theme-night .page-title,
body.acc-theme-night .page-title * {
    background: linear-gradient(135deg, #ffd700, #ffed4e) !important;
    -webkit-background-clip: text !important;
    background-clip: text !important;
    -webkit-text-fill-color: transparent !important;
    color: transparent !important;
}

body.acc-theme-night .site-card {
    background: #0d0d08 !important;
    border-color: #3a3000 !important;
}

body.acc-theme-night .site-card-title,
body.acc-theme-night .site-card-title * {
    color: #ffe566 !important;
}

body.acc-theme-night .site-card-description,
body.acc-theme-night .site-card-description * {
    color: #c8a800 !important;
}

body.acc-theme-night .site-card-image,
body.acc-theme-night .site-card-video {
    background: #060603 !important;
}

body.acc-theme-night .main-footer {
    background: #030303 !important;
    color: #7a6b00 !important;
    border-top-color: #3a3000 !important;
}

body.acc-theme-night .developer-credit {
    color: #9a8b00 !important;
}

body.acc-theme-night .developer-credit strong {
    background: linear-gradient(135deg, #ffd700, #ffed4e) !important;
    -webkit-background-clip: text !important;
    -webkit-text-fill-color: transparent !important;
    background-clip: text !important;
}

/* ===================================================
   PANEL DARK MODE (auto when dark theme)
   =================================================== */
body.acc-theme-dark #acc-panel,
body.acc-theme-night #acc-panel {
    background: #1e1e30 !important;
    color: #d0d0e0 !important;
}

body.acc-theme-dark #acc-panel-header,
body.acc-theme-night #acc-panel-header {
    border-color: #2e2e50 !important;
}

body.acc-theme-dark #acc-panel-header h2,
body.acc-theme-night #acc-panel-header h2 {
    color: #e0e0f0 !important;
}

body.acc-theme-dark .acc-section-title,
body.acc-theme-night .acc-section-title {
    color: #8080a0 !important;
}

body.acc-theme-dark .acc-theme-card,
body.acc-theme-night .acc-theme-card {
    background: #2a2a40 !important;
    color: #b0b0d0 !important;
    border-color: #3a3a5a !important;
}

body.acc-theme-dark .acc-theme-card.active,
body.acc-theme-night .acc-theme-card.active {
    background: #1a3a6e !important;
    color: #90caf9 !important;
    border-color: #1a73e8 !important;
}

body.acc-theme-dark .acc-action-btn,
body.acc-theme-night .acc-action-btn {
    background: #2a2a40 !important;
    color: #b0b0d0 !important;
    border-color: #3a3a5a !important;
}

body.acc-theme-dark .acc-action-btn.active,
body.acc-theme-night .acc-action-btn.active {
    background: #1a3a6e !important;
    color: #90caf9 !important;
    border-color: #1a73e8 !important;
}

body.acc-theme-dark .acc-toggle-row,
body.acc-theme-night .acc-toggle-row {
    border-color: #2e2e50 !important;
}

body.acc-theme-dark .acc-toggle-info,
body.acc-theme-night .acc-toggle-info {
    color: #d0d0e0 !important;
}

body.acc-theme-dark #acc-reset,
body.acc-theme-night #acc-reset {
    background: #2a2a40 !important;
    color: #9090b0 !important;
}

body.acc-theme-dark .acc-toggle-hint code,
body.acc-theme-night .acc-toggle-hint code {
    background: #2a2a40 !important;
    color: #9090b0 !important;
}

body.acc-theme-dark .acc-select,
body.acc-theme-night .acc-select {
    background: #2a2a40 !important;
    color: #d0d0e0 !important;
    border-color: #3a3a5a !important;
}

body.acc-theme-dark .acc-select:hover,
body.acc-theme-dark .acc-select:focus,
body.acc-theme-night .acc-select:hover,
body.acc-theme-night .acc-select:focus {
    background: #323250 !important;
    border-color: #1a73e8 !important;
}

body.acc-theme-dark #acc-close,
body.acc-theme-night #acc-close {
    color: #9090b0 !important;
}

body.acc-theme-dark .acc-developer,
body.acc-theme-night .acc-developer {
    border-top-color: #2e2e50 !important;
    color: #8080a0 !important;
}

body.acc-theme-dark .acc-dev-text strong,
body.acc-theme-night .acc-dev-text strong {
    color: #90caf9 !important;
}

/* ===================================================
   FOCUS MODE
   =================================================== */
body.acc-focus-mode .site-card:not(:hover),
body.acc-focus-mode nav a:not(:hover),
body.acc-focus-mode button:not(:hover) {
    opacity: 0.35;
}

/* Отмена затемнения карточек при hover (всегда яркие) */
.site-grid:hover .site-card:not(:hover) {
    opacity: 1 !important;
    filter: none !important;
}

.site-card {
    opacity: 1 !important;
}

/* ===================================================
   LETTER / WORD SPACING
   =================================================== */
body.acc-letter-wide * {
    letter-spacing: 0.08em;
}

body.acc-word-wide * {
    word-spacing: 0.18em;
}