/* Accessibility Widget Styles */
.accessibility-widget {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 2147483647;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', sans-serif;
}

.accessibility-toggle {
    width: 46px;
    height: 46px;
    background: #146ff8;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.25);
    transition: all 0.3s ease;
    border: none;
    color: white;
    position: relative;
}

.accessibility-toggle:hover {
    background: #0f5bc7;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

.accessibility-toggle svg {
    width: 28px;
    height: 28px;
    fill: white;
}

.accessibility-panel {
    position: fixed;
    bottom: 80px;
    right: 20px;
    background: #ffffff;
    border-radius: 12px;
    box-shadow: 0 4px 24px rgba(0, 0, 0, 0.15);
    width: 340px;
    max-height: 500px;
    display: none;
    flex-direction: column;
    overflow: hidden;
}

.accessibility-panel.active {
    display: flex;
    animation: slideIn 0.3s ease;
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.accessibility-header {
    background: #146ff8;
    color: white;
    padding: 16px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-shrink: 0;
}

.accessibility-title {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 16px;
    font-weight: 600;
    letter-spacing: 0.5px;
}

.accessibility-controls {
    display: flex;
    gap: 8px;
    align-items: center;
}

.accessibility-control-btn {
    width: 30px;
    height: 30px;
    border-radius: 6px;
    background: rgba(255, 255, 255, 0.15);
    border: none;
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    font-size: 16px;
}

.accessibility-control-btn svg {
    width: 16px;
    height: 16px;
    color: white;
    fill: white;
}

.accessibility-control-btn:hover {
    background: rgba(255, 255, 255, 0.25);
    transform: scale(1.05);
}

.accessibility-close {
    background: transparent;
    border: none;
    color: white;
    font-size: 20px;
    cursor: pointer;
    padding: 0;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.2s ease;
}

.accessibility-close:hover {
    transform: scale(1.1);
}

.accessibility-content {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    background: #ffffff;
}

.accessibility-section {
    margin-bottom: 24px;
}

.accessibility-section-title {
    font-size: 13px;
    font-weight: 700;
    color: #2c3e50;
    margin-bottom: 12px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.accessibility-options {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
}

.accessibility-option {
    background: #f8f9fb;
    border: 1px solid #e1e4e8;
    border-radius: 8px;
    padding: 10px;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    text-align: center;
    min-height: 70px;
    justify-content: center;
}

.accessibility-option:hover {
    background: #f0f3f7;
    border-color: #146ff8;
    transform: translateY(-1px);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.08);
}

.accessibility-option.active {
    background: #146ff8;
    border-color: #146ff8;
    color: white;
}

.accessibility-option.active .accessibility-option-label {
    color: white;
}

.accessibility-option-icon {
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
}

.accessibility-option-label {
    font-size: 11px;
    color: #4a5568;
    font-weight: 500;
    line-height: 1.2;
}

.accessibility-slider-container {
    background: white;
    border: 2px solid #e1e4e8;
    border-radius: 8px;
    padding: 12px;
    margin-bottom: 8px;
    transition: all 0.2s ease;
    cursor: pointer;
}

.accessibility-slider-container:hover {
    border-color: #146ff8;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.08);
}

.accessibility-slider-container.active {
    background: #146ff8;
    border-color: #146ff8;
}

.accessibility-slider-container.active .accessibility-slider-label,
.accessibility-slider-container.active .accessibility-slider-value {
    color: white;
}

.accessibility-slider-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
}

.accessibility-slider-label {
    font-size: 11px;
    color: #4a5568;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 6px;
}

.accessibility-slider-label .icon {
    font-size: 14px;
}

.accessibility-slider-value {
    font-size: 11px;
    color: #2c3e50;
    background: #f0f3f7;
    padding: 2px 8px;
    border-radius: 4px;
    font-weight: 600;
    min-width: 45px;
    text-align: center;
}

.accessibility-slider {
    width: 100%;
    height: 6px;
    border-radius: 3px;
    background: #e1e4e8;
    position: relative;
    cursor: pointer;
    margin-top: 8px;
}

.accessibility-slider-container.active .accessibility-slider {
    background: rgba(255, 255, 255, 0.3);
}

.accessibility-slider-track {
    height: 100%;
    background: #146ff8;
    border-radius: 3px;
    transition: width 0.2s ease;
    position: relative;
}

.accessibility-slider-container.active .accessibility-slider-track {
    background: white;
}

.accessibility-slider-steps {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 100%;
    display: flex;
    justify-content: space-between;
    padding: 0 2px;
}

.accessibility-slider-step {
    width: 2px;
    height: 100%;
    background: rgba(0, 0, 0, 0.1);
}

.accessibility-slider-container.active .accessibility-slider-step {
    background: rgba(255, 255, 255, 0.2);
}

.accessibility-slider-thumb {
    position: absolute;
    top: 50%;
    transform: translate(-50%, -50%);
    width: 18px;
    height: 18px;
    background: white;
    border: 3px solid #146ff8;
    border-radius: 50%;
    cursor: grab;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
    transition: all 0.2s ease;
}

.accessibility-slider-container.active .accessibility-slider-thumb {
    border-color: white;
    background: #146ff8;
}

.accessibility-slider-thumb:hover {
    transform: translate(-50%, -50%) scale(1.15);
}

.accessibility-slider-thumb:active {
    cursor: grabbing;
    transform: translate(-50%, -50%) scale(0.95);
}

/* Accessibility Effects - Using wrapper to prevent fixed position issues */
.accessibility-wrapper {
    /* Removed min-height to prevent layout issues */
}

body.high-contrast .accessibility-wrapper {
    filter: contrast(1.5) !important;
}

body.dark-contrast {
    background: #000 !important;
}

body.dark-contrast .accessibility-wrapper {
    filter: invert(1) hue-rotate(180deg) !important;
}

body.light-contrast {
    background: #fff !important;
}

body.light-contrast .accessibility-wrapper {
    filter: contrast(0.8) brightness(1.2) !important;
}

body.grayscale .accessibility-wrapper {
    filter: grayscale(1) !important;
}

/* Exclude widgets from filter effects */
.accessibility-widget,
.pwa-install-widget,
.back-to-top {
    position: fixed !important;
    z-index: 2147483647 !important;
}

body.high-contrast .accessibility-widget,
body.high-contrast .pwa-install-widget,
body.high-contrast .back-to-top,
body.dark-contrast .accessibility-widget,
body.dark-contrast .pwa-install-widget,
body.dark-contrast .back-to-top,
body.light-contrast .accessibility-widget,
body.light-contrast .pwa-install-widget,
body.light-contrast .back-to-top,
body.grayscale .accessibility-widget,
body.grayscale .pwa-install-widget,
body.grayscale .back-to-top {
    filter: none !important;
}

body.hide-images img,
body.hide-images video,
body.hide-images iframe {
    opacity: 0 !important;
    visibility: hidden !important;
}

body.stop-animations *,
body.stop-animations *::before,
body.stop-animations *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
}

