/* ===================================================
   Al-Haseen Insurance - Accessibility & UX Tools
   Professional Accessibility Widget + Helper Tools
   =================================================== */

/* ---- CSS Variables ---- */
:root {
    --acc-primary: #1a56db;
    --acc-primary-hover: #1444b0;
    --acc-bg: #ffffff;
    --acc-text: #1f2937;
    --acc-border: #e5e7eb;
    --acc-shadow: 0 10px 40px rgba(0, 0, 0, 0.15);
    --acc-radius: 16px;
    --acc-transition: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ===================================================
   1. ACCESSIBILITY WIDGET
   =================================================== */

/* Floating Button */
.acc-widget-btn {
    position: fixed;
    bottom: 100px;
    left: 20px;
    z-index: 99998;
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: var(--acc-primary);
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 15px rgba(26, 86, 219, 0.4);
    transition: var(--acc-transition);
    animation: acc-pulse 2s infinite;
}

.acc-widget-btn:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 25px rgba(26, 86, 219, 0.6);
}

.acc-widget-btn svg {
    width: 32px;
    height: 32px;
    fill: #ffffff;
}

@keyframes acc-pulse {
    0%, 100% { box-shadow: 0 4px 15px rgba(26, 86, 219, 0.4); }
    50% { box-shadow: 0 4px 25px rgba(26, 86, 219, 0.7); }
}

/* RTL Support */
[dir="rtl"] .acc-widget-btn {
    left: auto;
    right: 20px;
}

[dir="rtl"] .acc-widget-panel {
    left: auto;
    right: 20px;
}

/* Panel */
.acc-widget-panel {
    position: fixed;
    bottom: 170px;
    left: 20px;
    z-index: 99999;
    width: 360px;
    max-height: 75vh;
    background: var(--acc-bg);
    border-radius: var(--acc-radius);
    box-shadow: var(--acc-shadow);
    overflow: hidden;
    transform: scale(0.8) translateY(20px);
    opacity: 0;
    visibility: hidden;
    transition: var(--acc-transition);
    display: flex;
    flex-direction: column;
}

.acc-widget-panel.active {
    transform: scale(1) translateY(0);
    opacity: 1;
    visibility: visible;
}

/* Panel Header */
.acc-panel-header {
    background: var(--acc-primary);
    color: #ffffff;
    padding: 18px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-shrink: 0;
}

.acc-panel-header h3 {
    margin: 0;
    font-size: 16px;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 10px;
}

.acc-panel-header h3 svg {
    width: 22px;
    height: 22px;
    fill: #ffffff;
}

.acc-panel-close {
    background: rgba(255,255,255,0.2);
    border: none;
    color: #ffffff;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    transition: var(--acc-transition);
}

.acc-panel-close:hover {
    background: rgba(255,255,255,0.35);
}

/* Panel Body */
.acc-panel-body {
    padding: 16px;
    overflow-y: auto;
    flex: 1;
}

/* Options Grid */
.acc-options-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}

.acc-option {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 14px 8px;
    border: 2px solid var(--acc-border);
    border-radius: 12px;
    background: #f9fafb;
    cursor: pointer;
    transition: var(--acc-transition);
    text-align: center;
    min-height: 90px;
}

.acc-option:hover {
    border-color: var(--acc-primary);
    background: #eff6ff;
    transform: translateY(-2px);
}

.acc-option.active {
    border-color: var(--acc-primary);
    background: #dbeafe;
    box-shadow: 0 0 0 3px rgba(26, 86, 219, 0.1);
}

.acc-option-icon {
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
}

.acc-option-icon svg {
    width: 24px;
    height: 24px;
    fill: var(--acc-text);
}

.acc-option.active .acc-option-icon svg {
    fill: var(--acc-primary);
}

.acc-option-label {
    font-size: 11px;
    font-weight: 600;
    color: var(--acc-text);
    line-height: 1.3;
}

.acc-option.active .acc-option-label {
    color: var(--acc-primary);
}

/* Slider Options (for text size, spacing) */
.acc-slider-section {
    margin-top: 12px;
    padding: 12px;
    background: #f9fafb;
    border-radius: 12px;
    border: 2px solid var(--acc-border);
}

