/* ============================================================
   AFB Accessibility Pro – Widget Styles  v3.0.0
   ============================================================ */

/* ── Screen-reader only ─────────────────────────────────────── */
.afb-sr-only {
    position: absolute; width: 1px; height: 1px;
    padding: 0; margin: -1px; overflow: hidden;
    clip: rect(0,0,0,0); white-space: nowrap; border: 0;
}

/* ── CSS Variables (overrideable via wp_add_inline_style) ─── */
:root {
    --afb-brand:    #2563EB;
    --afb-brand-dk: #1d4ed8;
    --afb-panel-bg: #ffffff;
    --afb-panel-fg: #1e293b;
    --afb-border:   #e2e8f0;
    --afb-radius:   14px;
    --afb-shadow:   0 8px 32px rgba(0,0,0,.18);
    --afb-section-bg: #f8fafc;
    --afb-toggle-active: #2563EB;
    --afb-toggle-text:   #374151;
    --afb-z: 999999;
}

/* ── Widget Container ───────────────────────────────────────── */
.afb-acc-widget {
    position: fixed;
    z-index: var(--afb-z);
    font-family: inherit !important;
}

.afb-pos-bottom-right { bottom: 24px; right: 24px; }
.afb-pos-bottom-left  { bottom: 24px; left:  24px; }
.afb-pos-top-right    { top: 24px;    right: 24px; }
.afb-pos-top-left     { top: 24px;    left:  24px; }