body.highlight-links a {
    background: yellow !important;
    color: black !important;
    text-decoration: underline !important;
    padding: 2px 4px !important;
}

body.reading-mask .reading-line {
    position: fixed;
    left: 0;
    right: 0;
    height: 120px;
    background: transparent;
    box-shadow: 
        0 -9999px 0 9999px rgba(0, 0, 0, 0.5),
        0 9999px 0 9999px rgba(0, 0, 0, 0.5);
    pointer-events: none;
    z-index: 99998;
    transition: top 0.1s ease;
}

body.focus-outline *:focus {
    outline: 3px solid #ff6b00 !important;
    outline-offset: 2px !important;
}

body.page-structure * {
    border: 1px dashed rgba(0, 0, 0, 0.3) !important;
}

body.page-structure header {
    background: rgba(255, 0, 0, 0.1) !important;
}

body.page-structure nav {
    background: rgba(0, 255, 0, 0.1) !important;
}

body.page-structure main {
    background: rgba(0, 0, 255, 0.1) !important;
}

body.page-structure footer {
    background: rgba(255, 255, 0, 0.1) !important;
}

/* Text Size Adjustments */
body.text-size-small {
    font-size: 14px !important;
}

body.text-size-medium {
    font-size: 16px !important;
}

body.text-size-large {
    font-size: 20px !important;
}

body.text-size-xlarge {
    font-size: 24px !important;
}

/* Line Height Adjustments */
body.line-height-small * {
    line-height: 1.2 !important;
}

body.line-height-medium * {
    line-height: 1.5 !important;
}

body.line-height-large * {
    line-height: 1.8 !important;
}

body.line-height-xlarge * {
    line-height: 2.2 !important;
}

/* Text Alignment */
body.text-align-left * {
    text-align: left !important;
}

body.text-align-center * {
    text-align: center !important;
}

body.text-align-right * {
    text-align: right !important;
}

body.text-align-justify * {
    text-align: justify !important;
}

/* Readable Font */
body.readable-font * {
    font-family: 'OpenDyslexic', 'Comic Sans MS', sans-serif !important;
}

/* Mobile Responsive */
@media (max-width: 768px) {
    .accessibility-widget {
        right: 10px;
    }
    
    .accessibility-panel {
        right: 70px;
        width: calc(100vw - 100px);
        max-width: 320px;
    }
}

/* Page Structure View */
.page-structure-back {
    background: transparent;
    border: none;
    color: white;
    cursor: pointer;
    padding: 4px;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 6px;
    transition: background 0.2s ease;
}