.acc-slider-section label {
    font-size: 12px;
    font-weight: 600;
    color: var(--acc-text);
    display: flex;
    align-items: center;
    gap: 6px;
    margin-bottom: 8px;
}

.acc-slider-section input[type="range"] {
    width: 100%;
    height: 6px;
    border-radius: 3px;
    background: #e5e7eb;
    outline: none;
    -webkit-appearance: none;
    appearance: none;
}

.acc-slider-section input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: var(--acc-primary);
    cursor: pointer;
    box-shadow: 0 2px 6px rgba(26, 86, 219, 0.3);
}

/* Reset Button */
.acc-reset-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100%;
    margin-top: 14px;
    padding: 12px;
    background: #fee2e2;
    color: #dc2626;
    border: none;
    border-radius: 10px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: var(--acc-transition);
}

.acc-reset-btn:hover {
    background: #fecaca;
}

/* ===================================================
   2. BACK TO TOP BUTTON
   =================================================== */
.back-to-top-btn {
    position: fixed;
    bottom: 30px;
    left: 20px;
    z-index: 99990;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: var(--acc-primary);
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 12px rgba(26, 86, 219, 0.3);
    transition: var(--acc-transition);
    opacity: 0;
    visibility: hidden;
    transform: translateY(20px);
}

.back-to-top-btn.visible {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.back-to-top-btn:hover {
    transform: translateY(-3px);
    box-shadow: 0 6px 20px rgba(26, 86, 219, 0.5);
}

.back-to-top-btn svg {
    width: 20px;
    height: 20px;
    fill: #ffffff;
}

[dir="rtl"] .back-to-top-btn {
    left: auto;
    right: 20px;
}

/* ===================================================
   3. READING PROGRESS BAR
   =================================================== */
.reading-progress-bar {
    position: fixed;
    top: 0;
    left: 0;
    width: 0%;
    height: 3px;
    background: linear-gradient(90deg, var(--acc-primary), #3b82f6);
    z-index: 100000;
    transition: width 0.1s linear;
    border-radius: 0 2px 2px 0;
}

/* ===================================================
   4. SHARE BUTTON
   =================================================== */
.share-widget-btn {
    position: fixed;
    bottom: 180px;
    left: 20px;
    z-index: 99995;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: #10b981;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 12px rgba(16, 185, 129, 0.3);
    transition: var(--acc-transition);
}

.share-widget-btn:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 20px rgba(16, 185, 129, 0.5);
}

.share-widget-btn svg {
    width: 20px;
    height: 20px;
    fill: #ffffff;
}

[dir="rtl"] .share-widget-btn {
    left: auto;
    right: 20px;
}

/* Share Panel */
.share-panel {
    position: fixed;
    bottom: 230px;
    left: 20px;
    z-index: 99996;
    background: var(--acc-bg);
    border-radius: 12px;
    box-shadow: var(--acc-shadow);
    padding: 16px;
    opacity: 0;
    visibility: hidden;
    transform: scale(0.8) translateY(10px);
    transition: var(--acc-transition);
}

.share-panel.active {
    opacity: 1;
    visibility: visible;
    transform: scale(1) translateY(0);
}

[dir="rtl"] .share-panel {
    left: auto;
    right: 20px;
}

.share-panel-title {
    font-size: 13px;
    font-weight: 700;
    color: var(--acc-text);
    margin-bottom: 12px;
}

.share-panel-links {
    display: flex;
    gap: 10px;
}

.share-panel-links a {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--acc-transition);
    text-decoration: none;
}

.share-panel-links a:hover {
    transform: scale(1.15);
}

