/**
 * Enhancement styles: accessibility toolbar + effects, and live-search
 * suggestions. Loaded on every page after style.css.
 *
 * @package AlSalam
 */

/* ============================================================
   ACCESSIBILITY EFFECTS (classes toggled on <html>)
   ============================================================ */

/* Font scaling — rem-based sizes across the theme inherit automatically */
html[data-a11y-font="1"] { font-size: 112.5%; }
html[data-a11y-font="2"] { font-size: 125%; }
html[data-a11y-font="3"] { font-size: 137.5%; }

/* High contrast — inversion with media re-inverted so photos stay natural */
html.a11y-contrast {
    filter: invert(1) hue-rotate(180deg);
    background: #fff;
}
html.a11y-contrast img,
html.a11y-contrast video,
html.a11y-contrast iframe,
html.a11y-contrast [style*="background-image"] {
    filter: invert(1) hue-rotate(180deg);
}

/* Grayscale */
html.a11y-grayscale {
    filter: grayscale(1);
}
html.a11y-contrast.a11y-grayscale {
    filter: invert(1) hue-rotate(180deg) grayscale(1);
}

/* Underline all links */
html.a11y-underline a {
    text-decoration: underline !important;
    text-underline-offset: 2px;
}

/* Readable font — simpler letterforms + roomier lines */
html.a11y-readable body,
html.a11y-readable body * {
    font-family: 'Segoe UI', Tahoma, Arial, sans-serif !important;
    letter-spacing: 0.01em;
}
html.a11y-readable body {
    line-height: 1.9;
}

/* Pause animations & transitions */
html.a11y-no-motion *,
html.a11y-no-motion *::before,
html.a11y-no-motion *::after {
    animation: none !important;
    transition: none !important;
    scroll-behavior: auto !important;
}
html.a11y-no-motion .animate-on-scroll {
    opacity: 1 !important;
    transform: none !important;
}

/* Respect the OS-level reduced-motion preference too (WCAG 2.3.3) */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }
}

