/**
 * Refualaam Accessibility Widget
 * Custom accessibility solution - Similar to UserWay
 * Created: 10/01/2026
 * Features: Text size, contrast, spacing, grayscale, links highlight, readable font, animations pause, reading guide
 */

/* ===== FLOATING BUTTON ===== */
.acc-widget-btn {
    position: fixed;
    bottom: 20px;
    left: 20px;
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: linear-gradient(135deg, #0066cc 0%, #004499 100%);
    border: none;
    cursor: pointer;
    box-shadow: 0 4px 15px rgba(0, 102, 204, 0.4);
    z-index: 999999;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
}

.acc-widget-btn:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 20px rgba(0, 102, 204, 0.5);
}

.acc-widget-btn:focus {
    outline: 3px solid #ffcc00;
    outline-offset: 2px;
}

.acc-widget-btn svg {
    width: 32px;
    height: 32px;
    fill: white;
}

.acc-widget-btn.active {
    background: linear-gradient(135deg, #cc0000 0%, #990000 100%);
}

/* ===== PANEL ===== */
.acc-widget-panel {
    position: fixed;
    bottom: 90px;
    left: 20px;
    width: 320px;
    max-height: 80vh;
    background: #ffffff;
    border-radius: 16px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
    z-index: 999998;
    opacity: 0;
    visibility: hidden;
    transform: translateY(20px) scale(0.95);
    transition: all 0.3s ease;
    overflow: hidden;
    direction: rtl;
    /* Flexbox layout to ensure footer is always visible */
    display: flex;
    flex-direction: column;
}

.acc-widget-panel.open {
    opacity: 1;
    visibility: visible;
    transform: translateY(0) scale(1);
}

/* Panel Header */
.acc-panel-header {
    background: linear-gradient(135deg, #0066cc 0%, #004499 100%);
    color: white;
    padding: 16px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.acc-panel-header h3 {
    margin: 0;
    font-size: 18px;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 10px;
}

.acc-panel-header h3 svg {
    width: 24px;
    height: 24px;
    fill: white;
}

.acc-panel-close {
    background: rgba(255, 255, 255, 0.2);
    border: none;
    color: white;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
}

.acc-panel-close:hover {
    background: rgba(255, 255, 255, 0.3);
}

/* Panel Content */
.acc-panel-content {
    padding: 16px;
    flex: 1;
    overflow-y: auto;
    min-height: 0; /* Important for flexbox scroll */
}

/* Option Groups */
.acc-option-group {
    margin-bottom: 16px;
}

.acc-option-group-title {
    font-size: 12px;
    font-weight: 600;
    color: #666;
    text-transform: uppercase;
    margin-bottom: 8px;
    padding-right: 4px;
}

/* Option Buttons */
.acc-option {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 14px;
    background: #f5f7fa;
    border: 2px solid transparent;
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.2s ease;
    margin-bottom: 8px;
    width: 100%;
    text-align: right;
}

.acc-option:hover {
    background: #e8f0fe;
    border-color: #0066cc;
}

.acc-option.active {
    background: #e8f0fe;
    border-color: #0066cc;
}

.acc-option-icon {
    width: 40px;
    height: 40px;
    background: white;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.acc-option-icon svg {
    width: 22px;
    height: 22px;
    fill: #333;
}

.acc-option.active .acc-option-icon {
    background: #0066cc;
}

.acc-option.active .acc-option-icon svg {
    fill: white;
}

.acc-option-text {
    flex: 1;
}

.acc-option-title {
    font-size: 14px;
    font-weight: 600;
    color: #333;
    margin-bottom: 2px;
}

.acc-option-desc {
    font-size: 11px;
    color: #888;
}

/* Slider Options (Text Size, Spacing) */
.acc-slider-option {
    padding: 14px;
    background: #f5f7fa;
    border-radius: 10px;
    margin-bottom: 8px;
}

.acc-slider-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
}

.acc-slider-title {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 14px;
    font-weight: 600;
    color: #333;
}

.acc-slider-title svg {
    width: 20px;
    height: 20px;
    fill: #333;
}

.acc-slider-value {
    font-size: 14px;
    font-weight: 700;
    color: #0066cc;
    min-width: 45px;
    text-align: center;
}

.acc-slider-controls {
    display: flex;
    align-items: center;
    gap: 10px;
}

.acc-slider-btn {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border: 2px solid #ddd;
    background: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    font-weight: 700;
    color: #333;
    transition: all 0.2s;
}

.acc-slider-btn:hover {
    border-color: #0066cc;
    color: #0066cc;
}

.acc-slider-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.acc-slider-track {
    flex: 1;
    height: 6px;
    background: #ddd;
    border-radius: 3px;
    position: relative;
}

.acc-slider-fill {
    height: 100%;
    background: #0066cc;
    border-radius: 3px;
    transition: width 0.2s;
}

/* Reset Button */
.acc-reset-btn {
    width: 100%;
    padding: 14px;
    background: #f5f5f5;
    border: 2px solid #ddd;
    border-radius: 10px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 600;
    color: #666;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    transition: all 0.2s;
    margin-top: 8px;
}

.acc-reset-btn:hover {
    background: #ffebee;
    border-color: #cc0000;
    color: #cc0000;
}

.acc-reset-btn svg {
    width: 18px;
    height: 18px;
    fill: currentColor;
}

.acc-reset-icon {
    display: flex;
    align-items: center;
}

.acc-reset-text {
    text-align: center;
    line-height: 1.4;
}

.acc-reset-text small {
    font-size: 11px;
    font-weight: 400;
    color: #888;
    display: block;
}

/* Panel Footer */
.acc-panel-footer {
    padding: 12px 16px;
    background: #f9f9f9;
    border-top: 1px solid #eee;
    text-align: center;
    flex-shrink: 0; /* Never shrink - always visible */
}

.acc-panel-footer a {
    font-size: 12px;
    color: #0066cc;
    text-decoration: none;
}

.acc-panel-footer a:hover {
    text-decoration: underline;
}

/* ===== ACCESSIBILITY EFFECTS ===== */

/* Text Size Levels */
body.acc-text-1 { font-size: 110% !important; }
body.acc-text-2 { font-size: 120% !important; }
body.acc-text-3 { font-size: 130% !important; }
body.acc-text-4 { font-size: 140% !important; }

body.acc-text-1 *,
body.acc-text-2 *,
body.acc-text-3 *,
body.acc-text-4 * {
    font-size: inherit !important;
    line-height: 1.5 !important;
}

/* Exclude widget from text scaling */
body.acc-text-1 .acc-widget-panel,
body.acc-text-1 .acc-widget-panel *,
body.acc-text-2 .acc-widget-panel,
body.acc-text-2 .acc-widget-panel *,
body.acc-text-3 .acc-widget-panel,
body.acc-text-3 .acc-widget-panel *,
body.acc-text-4 .acc-widget-panel,
body.acc-text-4 .acc-widget-panel * {
    font-size: revert !important;
}

/* High Contrast */
body.acc-contrast-high {
    filter: contrast(1.4) !important;
}

/* Invert Colors */
body.acc-contrast-invert {
    filter: invert(1) hue-rotate(180deg) !important;
}

body.acc-contrast-invert img,
body.acc-contrast-invert video,
body.acc-contrast-invert iframe {
    filter: invert(1) hue-rotate(180deg) !important;
}

/* Dark Mode */
body.acc-contrast-dark {
    background-color: #1a1a1a !important;
    color: #e0e0e0 !important;
}

body.acc-contrast-dark * {
    background-color: inherit;
    color: inherit;
    border-color: #444 !important;
}

body.acc-contrast-dark a {
    color: #6db3f2 !important;
}

body.acc-contrast-dark .acc-widget-panel,
body.acc-contrast-dark .acc-widget-panel * {
    background-color: revert;
    color: revert;
}

/* Text Spacing */
body.acc-spacing-1 * { letter-spacing: 0.05em !important; word-spacing: 0.1em !important; }
body.acc-spacing-2 * { letter-spacing: 0.1em !important; word-spacing: 0.2em !important; }
body.acc-spacing-3 * { letter-spacing: 0.15em !important; word-spacing: 0.3em !important; }

/* Line Height */
body.acc-lineheight-1 * { line-height: 1.8 !important; }
body.acc-lineheight-2 * { line-height: 2.0 !important; }
body.acc-lineheight-3 * { line-height: 2.4 !important; }

/* Grayscale */
body.acc-grayscale {
    filter: grayscale(100%) !important;
}

/* Highlight Links */
body.acc-highlight-links a {
    background-color: #ffff00 !important;
    color: #000 !important;
    padding: 2px 4px !important;
    text-decoration: underline !important;
    outline: 2px solid #000 !important;
}

/* Readable Font (Dyslexia-friendly) */
body.acc-readable-font,
body.acc-readable-font * {
    font-family: Arial, Helvetica, sans-serif !important;
    letter-spacing: 0.03em !important;
}

/* Pause Animations */
body.acc-pause-animations *,
body.acc-pause-animations *::before,
body.acc-pause-animations *::after {
    animation-play-state: paused !important;
    transition: none !important;
}

/* Big Cursor */
body.acc-big-cursor,
body.acc-big-cursor * {
    cursor: url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" width="32" height="32" viewBox="0 0 32 32"><path fill="%23000" stroke="%23fff" stroke-width="1" d="M4 4l20 8-8 4-4 8z"/></svg>') 4 4, auto !important;
}

/* Reading Guide */
.acc-reading-guide {
    position: fixed;
    left: 0;
    right: 0;
    height: 40px;
    background: rgba(255, 255, 0, 0.3);
    border-top: 2px solid #ffcc00;
    border-bottom: 2px solid #ffcc00;
    pointer-events: none;
    z-index: 999990;
    display: none;
}

body.acc-reading-guide-active .acc-reading-guide {
    display: block;
}

/* ===== MOBILE RESPONSIVE ===== */
@media (max-width: 480px) {
    .acc-widget-btn {
        width: 48px;
        height: 48px;
        bottom: 15px;
        left: 15px;
    }

    .acc-widget-btn svg {
        width: 26px;
        height: 26px;
    }

    .acc-widget-panel {
        width: calc(100vw - 30px);
        left: 15px;
        right: 15px;
        bottom: 75px;
        max-height: 70vh;
    }
}

/* ===== PRINT HIDE ===== */
@media print {
    .acc-widget-btn,
    .acc-widget-panel,
    .acc-reading-guide {
        display: none !important;
    }
}

/* ===== REDUCED MOTION SUPPORT (WCAG 2.1) ===== */
@media (prefers-reduced-motion: reduce) {
    .acc-widget-btn,
    .acc-widget-panel,
    .acc-widget-panel * {
        transition: none !important;
        animation: none !important;
    }
}