.share-panel-links .share-whatsapp { background: #25d366; }
.share-panel-links .share-twitter { background: #1da1f2; }
.share-panel-links .share-facebook { background: #1877f2; }
.share-panel-links .share-copy { background: #6b7280; }

.share-panel-links a svg {
    width: 18px;
    height: 18px;
    fill: #ffffff;
}

/* ===================================================
   5. COOKIE CONSENT BANNER
   =================================================== */
.cookie-consent-banner {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 100001;
    background: #1f2937;
    color: #ffffff;
    padding: 18px 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
    transform: translateY(100%);
    transition: var(--acc-transition);
    box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.2);
}

.cookie-consent-banner.visible {
    transform: translateY(0);
}

.cookie-consent-text {
    font-size: 13px;
    line-height: 1.6;
    flex: 1;
}

.cookie-consent-text a {
    color: #93c5fd;
    text-decoration: underline;
}

.cookie-consent-actions {
    display: flex;
    gap: 10px;
    flex-shrink: 0;
}

.cookie-accept-btn {
    padding: 10px 24px;
    background: var(--acc-primary);
    color: #ffffff;
    border: none;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: var(--acc-transition);
}

.cookie-accept-btn:hover {
    background: var(--acc-primary-hover);
}

.cookie-decline-btn {
    padding: 10px 18px;
    background: transparent;
    color: #9ca3af;
    border: 1px solid #4b5563;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: var(--acc-transition);
}

.cookie-decline-btn:hover {
    border-color: #9ca3af;
    color: #ffffff;
}

/* ===================================================
   6. DARK MODE
   =================================================== */
body.dark-mode {
    background-color: #111827 !important;
    color: #e5e7eb !important;
}

body.dark-mode .acc-widget-panel {
    background: #1f2937;
    --acc-text: #e5e7eb;
    --acc-border: #374151;
}

body.dark-mode .acc-option {
    background: #374151;
    border-color: #4b5563;
}

body.dark-mode .acc-option:hover {
    background: #4b5563;
    border-color: var(--acc-primary);
}

body.dark-mode .acc-option.active {
    background: #1e3a5f;
    border-color: var(--acc-primary);
}

body.dark-mode .acc-option-label {
    color: #e5e7eb;
}

body.dark-mode .acc-slider-section {
    background: #374151;
    border-color: #4b5563;
}

body.dark-mode .acc-panel-body {
    background: #1f2937;
}

/* Accessibility Applied Classes */
/* Filters are applied to <html> element via JS */
/* Floating widgets get counter-filter to remain unaffected */

body.acc-highlight-links a {
    outline: 2px solid #ff6600 !important;
    text-decoration: underline !important;
    background: rgba(255, 102, 0, 0.1) !important;
}

body.acc-big-cursor,
body.acc-big-cursor * {
    cursor: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='32' height='32' viewBox='0 0 32 32'%3E%3Cpath d='M5 2l20 14H14l6 12-4 2-6-12-5 7z' fill='%23000' stroke='%23fff' stroke-width='1'/%3E%3C/svg%3E") 4 2, auto !important;
}

body.acc-reading-guide .acc-reading-line {
    display: block !important;
}

.acc-reading-line {
    display: none;
    position: fixed;
    left: 0;
    right: 0;
    height: 8px;
    background: rgba(26, 86, 219, 0.3);
    border-top: 2px solid var(--acc-primary);
    border-bottom: 2px solid var(--acc-primary);
    pointer-events: none;
    z-index: 99997;
    transition: top 0.05s linear;
}

body.acc-hide-images img {
    opacity: 0.05 !important;
}

body.acc-dyslexia-font,
body.acc-dyslexia-font *:not(.fas):not(.far):not(.fab):not(.fa):not(.fa-solid):not(.fa-regular):not(.fa-brands):not([class*="fa-"]):not(.swiper-button-next):not(.swiper-button-prev) {
    font-family: 'OpenDyslexic', 'Comic Sans MS', 'Arial', sans-serif !important;
}

body.acc-pause-animations,
body.acc-pause-animations * {
    animation-play-state: paused !important;
    transition: none !important;
}

/* ===================================================
   RESPONSIVE
   =================================================== */
@media (max-width: 480px) {
    .acc-widget-panel {
        width: calc(100vw - 40px);
        left: 20px;
        right: 20px;
        bottom: 90px;
        max-height: 70vh;
    }

    [dir="rtl"] .acc-widget-panel {
        left: 20px;
        right: 20px;
    }

    .cookie-consent-banner {
        flex-direction: column;
        padding: 16px;
        gap: 12px;
    }

    .cookie-consent-actions {
        width: 100%;
        justify-content: center;
    }

    .share-panel {
        left: 20px;
        right: 20px;
    }

    [dir="rtl"] .share-panel {
        left: 20px;
        right: 20px;
    }
}
