/* ==========================================================================
   Accessibility Styles & WCAG 2.1 Level AA Enhancements for RSUD
   ========================================================================== */

/* Dyslexia friendly font */
@import url('https://fonts.googleapis.com/css2?family=Lexend:wght@400;500;600;700&display=swap');

/* Skip to content link */
.a11y-skip-link {
    position: fixed;
    top: -100px;
    left: 20px;
    background: #0066cc;
    color: #ffffff !important;
    padding: 12px 24px;
    font-weight: 700;
    font-size: 14px;
    border-radius: 0 0 12px 12px;
    z-index: 9999999;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.5);
    transition: top 0.2s ease-in-out;
    text-decoration: none !important;
}

.a11y-skip-link:focus {
    top: 0;
    outline: 3px solid #ffcc00;
    outline-offset: 2px;
}

/* Floating Accessibility Button */
.a11y-floating-trigger {
    position: fixed;
    bottom: 25px;
    left: 25px;
    z-index: 999990;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: #0066cc;
    color: #ffffff !important;
    box-shadow: 0 8px 24px rgba(0, 102, 204, 0.4);
    cursor: pointer;
    border: 3px solid #ffffff;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    font-size: 24px;
}

.a11y-floating-trigger:hover {
    background: #004c99;
    transform: scale(1.08);
    box-shadow: 0 12px 28px rgba(0, 102, 204, 0.6);
    color: #ffffff !important;
}

.a11y-floating-trigger:focus {
    outline: 3px solid #ffcc00;
    outline-offset: 3px;
}

.a11y-badge-active {
    position: absolute;
    top: -2px;
    right: -2px;
    width: 14px;
    height: 14px;
    background-color: #ffcc00;
    border: 2px solid #ffffff;
    border-radius: 50%;
    display: none;
}

/* Accessibility Drawer Panel */
.a11y-panel-modal {
    position: fixed;
    bottom: 95px;
    left: 25px;
    width: 360px;
    max-width: calc(100vw - 40px);
    max-height: 80vh;
    overflow-y: auto;
    background: #ffffff;
    border-radius: 24px;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.25);
    border: 1px solid #e2e8f0;
    z-index: 999991;
    display: none;
    flex-direction: column;
    padding: 20px;
    animation: a11ySlideUp 0.3s ease-out;
}

.a11y-panel-modal.show {
    display: flex;
}

@keyframes a11ySlideUp {
    from {
        opacity: 0;
        transform: translateY(20px) scale(0.95);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.a11y-panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding-bottom: 12px;
    border-bottom: 1px solid #f1f5f9;
}

.a11y-panel-title {
    font-size: 16px;
    font-weight: 700;
    color: #0f172a;
    margin: 0;
    display: flex;
    align-items: center;
    gap: 8px;
}

.a11y-close-btn {
    background: transparent;
    border: none;
    color: #94a3b8;
    font-size: 20px;
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 8px;
    transition: all 0.2s;
}

.a11y-close-btn:hover {
    background: #f1f5f9;
    color: #334155;
}

.a11y-section-box {
    margin-top: 15px;
    padding: 12px;
    background: #f8fafc;
    border-radius: 16px;
    border: 1px solid #e2e8f0;
}

.a11y-section-label {
    font-size: 12px;
    font-weight: 700;
    color: #334155;
    margin-bottom: 8px;
    display: flex;
    align-items: center;
    gap: 6px;
}

.a11y-btn-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 6px;
}

.a11y-btn-grid-2 {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
}

.a11y-opt-btn {
    background: #ffffff;
    border: 1px solid #cbd5e1;
    color: #334155;
    padding: 8px 4px;
    border-radius: 10px;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    text-align: center;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 5px;
}

.a11y-opt-btn:hover {
    background: #e2e8f0;
    border-color: #94a3b8;
}

.a11y-opt-btn.active {
    background: #0066cc !important;
    color: #ffffff !important;
    border-color: #0066cc !important;
    box-shadow: 0 2px 8px rgba(0, 102, 204, 0.3);
}

.a11y-toggle-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: #ffffff;
    border: 1px solid #cbd5e1;
    color: #334155;
    padding: 10px 12px;
    border-radius: 12px;
    margin-bottom: 6px;
    cursor: pointer;
    font-size: 12px;
    font-weight: 600;
    transition: all 0.2s;
}

.a11y-toggle-row:hover {
    background: #f1f5f9;
}