/* ── Trigger Button ─────────────────────────────────────────── */
.afb-trigger {
    width: 56px; height: 56px;
    border-radius: 50% !important;
    background: var(--afb-brand) !important;
    color: #fff !important;
    border: none;
    cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    box-shadow: 0 4px 16px rgba(37,99,235,.4);
    transition: transform .2s, box-shadow .2s;
    position: relative;
    z-index: 1;
}
.afb-trigger:hover  { transform: scale(1.08); box-shadow: 0 6px 20px rgba(37,99,235,.5); }
.afb-trigger:focus  { outline: 3px solid #fff; outline-offset: 2px; }

/* ── Panel ──────────────────────────────────────────────────── */
.afb-panel {
    position: absolute;
    bottom: 68px; right: 0;
    width: 340px;
    max-height: 80vh;
    overflow-y: auto;
    background: var(--afb-panel-bg);
    color: var(--afb-panel-fg);
    border-radius: var(--afb-radius);
    box-shadow: var(--afb-shadow);
    border: 1px solid var(--afb-border);
    opacity: 0;
    transform: translateY(10px) scale(.97);
    transition: opacity .25s, transform .25s;
    pointer-events: none;
}
.afb-pos-bottom-left  .afb-panel { right: auto; left: 0; }
.afb-pos-top-right    .afb-panel { bottom: auto; top: 68px; }
.afb-pos-top-left     .afb-panel { bottom: auto; top: 68px; right: auto; left: 0; }

.afb-panel:not([hidden]) {
    opacity: 1;
    transform: translateY(0) scale(1);
    pointer-events: auto;
}
.afb-panel[hidden] { display: block !important; }

/* ── Panel Header ───────────────────────────────────────────── */
.afb-panel-header {
    display: flex; justify-content: space-between; align-items: center;
    padding: 16px 18px 12px;
    border-bottom: 1px solid var(--afb-border);
    background: var(--afb-brand);
    border-radius: var(--afb-radius) var(--afb-radius) 0 0;
    color: #fff;
}
.afb-panel-title { font-weight: 700; font-size: 15px; }
.afb-header-actions { display: flex; align-items: center; gap: 8px; }

.afb-reset-btn {
    background: rgb(226,163,51) !important;
	border: none;
	color: #fff !important;
	
    width: 28px; height: 28px; border-radius: 50% !important; cursor: pointer;
    font-size: 16px; display: flex; align-items: center; justify-content: center;
	font-weight: bold;
    transition: background .15s;
}
.afb-reset-btn:hover { background: rgba(255,255,255,.35); }

.afb-close-btn {
    background: rgb(226,163,51) !important;
	border: none;
	color: #fff !important;
	
    width: 28px; height: 28px; border-radius: 50% !important; cursor: pointer;
    font-size: 16px; display: flex; align-items: center; justify-content: center;
	font-weight: bold;
    transition: background .15s;
}
.afb-close-btn:hover { background: rgba(255,255,255,.3); }

/* ── Section ────────────────────────────────────────────────── */
.afb-section {
    padding: 14px 16px;
    border-bottom: 1px solid var(--afb-border);
}
.afb-section:last-child { border-bottom: none; }
.afb-section-title {
    font-size: 11px; font-weight: 700; text-transform: uppercase;
    letter-spacing: .06em; color: #94a3b8; margin: 0 0 12px;
}

/* ── Profiles Grid ──────────────────────────────────────────── */
.afb-profiles-grid {
    display: grid; grid-template-columns: 1fr 1fr; gap: 8px;
}
.afb-profile-btn {
    display: flex; flex-direction: column; align-items: center; gap: 6px;
    padding: 12px 8px; border: 2px solid var(--afb-border);
    border-radius: 10px; background: var(--afb-section-bg);
    cursor: pointer; transition: all .15s; color: var(--afb-panel-fg);
}
.afb-profile-btn:hover, .afb-profile-btn.active {
    border-color: var(--afb-brand);
    background: #eff6ff;
    color: var(--afb-brand);
}
.afb-profile-icon { font-size: 22px; line-height: 1; }
.afb-profile-name { font-size: 11px; font-weight: 600; text-align: center; }

/* ── Controls Grid ──────────────────────────────────────────── */
.afb-controls-grid {
    display: grid; grid-template-columns: 1fr; gap: 8px;
}
.afb-control-wide { grid-column: 1 / -1; }

/* ── Toggle Button ──────────────────────────────────────────── */
.afb-toggle-btn {
    display: flex; flex-direction: column; align-items: center; gap: 4px;
    padding: 10px 6px; border: 2px solid var(--afb-border);
    border-radius: 10px; background: var(--afb-section-bg);
    cursor: pointer; font-size: 11px; font-weight: 500;
    color: var(--afb-toggle-text); transition: all .15s;
    line-height: 1.3;
}
.afb-toggle-btn:hover { border-color: var(--afb-brand); background: #eff6ff; }
.afb-toggle-btn[aria-pressed="true"],
.afb-toggle-btn.active {
    border-color: var(--afb-toggle-active);
    background: var(--afb-toggle-active);
    color: #fff;
}
.afb-toggle-icon { font-size: 18px; line-height: 1; }
.afb-toggle-label { font-size: 11px; text-align: center; }

/* ── Stepper Control ────────────────────────────────────────── */
.afb-control { }
.afb-ctrl-label { font-size: 12px; font-weight: 600; color: #475569; display: block; margin-bottom: 6px; }
.afb-stepper {
    display: flex; align-items: center; gap: 6px;
    background: var(--afb-section-bg);
    border: 1px solid var(--afb-border); border-radius: 8px; padding: 4px 8px;
}
.afb-step-btn {
    background: none; border: none; cursor: pointer;
    width: 28px; height: 28px; border-radius: 6px;
    font-size: 12px; font-weight: 700; color: var(--afb-brand);
    transition: background .12s;
    display: flex; align-items: center; justify-content: center;
}
.afb-step-btn:hover { background: #dbeafe; }
.afb-step-val { flex: 1; text-align: center; font-size: 13px; font-weight: 600; color: var(--afb-panel-fg); }

/* ── Btn Group (alignment) ──────────────────────────────────── */
.afb-btn-group {
    display: flex; gap: 4px;
    background: var(--afb-section-bg);
    border: 1px solid var(--afb-border); border-radius: 8px; padding: 4px;
}
.afb-group-btn {
    flex: 1; padding: 6px; border: none; border-radius: 6px; cursor: pointer;
    background: none; font-size: 14px; color: var(--afb-panel-fg);
    transition: all .12s;
}
.afb-group-btn:hover { background: #dbeafe; color: var(--afb-brand); }
.afb-group-btn[aria-pressed="true"],
.afb-group-btn.active { background: var(--afb-brand); color: #fff; }

/* ── Statement ──────────────────────────────────────────────── */
.afb-section-statement { text-align: center; }
.afb-statement-link, .afb-statement-btn {
    display: inline-block;
    color: var(--afb-brand); font-size: 13px; text-decoration: underline;
    background: none; border: none; cursor: pointer; padding: 0;
}
.afb-statement-body {
    text-align: start; font-size: 12px; color: #475569;
    margin-top: 10px; line-height: 1.6;
    padding: 10px; background: var(--afb-section-bg);
    border-radius: 8px; border: 1px solid var(--afb-border);
}

/* ── Panel Footer ───────────────────────────────────────────── */
.afb-panel-footer {
    padding: 10px 16px; text-align: center;
    font-size: 11px; color: #94a3b8;
    border-top: 1px solid var(--afb-border);
}

/* ── Reading Guide ──────────────────────────────────────────── */
.afb-reading-guide {
    position: fixed; left: 0; right: 0;
    height: 28px;
    background: rgba(37,99,235,.12);
    border-top: 2px solid rgba(37,99,235,.5);
    border-bottom: 2px solid rgba(37,99,235,.5);
    pointer-events: none;
    z-index: calc(var(--afb-z) - 1);
    transition: top .05s;
}

/* ── Big Cursor ─────────────────────────────────────────────── */
.afb-big-cursor {
    position: fixed; pointer-events: none;
    z-index: calc(var(--afb-z) + 1);
    transform: translate(-4px, -4px);
}

/* ─── Applied State Classes ─────────────────────────────────── */

/* Dark Mode */
html.afb-dark { filter: invert(1) hue-rotate(180deg) !important; }
html.afb-dark img,
html.afb-dark video,
html.afb-dark iframe { filter: invert(1) hue-rotate(180deg); }
html.afb-dark .afb-acc-widget * { filter: none !important; }

/* Light Mode */
html.afb-light { filter: brightness(1.08) saturate(1.1) !important; }

/* High Contrast */
html.afb-high-contrast body { background: #000 !important; color: #ffff00 !important; }
html.afb-high-contrast a { color: #00ffff !important; }
html.afb-high-contrast * { border-color: #ffff00 !important; }
html.afb-high-contrast .afb-acc-widget { filter: none !important; }

/* Saturation */
html.afb-low-sat  { filter: saturate(.2) !important; }
html.afb-high-sat { filter: saturate(2)  !important; }
html.afb-grayscale { filter: grayscale(1) !important; }
html.afb-grayscale .afb-acc-widget * { filter: none; }

/* Dyslexic Font */
html.afb-dyslexic, html.afb-dyslexic * {
    font-family: 'OpenDyslexic', 'Comic Sans MS', cursive !important;
}

/* Highlight Titles */
html.afb-hl-titles h1, html.afb-hl-titles h2,
html.afb-hl-titles h3, html.afb-hl-titles h4,
html.afb-hl-titles h5, html.afb-hl-titles h6 {
    background: #fef08a !important; color: #1e293b !important;
    box-shadow: 0 0 0 3px #fef08a; border-radius: 3px;
}

/* Highlight Links */
html.afb-hl-links a {
    background: #bbf7d0 !important; color: #14532d !important;
    text-decoration: underline !important;
    padding: 0 3px; border-radius: 3px;
}

/* Pause Animations */
html.afb-no-anim *, html.afb-no-anim *::before, html.afb-no-anim *::after {
    animation-duration: .001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .001ms !important;
    scroll-behavior: auto !important;
}

/* Big Cursor */
html.afb-big-cur { cursor: none !important; }
html.afb-big-cur * { cursor: none !important; }

/* Mute */
/* JS handles muting; no CSS class needed */

/* Scrollbar styling in panel */
.afb-panel::-webkit-scrollbar { width: 6px; }
.afb-panel::-webkit-scrollbar-track { background: transparent; }
.afb-panel::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 3px; }

/* RTL adjustments */
[dir="rtl"] .afb-pos-bottom-right { right: auto; left: 24px; }
[dir="rtl"] .afb-pos-bottom-left  { left: auto;  right: 24px; }
[dir="rtl"] .afb-pos-bottom-right .afb-panel { right: auto; left: 0; }
[dir="rtl"] .afb-pos-bottom-left  .afb-panel { left: auto;  right: 0; }

/* Responsive */
@media (max-width: 480px) {
    .afb-panel { width: calc(100vw - 32px); max-width: 340px; }
    .afb-pos-bottom-right, .afb-pos-bottom-left { right: 12px; left: 12px; }
    .afb-pos-bottom-right .afb-panel, .afb-pos-bottom-left .afb-panel { right: 0; left: 0; width: 100%; }
}
/* ============================================================
   تحسينات الهواتف المحمولة - Responsive Fixes
   ============================================================ */

@media (max-width: 550px) {

    .afb-panel {
        position: fixed !important;

        left: 12px !important;
        right: 12px !important;
        bottom: 84px !important;
        top: auto !important;

        width: auto !important;
        max-width: none !important;

        max-height: calc(100dvh - 100px) !important;

        border-radius: 16px !important;
    }

    .afb-controls-grid,
    .afb-profiles-grid {
        grid-template-columns: 1fr !important;
        gap: 10px !important;
    }

    .afb-toggle-btn,
    .afb-profile-btn {

        width: 100%;

        min-height: 56px;

        display: flex;
        flex-direction: row !important;

        align-items: center !important;
        justify-content: space-between !important;

        padding: 14px 16px !important;

        gap: 12px !important;
    }

    .afb-toggle-icon,
    .afb-profile-icon {
        font-size: 22px !important;
        flex-shrink: 0;
    }

    .afb-toggle-label,
    .afb-profile-name {
        flex: 1;
        text-align: start !important;
        font-size: 13px !important;
    }

    .afb-trigger {
        width: 60px !important;
        height: 60px !important;
    }

    .afb-step-btn {
        width: 44px !important;
        height: 44px !important;
    }

    .afb-section {
        padding: 12px 14px !important;
    }

}

/* للشاشات الصغيرة جداً (أقل من 360 بكسل) */
@media (max-width: 360px) {
    .afb-toggle-label,
    .afb-profile-name {
        font-size: 12px !important;
    }
    
    .afb-panel {
        max-width: 100% !important;
        width: calc(100vw - 20px) !important;
    }
}