/* IEPC Accessibility Suite v2.0 — Panel CSS
 * Floating panel with tabs (WAI-ARIA APG pattern)
 */

/* ── Panel container ───────────────────────────────────────────── */
.a11y-panel {
    position: fixed;
    bottom: 6rem;
    right: 1.5rem;
    width: 340px;
    max-width: calc(100vw - 3rem);
    max-height: calc(100vh - 8rem);
    background: #fff;
    border-radius: 14px;
    box-shadow: 0 24px 60px rgba(0, 0, 0, 0.28);
    z-index: 10000;
    display: none;
    flex-direction: column;
    font-size: 0.9rem;
    overflow: hidden;
    border: 1px solid var(--border-light, #e2e8f0);
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
}
.a11y-panel.open { display: flex; animation: a11ySlideUp .2s ease; }
@keyframes a11ySlideUp {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

/* ── Header ────────────────────────────────────────────────────── */
.a11y-panel-header {
    background: linear-gradient(135deg, #4f46e5, #3730a3);
    color: #fff;
    padding: .85rem 1rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: .5rem;
}
.a11y-panel-header h2 {
    margin: 0; font-size: 1rem; font-weight: 600;
    display: flex; align-items: center; gap: .5rem;
}
.a11y-panel-header h2 i { font-size: 1.1rem; }
.a11y-close {
    background: transparent; border: 0; color: #fff; font-size: 1.5rem;
    line-height: 1; padding: 0; cursor: pointer; opacity: 0.85;
}
.a11y-close:hover { opacity: 1; }
.a11y-close:focus-visible { outline: 2px solid #facc15; outline-offset: 2px; border-radius: 4px; }

.a11y-panel-intro {
    padding: .5rem 1rem;
    background: #f8fafc;
    color: var(--text-secondary, #475569);
    font-size: .82rem;
    border-bottom: 1px solid var(--border-light, #e2e8f0);
}

/* ── Tabs ──────────────────────────────────────────────────────── */
.a11y-tabs {
    min-height: 40px;
    display: flex;
    overflow-x: auto;
    border-bottom: 1px solid var(--border-light, #e2e8f0);
    background: #f8fafc;
    scrollbar-width: thin;
}
.a11y-tab {
    flex: 0 0 auto;
    background: transparent;
    border: 0;
    padding: .6rem .7rem;
    font-size: .72rem;
    font-weight: 600;
    color: #64748b;
    cursor: pointer;
    border-bottom: 3px solid transparent;
    transition: all .15s;
    text-transform: uppercase;
    letter-spacing: .04em;
    white-space: nowrap;
    display: flex; align-items: center; gap: .3rem;
}
.a11y-tab i { font-size: .85rem; }
.a11y-tab[aria-selected="true"] { color: #4f46e5; border-bottom-color: #4f46e5; background: #fff; }
.a11y-tab:hover:not([aria-selected="true"]) { color: #1e293b; background: #eef2ff; }
.a11y-tab:focus-visible { outline: 3px solid #facc15; outline-offset: -3px; }
.a11y-tab-count { font-weight: 700; color: #4f46e5; }

/* ── Panel body ────────────────────────────────────────────────── */
.a11y-panel-body {
    padding: 1rem;
    overflow-y: auto;
    flex-grow: 1;
    scrollbar-width: thin;
}
.a11y-panel-loading {
    text-align: center;
    padding: 2rem;
    color: #64748b;
}
.a11y-tabpanel { animation: a11yFadeIn .15s ease; }
@keyframes a11yFadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

/* ── Section ───────────────────────────────────────────────────── */
.a11y-section { margin-bottom: 1.1rem; padding-bottom: .9rem; border-bottom: 1px solid #f1f5f9; }
.a11y-section:last-child { margin-bottom: 0; padding-bottom: 0; border-bottom: 0; }
.a11y-section > label {
    display: flex; align-items: center; gap: .4rem;
    font-weight: 700;
    font-size: .8rem;
    color: var(--text-primary, #0f172a);
    margin-bottom: .25rem;
    text-transform: uppercase;
    letter-spacing: .04em;
}
.a11y-section-desc {
    font-size: .8rem;
    color: var(--text-secondary, #475569);
    margin: 0 0 .55rem 0;
    line-height: 1.4;
}
.a11y-help {
    color: #94a3b8;
    cursor: help;
    font-size: .75rem;
    margin-left: auto;
    transition: color .15s;
}
.a11y-help:hover { color: #4f46e5; }
.a11y-help:focus-visible { outline: 2px solid #facc15; outline-offset: 2px; border-radius: 50%; }

/* ── Button group ──────────────────────────────────────────────── */
.a11y-btn-group {
    display: flex;
    gap: .3rem;
    flex-wrap: wrap;
}
.a11y-btn-group button {
    flex: 1 1 auto;
    min-width: 38px;
    background: #f1f5f9;
    border: 1.5px solid transparent;
    color: var(--text-primary, #0f172a);
    padding: .45rem .6rem;
    border-radius: 8px;
    font-weight: 600;
    font-size: .82rem;
    cursor: pointer;
    transition: all .15s ease;
    white-space: nowrap;
    font-family: inherit;
}
.a11y-btn-group button:hover { background: #e2e8f0; }
.a11y-btn-group button.active {
    background: #4f46e5;
    color: #fff;
    border-color: #3730a3;
    box-shadow: 0 2px 6px rgba(79, 70, 229, 0.35);
}
.a11y-btn-group button:focus-visible {
    outline: 3px solid #facc15;
    outline-offset: 2px;
}

/* ── Generic buttons ───────────────────────────────────────────── */
.a11y-btn {
    background: #f1f5f9;
    border: 1.5px solid transparent;
    color: var(--text-primary, #0f172a);
    padding: .5rem .85rem;
    border-radius: 8px;
    font-weight: 600;
    font-size: .85rem;
    cursor: pointer;
    transition: all .15s ease;
    font-family: inherit;
    display: inline-flex;
    align-items: center;
    gap: .4rem;
}
.a11y-btn:hover { background: #e2e8f0; }
.a11y-btn:focus-visible { outline: 3px solid #facc15; outline-offset: 2px; }
.a11y-btn-primary { background: #4f46e5; color: #fff; }
.a11y-btn-primary:hover { background: #4338ca; }
.a11y-btn-secondary { background: transparent; border-color: #cbd5e1; }
.a11y-btn-sm { padding: .3rem .55rem; font-size: .78rem; }
.a11y-btn-danger { background: #fee2e2; color: #b91c1c; }
.a11y-btn-danger:hover { background: #fecaca; }

.a11y-action-row {
    display: flex;
    gap: .4rem;
    flex-wrap: wrap;
    margin-bottom: .5rem;
}

/* Stop button: only visible while a TTS read is in progress */
[data-tts="stop"] { display: none; }
body.a11y-tts-active [data-tts="stop"] { display: inline-flex; }

/* ── Row + form controls ──────────────────────────────────────── */
.a11y-row {
    margin-top: .55rem;
    display: flex;
    flex-direction: column;
    gap: .3rem;
}
.a11y-row label { font-size: .8rem; color: var(--text-secondary, #475569); }
.a11y-input, .a11y-select {
    width: 100%;
    padding: .5rem .65rem;
    border: 1.5px solid var(--border-medium, #cbd5e1);
    border-radius: 8px;
    font-size: .85rem;
    font-family: inherit;
    background: #fff;
    color: var(--text-primary, #0f172a);
}
.a11y-input:focus, .a11y-select:focus {
    outline: 3px solid #facc15;
    border-color: #4f46e5;
}
input[type="range"] {
    width: 100%;
    accent-color: #4f46e5;
}
.a11y-warning {
    background: #fef3c7;
    color: #92400e;
    padding: .5rem .65rem;
    border-radius: 6px;
    font-size: .82rem;
    margin: .5rem 0;
    border: 1px solid #fde68a;
}

/* ── Profile cards ─────────────────────────────────────────────── */
.a11y-profile-list {
    display: flex;
    flex-direction: column;
    gap: .4rem;
    margin-bottom: .5rem;
}
.a11y-profile-card {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: .55rem .7rem;
    background: #f8fafc;
    border-radius: 8px;
    border: 1px solid #e2e8f0;
}
.a11y-profile-info { display: flex; align-items: center; gap: .4rem; font-size: .85rem; }
.a11y-profile-actions { display: flex; gap: .25rem; }
.a11y-badge {
    background: #ddd6fe;
    color: #5b21b6;
    font-size: .65rem;
    padding: .1rem .35rem;
    border-radius: 999px;
    text-transform: uppercase;
    font-weight: 700;
    letter-spacing: .04em;
}

/* ── Voice commands list ───────────────────────────────────────── */
.a11y-voice-cmds {
    list-style: none;
    padding: 0;
    margin: .5rem 0;
    font-size: .82rem;
    color: var(--text-secondary, #475569);
}
.a11y-voice-cmds li {
    padding: .25rem 0;
    border-bottom: 1px solid #f1f5f9;
}
.a11y-voice-cmds li:last-child { border-bottom: 0; }
.a11y-voice-cmds b { color: #4f46e5; font-weight: 600; }

/* ── Shortcuts table ───────────────────────────────────────────── */
.a11y-shortcuts {
    width: 100%;
    border-collapse: collapse;
    font-size: .82rem;
}
.a11y-shortcuts td {
    padding: .4rem .2rem;
    border-bottom: 1px solid #f1f5f9;
    color: var(--text-secondary, #475569);
}
.a11y-shortcuts td:first-child { width: 35%; }
kbd {
    display: inline-block;
    background: #f1f5f9;
    color: #1e293b;
    border: 1px solid #cbd5e1;
    border-bottom-width: 2px;
    border-radius: 4px;
    padding: 1px 6px;
    font-size: .75rem;
    font-family: 'SF Mono', Consolas, monospace;
    margin: 0 1px;
}

/* ── Footer ────────────────────────────────────────────────────── */
.a11y-panel-footer {
    padding: .65rem 1rem;
    border-top: 1px solid var(--border-light, #e2e8f0);
    display: flex;
    gap: .4rem;
    background: #f8fafc;
}
.a11y-panel-footer .a11y-btn { flex: 1; justify-content: center; font-size: .78rem; padding: .4rem .65rem; }

/* ── FAB badge ─────────────────────────────────────────────────── */
.a11y-active-badge {
    position: absolute;
    top: -3px;
    right: -3px;
    width: 12px;
    height: 12px;
    background: #10b981;
    border: 2px solid #fff;
    border-radius: 50%;
    display: none;
}
.has-active .a11y-active-badge { display: block; }

/* ── High contrast adjustments ─────────────────────────────────── */
body.a11y-contrast-high .a11y-panel {
    background: #000 !important;
    border: 2px solid #fff !important;
}
body.a11y-contrast-high .a11y-panel-body,
body.a11y-contrast-high .a11y-panel-intro { color: #fff !important; background: #000 !important; }
body.a11y-contrast-high .a11y-section > label { color: #ffd84d !important; }
body.a11y-contrast-high .a11y-section-desc { color: #fff !important; }
body.a11y-contrast-high .a11y-btn-group button {
    background: #1a1a1a !important; color: #fff !important; border-color: #444 !important;
}
body.a11y-contrast-high .a11y-btn-group button.active {
    background: #ffd84d !important; color: #000 !important; border-color: #fff !important;
}
body.a11y-contrast-high .a11y-btn {
    background: #1a1a1a !important; color: #fff !important; border-color: #fff !important;
}
body.a11y-contrast-high .a11y-btn-primary { background: #ffd84d !important; color: #000 !important; }
body.a11y-contrast-high .a11y-input, body.a11y-contrast-high .a11y-select {
    background: #000 !important; color: #fff !important; border-color: #fff !important;
}
body.a11y-contrast-high kbd { background: #1a1a1a !important; color: #fff !important; border-color: #fff !important; }
body.a11y-contrast-high .a11y-tab { color: #94a3b8 !important; }
body.a11y-contrast-high .a11y-tab[aria-selected="true"] { color: #ffd84d !important; border-bottom-color: #ffd84d !important; }
body.a11y-contrast-high .a11y-tabs { background: #1a1a1a !important; }

/* ── Dark skin ─────────────────────────────────────────────────── */
body.a11y-skin-dark .a11y-panel {
    background: #1e293b; color: #f1f5f9;
    border-color: #334155;
}
body.a11y-skin-dark .a11y-panel-intro { background: #0f172a; color: #cbd5e1; border-bottom-color: #334155; }
body.a11y-skin-dark .a11y-tabs { background: #0f172a; border-bottom-color: #334155; }
body.a11y-skin-dark .a11y-tab { color: #94a3b8; }
body.a11y-skin-dark .a11y-tab[aria-selected="true"] { color: #a5b4fc; border-bottom-color: #818cf8; background: #1e293b; }
body.a11y-skin-dark .a11y-tab:hover:not([aria-selected="true"]) { background: #1e293b; color: #f1f5f9; }
body.a11y-skin-dark .a11y-panel-body { background: #1e293b; }
body.a11y-skin-dark .a11y-section { border-bottom-color: #334155; }
body.a11y-skin-dark .a11y-section > label { color: #f1f5f9; }
body.a11y-skin-dark .a11y-section-desc { color: #cbd5e1; }
body.a11y-skin-dark .a11y-btn-group button { background: #334155; color: #f1f5f9; }
body.a11y-skin-dark .a11y-btn-group button:hover { background: #475569; }
body.a11y-skin-dark .a11y-btn-group button.active { background: #818cf8; color: #1e293b; border-color: #6366f1; }
body.a11y-skin-dark .a11y-btn { background: #334155; color: #f1f5f9; }
body.a11y-skin-dark .a11y-btn:hover { background: #475569; }
body.a11y-skin-dark .a11y-btn-secondary { background: transparent; border-color: #475569; }
body.a11y-skin-dark .a11y-input, body.a11y-skin-dark .a11y-select { background: #0f172a; color: #f1f5f9; border-color: #334155; }
body.a11y-skin-dark kbd { background: #334155; color: #f1f5f9; border-color: #475569; }
body.a11y-skin-dark .a11y-profile-card { background: #0f172a; border-color: #334155; }
body.a11y-skin-dark .a11y-panel-footer { background: #0f172a; border-top-color: #334155; }
body.a11y-skin-dark .a11y-shortcuts td { border-bottom-color: #334155; }
body.a11y-skin-dark .a11y-voice-cmds li { border-bottom-color: #334155; }

/* ── Sepia skin ────────────────────────────────────────────────── */
body.a11y-skin-sepia .a11y-panel {
    background: #f5e9c8; color: #3d2914;
    border-color: #d4b878;
}
body.a11y-skin-sepia .a11y-panel-intro { background: #e8d8a8; color: #5d4524; border-bottom-color: #d4b878; }
body.a11y-skin-sepia .a11y-tabs { background: #e8d8a8; border-bottom-color: #d4b878; }
body.a11y-skin-sepia .a11y-tab[aria-selected="true"] { color: #8b4513; border-bottom-color: #8b4513; background: #f5e9c8; }
body.a11y-skin-sepia .a11y-panel-body { background: #f5e9c8; }
body.a11y-skin-sepia .a11y-section { border-bottom-color: #d4b878; }
body.a11y-skin-sepia .a11y-btn-group button { background: #e8d8a8; color: #3d2914; }
body.a11y-skin-sepia .a11y-btn-group button.active { background: #8b4513; color: #f5e9c8; }
body.a11y-skin-sepia .a11y-btn { background: #e8d8a8; color: #3d2914; }
body.a11y-skin-sepia .a11y-input, body.a11y-skin-sepia .a11y-select { background: #fff8e0; color: #3d2914; border-color: #d4b878; }
body.a11y-skin-sepia .a11y-panel-footer { background: #e8d8a8; border-top-color: #d4b878; }
body.a11y-skin-sepia .a11y-profile-card { background: #e8d8a8; border-color: #d4b878; }

/* ── Responsive ────────────────────────────────────────────────── */
@media (max-width: 480px) {
    .a11y-panel {
        right: 0.5rem; left: 0.5rem; width: auto; bottom: 5rem;
        max-height: calc(100vh - 6rem);
    }
    .a11y-tab { padding: .55rem .55rem; font-size: .68rem; }
}