.a11y-toggle-row.active {
    background: #f0f7ff;
    border-color: #0066cc;
    color: #0066cc;
}

/* Text To Speech Card */
.a11y-tts-box {
    background: linear-gradient(135deg, #eff6ff 0%, #e0f2fe 100%);
    border: 1px solid #bae6fd;
    border-radius: 16px;
    padding: 12px;
    margin-top: 15px;
}

.a11y-tts-btn-row {
    display: flex;
    gap: 6px;
    margin-top: 8px;
}

.a11y-tts-btn {
    flex: 1;
    background: #0066cc;
    color: #ffffff !important;
    border: none;
    padding: 8px 12px;
    border-radius: 10px;
    font-size: 12px;
    font-weight: 700;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    transition: all 0.2s;
}

.a11y-tts-btn:hover {
    background: #004c99;
}

.a11y-tts-btn.btn-pause {
    background: #f59e0b;
}

.a11y-tts-btn.btn-stop {
    flex: 0 0 42px;
    background: #ef4444;
}

/* Modifiers on <html> or <body> */
html.a11y-font-lg {
    font-size: 112.5% !important; /* ~18px base */
}

html.a11y-font-xl {
    font-size: 125% !important; /* ~20px base */
}

html.a11y-font-xxl {
    font-size: 137.5% !important; /* ~22px base */
}

/* Dyslexia friendly */
html.a11y-dyslexia,
html.a11y-dyslexia * {
    font-family: 'Lexend', 'Comic Sans MS', sans-serif !important;
    letter-spacing: 0.05em !important;
    word-spacing: 0.1em !important;
    line-height: 1.75 !important;
}

/* High Contrast Mode */
html.a11y-high-contrast,
html.a11y-high-contrast body,
html.a11y-high-contrast header,
html.a11y-high-contrast nav,
html.a11y-high-contrast main,
html.a11y-high-contrast footer,
html.a11y-high-contrast section,
html.a11y-high-contrast div:not(.a11y-panel-modal):not(.a11y-floating-trigger),
html.a11y-high-contrast article {
    background-color: #000000 !important;
    color: #ffff00 !important;
    border-color: #ffff00 !important;
    box-shadow: none !important;
}

html.a11y-high-contrast a,
html.a11y-high-contrast button:not(.a11y-opt-btn):not(.a11y-floating-trigger) {
    color: #00ffff !important;
    border-color: #00ffff !important;
}

html.a11y-high-contrast img,
html.a11y-high-contrast svg {
    filter: brightness(0.9) contrast(1.2);
}

/* Monochrome Mode */
html.a11y-monochrome {
    filter: grayscale(100%) !important;
}

/* Invert Mode */
html.a11y-invert {
    filter: invert(100%) hue-rotate(180deg) !important;
}

html.a11y-invert img,
html.a11y-invert video,
html.a11y-invert iframe {
    filter: invert(100%) hue-rotate(180deg) !important;
}

/* Highlight Links */
html.a11y-highlight-links a,
html.a11y-highlight-links button {
    text-decoration: underline !important;
    text-decoration-thickness: 2px !important;
    text-underline-offset: 4px !important;
    background-color: rgba(254, 240, 138, 0.4) !important;
    outline: 2px solid #ca8a04 !important;
    outline-offset: 2px !important;
}

/* Reading Ruler */
.a11y-reading-ruler {
    position: fixed;
    left: 0;
    right: 0;
    height: 32px;
    background: rgba(250, 204, 21, 0.3);
    border-top: 2px solid #ca8a04;
    border-bottom: 2px solid #ca8a04;
    pointer-events: none;
    z-index: 999998;
    transform: translateY(-50%);
    display: none;
}

.a11y-reading-ruler.active {
    display: block;
}

/* Big Cursor */
html.a11y-big-cursor,
html.a11y-big-cursor * {
    cursor: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='44' height='44' viewBox='0 0 24 24' fill='%23000000' stroke='%23ffffff' stroke-width='1.5'%3E%3Cpath d='M3 3l7 18 3-7 7-3L3 3z'/%3E%3C/svg%3E"), auto !important;
}

/* Pause Animations */
html.a11y-pause-animations,
html.a11y-pause-animations * {
    animation: none !important;
    transition: none !important;
}

/* Keyboard Focus Highlights */
:focus-visible {
    outline: 3px solid #0066cc !important;
    outline-offset: 2px !important;
}