/* Strong, visible focus indicator everywhere (WCAG 2.4.7) */
a:focus-visible,
button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
[tabindex]:focus-visible {
    outline: 3px solid var(--color-accent, #D4A843) !important;
    outline-offset: 2px;
    border-radius: 2px;
}

.screen-reader-text {
    position: absolute !important;
    width: 1px; height: 1px;
    margin: -1px; padding: 0;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
    border: 0;
}

/* ============================================================
   ACCESSIBILITY WIDGET UI
   ============================================================ */
.a11y-widget {
    position: fixed;
    bottom: 96px;
    z-index: 9999;
}
.a11y-widget--rtl { left: 20px; }
.a11y-widget--ltr { right: 20px; }

.a11y-widget__toggle {
    width: 52px; height: 52px;
    border: none;
    border-radius: 50%;
    background: var(--color-primary, #1B2A4A);
    color: #fff;
    font-size: 1.5rem;
    cursor: pointer;
    box-shadow: 0 4px 14px rgba(0,0,0,0.3);
    display: flex; align-items: center; justify-content: center;
    transition: transform 0.2s ease, background 0.2s ease;
}
.a11y-widget__toggle:hover {
    background: var(--color-accent, #D4A843);
    transform: scale(1.08);
}

.a11y-panel {
    position: absolute;
    bottom: 62px;
    width: 240px;
    background: #fff;
    color: #212529;
    border-radius: 12px;
    box-shadow: 0 10px 40px rgba(0,0,0,0.25);
    padding: 12px;
    max-height: min(70vh, 520px);
    overflow-y: auto;
}
.a11y-widget--rtl .a11y-panel { left: 0; }
.a11y-widget--ltr .a11y-panel { right: 0; }

.a11y-panel__head {
    display: flex; align-items: center; justify-content: space-between;
    font-weight: 700;
    padding-bottom: 10px;
    margin-bottom: 10px;
    border-bottom: 2px solid var(--color-accent, #D4A843);
    color: var(--color-primary, #1B2A4A);
}
.a11y-panel__close {
    border: none; background: none; cursor: pointer;
    font-size: 1rem; color: #6C757D;
    padding: 4px 8px;
}
.a11y-panel__close:hover { color: #DC3545; }

.a11y-panel__group { margin-bottom: 10px; }
.a11y-panel__label {
    display: block;
    font-size: 0.8rem; font-weight: 600;
    color: #6C757D;
    margin-bottom: 6px;
}
.a11y-panel__row {
    display: flex; align-items: center; justify-content: space-between; gap: 8px;
}
.a11y-font-level {
    font-weight: 700; font-size: 0.9rem;
    min-width: 56px; text-align: center;
}

.a11y-btn {
    border: 1.5px solid #E9ECEF;
    background: #F8F9FA;
    color: #212529;
    border-radius: 8px;
    padding: 8px 12px;
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.15s ease;
    font-family: inherit;
}
.a11y-btn:hover {
    border-color: var(--color-accent, #D4A843);
    background: #fff;
}
.a11y-btn.active {
    background: var(--color-primary, #1B2A4A);
    border-color: var(--color-primary, #1B2A4A);
    color: #fff;
}
.a11y-btn--wide {
    display: flex; align-items: center; gap: 8px;
    width: 100%;
    margin-bottom: 6px;
    text-align: start;
}
.a11y-btn--reset {
    color: #DC3545;
    justify-content: center;
}
.a11y-btn--reset:hover { border-color: #DC3545; }

@media (max-width: 600px) {
    .a11y-widget { bottom: 84px; }
    .a11y-widget--rtl { left: 12px; }
    .a11y-widget--ltr { right: 12px; }
    .a11y-panel { width: min(240px, calc(100vw - 40px)); }
}

/* ============================================================
   LIVE SEARCH SUGGESTIONS (inside the search overlay)
   ============================================================ */
.search-suggestions {
    margin-top: 12px;
    background: #fff;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 10px 40px rgba(0,0,0,0.25);
    display: none;
    text-align: start;
    max-height: 50vh;
    overflow-y: auto;
}
.search-suggestions.visible { display: block; }

.search-suggestions__list {
    list-style: none;
    margin: 0; padding: 0;
}
.search-suggestions__item a {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 12px 18px;
    color: #212529;
    text-decoration: none;
    border-bottom: 1px solid #F1F3F5;
    transition: background 0.12s ease;
}
.search-suggestions__item:last-child a { border-bottom: none; }
.search-suggestions__item a:hover,
.search-suggestions__item.is-active a {
    background: #F8F9FA;
}
.search-suggestions__title {
    font-weight: 600;
    font-size: 0.95rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.search-suggestions__type {
    flex-shrink: 0;
    font-size: 0.72rem;
    font-weight: 700;
    color: var(--color-primary, #1B2A4A);
    background: rgba(212, 168, 67, 0.18);
    border-radius: 20px;
    padding: 3px 10px;
    white-space: nowrap;
}
.search-suggestions__empty,
.search-suggestions__loading {
    padding: 14px 18px;
    color: #6C757D;
    font-size: 0.9rem;
}
.search-suggestions__all a {
    display: block;
    text-align: center;
    padding: 11px;
    font-weight: 700;
    font-size: 0.88rem;
    color: var(--color-primary, #1B2A4A);
    background: #F8F9FA;
    text-decoration: none;
}
.search-suggestions__all a:hover { background: #E9ECEF; }

/* ============================================================
   FAQ CHATBOT (opposite corner from the accessibility widget)
   ============================================================ */
.chatbot {
    position: fixed;
    bottom: 24px;
    z-index: 9999;
}
.chatbot--rtl { right: 20px; }
.chatbot--ltr { left: 20px; }

.chatbot__toggle {
    width: 56px; height: 56px;
    border: none;
    border-radius: 50%;
    background: var(--color-accent, #D4A843);
    color: var(--color-primary-dark, #0F1A2E);
    font-size: 1.5rem;
    cursor: pointer;
    box-shadow: 0 4px 14px rgba(0,0,0,0.3);
    display: flex; align-items: center; justify-content: center;
    transition: transform 0.2s ease, background 0.2s ease;
}
.chatbot__toggle:hover {
    background: var(--color-primary, #1B2A4A);
    color: #fff;
    transform: scale(1.08);
}

.chatbot__window {
    position: absolute;
    bottom: 68px;
    width: 340px;
    max-width: calc(100vw - 40px);
    height: 460px;
    max-height: 70vh;
    background: #fff;
    border-radius: 16px;
    box-shadow: 0 10px 40px rgba(0,0,0,0.3);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}
.chatbot--rtl .chatbot__window { right: 0; }
.chatbot--ltr .chatbot__window { left: 0; }

.chatbot__head {
    display: flex; align-items: center; justify-content: space-between;
    background: var(--color-primary, #1B2A4A);
    color: #fff;
    padding: 12px 16px;
    flex-shrink: 0;
}
.chatbot__head-title {
    display: flex; align-items: center; gap: 8px;
    font-weight: 700; font-size: 0.95rem;
}
.chatbot__head-title .fa-robot { color: var(--color-accent, #D4A843); }
.chatbot__close {
    border: none; background: none; cursor: pointer;
    color: rgba(255,255,255,0.8);
    font-size: 1rem;
    padding: 4px 8px;
}
.chatbot__close:hover { color: #fff; }

.chatbot__messages {
    flex: 1;
    overflow-y: auto;
    padding: 14px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    background: #F8F9FA;
}

.chatbot__msg {
    max-width: 85%;
    padding: 10px 14px;
    border-radius: 14px;
    font-size: 0.88rem;
    line-height: 1.6;
}
.chatbot__msg p { margin: 0; }
.chatbot__msg--bot {
    background: #fff;
    color: #212529;
    align-self: flex-start;
    border: 1px solid #E9ECEF;
    border-start-start-radius: 4px;
}
.chatbot__msg--user {
    background: var(--color-primary, #1B2A4A);
    color: #fff;
    align-self: flex-end;
    border-start-end-radius: 4px;
}
.chatbot__msg-link {
    display: inline-block;
    margin-top: 8px;
    font-weight: 700;
    font-size: 0.82rem;
    color: var(--color-accent-dark, #B88A2A);
    text-decoration: none;
}
.chatbot__msg-link:hover { text-decoration: underline; }

.chatbot__chips {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    align-self: flex-start;
    max-width: 95%;
}
.chatbot__chips-label {
    width: 100%;
    font-size: 0.75rem;
    color: #6C757D;
    font-weight: 600;
}
.chatbot__chip {
    border: 1.5px solid var(--color-accent, #D4A843);
    background: #fff;
    color: var(--color-primary, #1B2A4A);
    border-radius: 20px;
    padding: 6px 14px;
    font-size: 0.8rem;
    font-weight: 600;
    cursor: pointer;
    font-family: inherit;
    text-decoration: none;
    transition: all 0.15s ease;
}
.chatbot__chip:hover {
    background: var(--color-accent, #D4A843);
    color: var(--color-primary-dark, #0F1A2E);
}

.chatbot__form {
    display: flex;
    gap: 8px;
    padding: 10px;
    border-top: 1px solid #E9ECEF;
    background: #fff;
    flex-shrink: 0;
}
.chatbot__input {
    flex: 1;
    border: 1.5px solid #E9ECEF;
    border-radius: 24px;
    padding: 9px 16px;
    font-size: 0.88rem;
    font-family: inherit;
    outline: none;
}
.chatbot__input:focus { border-color: var(--color-accent, #D4A843); }
.chatbot__send {
    width: 42px; height: 42px;
    border: none;
    border-radius: 50%;
    background: var(--color-primary, #1B2A4A);
    color: #fff;
    cursor: pointer;
    flex-shrink: 0;
    transition: background 0.15s ease;
}
.chatbot__send:hover { background: var(--color-accent-dark, #B88A2A); }
[dir="ltr"] .chatbot__send i { transform: none; }
[dir="rtl"] .chatbot__send i { transform: scaleX(-1); }

@media (max-width: 600px) {
    .chatbot--rtl { right: 12px; }
    .chatbot--ltr { left: 12px; }
    .chatbot__window { height: 65vh; }
}

/* ============================================================
   CALENDAR EXPORT BUTTONS
   ============================================================ */
.calendar-export {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-bottom: var(--space-xl, 2rem);
}
.calendar-export__btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 20px;
    border-radius: 24px;
    font-size: 0.9rem;
    font-weight: 700;
    text-decoration: none;
    background: var(--color-primary, #1B2A4A);
    color: #fff;
    transition: background 0.15s ease;
}
.calendar-export__btn:hover { background: var(--color-accent-dark, #B88A2A); color: #fff; }
.calendar-export__btn--outline {
    background: transparent;
    border: 2px solid var(--color-primary, #1B2A4A);
    color: var(--color-primary, #1B2A4A);
}
.calendar-export__btn--outline:hover {
    background: var(--color-primary, #1B2A4A);
    color: #fff;
}
.calendar-gcal-link {
    font-size: 0.78rem;
    white-space: nowrap;
    color: var(--color-accent-dark, #B88A2A);
    text-decoration: none;
    font-weight: 700;
}
.calendar-gcal-link:hover { text-decoration: underline; }