.page-structure-back:hover {
    background: rgba(255, 255, 255, 0.15);
}

.page-structure-view {
    padding: 0 !important;
}

.page-structure-list {
    padding: 12px;
    overflow-y: auto;
    height: 100%;
}

.page-structure-item {
    display: flex;
    align-items: center;
    padding: 10px 12px;
    margin-bottom: 6px;
    background: white;
    border: 1px solid #e1e4e8;
    border-radius: 8px;
    text-decoration: none;
    color: #2c3e50;
    transition: all 0.2s ease;
    cursor: pointer;
}

.page-structure-item:hover {
    background: #f8f9fb;
    border-color: #146ff8;
    transform: translateX(2px);
}

.page-structure-icon {
    width: 28px;
    height: 28px;
    background: #146ff8;
    color: white;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    font-weight: bold;
    margin-right: 10px;
    flex-shrink: 0;
}

.page-structure-text {
    flex: 1;
    font-size: 13px;
    line-height: 1.3;
    color: #2c3e50;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.page-structure-empty {
    text-align: center;
    padding: 40px 20px;
    color: #6b7280;
    font-size: 13px;
}

/* Hide Options Modal */
.accessibility-hide-modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.6);
    z-index: 2147483649;
    display: none;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.accessibility-hide-modal.active {
    opacity: 1;
}

.hide-modal-content {
    width: 90%;
    max-width: 480px;
    background: white;
    border-radius: 16px;
    overflow: hidden;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    transform: scale(0.9);
    transition: transform 0.3s ease;
}

.accessibility-hide-modal.active .hide-modal-content {
    transform: scale(1);
}

.hide-modal-header {
    padding: 24px 24px 20px;
    text-align: center;
    border-bottom: 1px solid #e1e4e8;
}

.hide-modal-icon {
    width: 56px;
    height: 56px;
    margin: 0 auto 16px;
    background: #f0f7ff;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.hide-modal-title {
    font-size: 20px;
    font-weight: 600;
    color: #2c3e50;
    margin: 0 0 8px 0;
}

.hide-modal-description {
    font-size: 14px;
    color: #6b7280;
    line-height: 1.5;
    margin: 0;
}

.hide-modal-options {
    padding: 20px;
}

.hide-option {
    display: block;
    padding: 14px;
    margin-bottom: 12px;
    background: #f8f9fb;
    border: 2px solid #e1e4e8;
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.hide-option:hover {
    background: #f0f3f7;
    border-color: #146ff8;
}

.hide-option input[type="radio"] {
    position: absolute;
    opacity: 0;
}

.hide-option input[type="radio"]:checked + .hide-option-content {
    color: #146ff8;
}

.hide-option input[type="radio"]:checked ~ .hide-option-content::before {
    content: '✓';
    position: absolute;
    right: 16px;
    top: 50%;
    transform: translateY(-50%);
    color: #146ff8;
    font-weight: bold;
    font-size: 18px;
}

.hide-option-content {
    position: relative;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.hide-option-title {
    font-size: 14px;
    font-weight: 600;
    color: #2c3e50;
}

.hide-option-desc {
    font-size: 12px;
    color: #6b7280;
}

.hide-option input[type="radio"]:checked ~ .hide-option-content .hide-option-title {
    color: #146ff8;
}

.hide-modal-actions {
    padding: 20px;
    border-top: 1px solid #e1e4e8;
    display: flex;
    gap: 12px;
}

.hide-modal-cancel,
.hide-modal-confirm {
    flex: 1;
    padding: 12px 20px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    border: none;
}

.hide-modal-cancel {
    background: #f3f4f6;
    color: #4b5563;
}

.hide-modal-cancel:hover {
    background: #e5e7eb;
}

.hide-modal-confirm {
    background: #146ff8;
    color: white;
}

.hide-modal-confirm:hover {
    background: #0f5bc7;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(20, 111, 248, 0.3);
}

/* Notification Toast */
.accessibility-notification {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%) translateY(100px);
    background: #2c3e50;
    color: white;
    padding: 12px 24px;
    border-radius: 8px;
    font-size: 14px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
    z-index: 2147483650;
    opacity: 0;
    transition: all 0.3s ease;
}

.accessibility-notification.show {
    transform: translateX(-50%) translateY(0);
    opacity: 1;
}

/* Print Styles */
@media print {
    .accessibility-widget,
    .page-structure-modal,
    .accessibility-hide-modal {
        display: none !important;
    }
}

/* Custom Scrollbar for Panel */
.accessibility-panel::-webkit-scrollbar {
    width: 8px;
}

.accessibility-panel::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 4px;
}

.accessibility-panel::-webkit-scrollbar-thumb {
    background: #888;
    border-radius: 4px;
}

.accessibility-panel::-webkit-scrollbar-thumb:hover {
    background: #555;
}