/* ==========================================================
   AUDIO SCREEN READER - RESPONSIVE ACCESSIBILITY WIDGET
   Standar Ditjen Badilum Mahkamah Agung RI & WCAG 2.0 AA
   ========================================================== */

/* 1. Highlight Visual untuk Elemen yang Sedang Dibaca (Karaoke Effect) */
.asr-highlight {
    background-color: #fef08a !important;
    color: #854d0e !important;
    outline: 3px solid #eab308 !important;
    outline-offset: 2px;
    border-radius: 4px;
    transition: background-color 0.25s ease, outline 0.25s ease;
    box-shadow: 0 0 12px rgba(234, 179, 8, 0.45);
}

body.high-contrast .asr-highlight {
    background-color: #ffff00 !important;
    color: #000000 !important;
    outline: 3px solid #ffffff !important;
}

/* 2. Floating Card / Popup Audio Screen Reader (Anchored above #asr-floating-btn) */
#asr-player-dock {
    position: fixed;
    bottom: 148px;
    left: 25px;
    width: 340px;
    max-width: calc(100vw - 32px);
    background: #ffffff;
    border-radius: 16px;
    border: 1.5px solid rgba(154, 33, 9, 0.2);
    box-shadow: 0 12px 35px rgba(0, 0, 0, 0.22);
    z-index: 99996;
    padding: 14px 16px;
    transform-origin: bottom left;
    transition: transform 0.28s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.25s ease;
    opacity: 0;
    transform: translateY(12px) scale(0.95);
    pointer-events: none;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    color: #1e293b;
}

#asr-player-dock.pos-right {
    left: auto;
    right: 25px;
    bottom: 218px;
    transform-origin: bottom right;
}

#asr-player-dock.active {
    opacity: 1;
    transform: translateY(0) scale(1);
    pointer-events: auto;
}

/* Jembatan hover tak terlihat agar pergerakan kursor mouse mulus antara tombol dan kartu */
#asr-player-dock::after {
    content: '';
    position: absolute;
    top: 100%;
    left: 0;
    width: 60px;
    height: 18px;
    pointer-events: auto;
}

#asr-player-dock.pos-right::after {
    left: auto;
    right: 0;
}

/* Header / Status Bar */
.asr-header-wrap {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    margin-bottom: 10px;
    padding-bottom: 8px;
    border-bottom: 1px solid #f1f5f9;
}

.asr-badge-brand {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 0.78rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--skt-maroon, #9A2109);
    background: #fee2e2;
    padding: 3px 9px;
    border-radius: 20px;
}

/* Animasi Equalizer Suara */
.asr-equalizer {
    display: inline-flex;
    align-items: flex-end;
    gap: 2px;
    height: 14px;
    width: 16px;
}

.asr-equalizer span {
    width: 3px;
    background-color: var(--skt-maroon, #9A2109);
    border-radius: 2px;
    height: 3px;
    transition: height 0.2s ease;
}

.asr-equalizer.playing span:nth-child(1) {
    animation: asrWave 0.8s ease-in-out infinite alternate;
}
.asr-equalizer.playing span:nth-child(2) {
    animation: asrWave 0.5s ease-in-out 0.15s infinite alternate;
}
.asr-equalizer.playing span:nth-child(3) {
    animation: asrWave 0.7s ease-in-out 0.3s infinite alternate;
}
.asr-equalizer.playing span:nth-child(4) {
    animation: asrWave 0.6s ease-in-out 0.2s infinite alternate;
}

@keyframes asrWave {
    0% { height: 3px; }
    100% { height: 14px; }
}

.asr-close-btn {
    background: transparent;
    border: none;
    color: #94a3b8;
    font-size: 1.1rem;
    cursor: pointer;
    padding: 4px 6px;
    line-height: 1;
    border-radius: 6px;
    transition: all 0.2s ease;
}

.asr-close-btn:hover {
    color: #ef4444;
    background: #fee2e2;
}

/* Status Bar Realtime */
.asr-status-bar {
    display: flex;
    align-items: center;
    gap: 7px;
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    padding: 6px 10px;
    margin-bottom: 10px;
}

.asr-status-icon {
    font-size: 0.85rem;
    color: var(--skt-maroon, #9A2109);
    flex-shrink: 0;
}

.asr-status-text {
    font-size: 0.78rem;
    color: #475569;
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    line-height: 1.3;
}

/* Mode Auto Read & Auto Sorot Switch Box */
.asr-mode-card {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    background: #f8fafc;
    border: 1.5px solid #e2e8f0;
    border-radius: 10px;
    padding: 9px 12px;
    margin-bottom: 12px;
    cursor: pointer;
    user-select: none;
    transition: all 0.2s ease;
}

.asr-mode-card:hover {
    background: #f1f5f9;
    border-color: #cbd5e1;
    transform: translateY(-1px);
}

.asr-mode-card:focus-visible {
    outline: 2px solid var(--skt-gold, #FF9900);
    outline-offset: 2px;
}

.asr-mode-card.active {
    background: #f0fdf4;
    border-color: #86efac;
    box-shadow: 0 2px 8px rgba(34, 197, 94, 0.15);
}

.asr-mode-info {
    flex: 1;
    min-width: 0;
    pointer-events: none;
}

.asr-mode-title {
    font-size: 0.82rem;
    font-weight: 700;
    color: #1e293b;
    display: flex;
    align-items: center;
    gap: 6px;
}

.asr-mode-title i {
    color: var(--skt-maroon, #9A2109);
    font-size: 0.85rem;
    transition: color 0.2s ease;
}

.asr-mode-card.active .asr-mode-title {
    color: #15803d;
}

.asr-mode-card.active .asr-mode-title i {
    color: #16a34a;
}

.asr-mode-desc {
    font-size: 0.71rem;
    color: #64748b;
    line-height: 1.25;
    margin-top: 2px;
}

.asr-mode-toggle {
    flex-shrink: 0;
    pointer-events: none;
}

.asr-toggle-pill {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 10px;
    font-weight: 800;
    letter-spacing: 0.5px;
    padding: 4px 10px;
    border-radius: 20px;
    transition: all 0.2s ease;
    pointer-events: none;
}

.asr-toggle-pill.badge-off {
    background: #64748b;
    color: #ffffff;
}

.asr-toggle-pill.badge-on {
    background: #16a34a;
    color: #ffffff;
    box-shadow: 0 2px 6px rgba(22, 163, 74, 0.4);
}

/* Kontrol Navigasi & Pemutaran Suara */
.asr-controls-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    margin-bottom: 10px;
}

.asr-playback-buttons {
    display: flex;
    align-items: center;
    gap: 6px;
}

.asr-btn {
    border: none;
    outline: none;
    cursor: pointer;
    background: #f1f5f9;
    color: #1e293b;
    border-radius: 50%;
    width: 36px;
    height: 36px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 0.95rem;
    transition: all 0.2s ease;
}

.asr-btn:hover {
    background: #e2e8f0;
    color: var(--skt-maroon, #9A2109);
    transform: scale(1.06);
}

.asr-btn-play {
    width: 42px;
    height: 42px;
    background: linear-gradient(135deg, var(--skt-maroon, #9A2109) 0%, var(--skt-maroon-dark, #7B201F) 100%);
    color: #ffffff;
    font-size: 1.2rem;
    box-shadow: 0 4px 12px rgba(154, 33, 9, 0.35);
}

.asr-btn-play:hover {
    background: linear-gradient(135deg, #b92b0b 0%, #8c1906 100%);
    color: #ffffff;
    transform: scale(1.08);
}

.asr-btn-stop {
    background: #fee2e2;
    color: #b91c1c;
}
.asr-btn-stop:hover {
    background: #fecaca;
    color: #991b1b;
}

.asr-options-group {
    display: flex;
    align-items: center;
}

.asr-pill-btn {
    background: #f8fafc;
    border: 1px solid #cbd5e1;
    border-radius: 18px;
    padding: 5px 10px;
    font-size: 0.76rem;
    font-weight: 600;
    color: #334155;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    transition: all 0.2s ease;
}

.asr-pill-btn:hover {
    border-color: var(--skt-gold, #FF9900);
    color: var(--skt-maroon, #9A2109);
    background: #ffffff;
}

.asr-speed-badge {
    min-width: 22px;
    text-align: center;
}

/* Hint Pintasan Keyboard */
.asr-shortcut-hint {
    font-size: 10px;
    color: #94a3b8;
    text-align: center;
    border-top: 1px solid #f1f5f9;
    padding-top: 7px;
    line-height: 1.3;
}

.asr-shortcut-hint kbd {
    background: #e2e8f0;
    color: #475569;
    border-radius: 3px;
    padding: 1px 4px;
    font-size: 9.5px;
    font-family: inherit;
    border: 1px solid #cbd5e1;
}

/* 3. Floating Mini Tooltip untuk Seleksi Teks */
#asr-selection-tooltip {
    position: absolute;
    display: none;
    z-index: 100001;
    background: #1e293b;
    color: #ffffff;
    padding: 6px 14px;
    border-radius: 24px;
    font-size: 0.78rem;
    font-weight: 600;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
    cursor: pointer;
    transform: translate(-50%, -100%);
    margin-top: -12px;
    white-space: nowrap;
    align-items: center;
    gap: 8px;
    transition: transform 0.15s ease, opacity 0.15s ease;
    border: 1.5px solid var(--skt-gold, #FF9900);
    user-select: none;
}

#asr-selection-tooltip::after {
    content: '';
    position: absolute;
    bottom: -6px;
    left: 50%;
    transform: translateX(-50%);
    border-width: 6px 6px 0 6px;
    border-style: solid;
    border-color: #1e293b transparent transparent transparent;
}

#asr-selection-tooltip:hover {
    background: var(--skt-maroon, #9A2109);
    color: #ffffff;
    transform: translate(-50%, -105%) scale(1.04);
}

#asr-selection-tooltip:hover::after {
    border-color: var(--skt-maroon, #9A2109) transparent transparent transparent;
}

#asr-selection-tooltip .asr-tt-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.18);
    width: 18px;
    height: 18px;
    border-radius: 50%;
    margin-left: 2px;
    font-size: 11px;
}

/* 4. In-Article Audio Screen Reader Player Card */
.article-audio-player {
    background: linear-gradient(135deg, #fdfbf7 0%, #fff6ec 100%);
    border: 1.5px solid var(--skt-gold, #FF9900);
    border-radius: 12px;
    padding: 12px 18px;
    margin: 18px 0 24px 0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    box-shadow: 0 3px 10px rgba(255, 153, 0, 0.08);
}

.article-audio-info {
    display: flex;
    align-items: center;
    gap: 12px;
}

.article-audio-icon {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: var(--skt-maroon, #9A2109);
    color: #ffffff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.3rem;
    flex-shrink: 0;
    box-shadow: 0 4px 8px rgba(154, 33, 9, 0.25);
}

.article-audio-title {
    font-size: 0.92rem;
    font-weight: 700;
    color: #1e293b;
    margin-bottom: 2px;
}

.article-audio-subtitle {
    font-size: 0.78rem;
    color: #64748b;
}

.article-audio-action {
    display: flex;
    align-items: center;
    gap: 8px;
}

/* 5. Indikator Mode Hover Aktif di Seluruh Halaman */
body.asr-hover-mode-active * {
    cursor: help !important;
}

body.asr-hover-mode-active .asr-hover-target {
    outline: 2px dashed #eab308 !important;
    outline-offset: 2px;
    background-color: rgba(254, 240, 138, 0.35) !important;
}

/* 6. Penyesuaian Responsif Layar Mobile */
@media (max-width: 768px) {
    #asr-player-dock {
        bottom: 134px;
        left: 20px;
        width: 320px;
        max-width: calc(100vw - 40px);
        padding: 12px 14px;
        border-radius: 14px;
    }

    #asr-player-dock.pos-right {
        left: auto;
        right: 20px;
        bottom: 198px;
    }

    .asr-header-wrap {
        margin-bottom: 8px;
        padding-bottom: 6px;
    }

    .asr-mode-card {
        padding: 7px 10px;
        margin-bottom: 10px;
    }

    .asr-status-text {
        font-size: 0.74rem;
    }

    .asr-controls-row {
        gap: 6px;
    }

    .asr-btn {
        width: 34px;
        height: 34px;
        font-size: 0.88rem;
    }

    .asr-btn-play {
        width: 38px;
        height: 38px;
        font-size: 1.05rem;
    }

    .asr-pill-btn {
        padding: 4px 8px;
        font-size: 0.72rem;
    }

    .article-audio-player {
        flex-direction: column;
        align-items: stretch;
        gap: 12px;
        padding: 12px;
    }

    .article-audio-action {
        justify-content: flex-end;
    }
}

@media (max-width: 576px) {
    #asr-player-dock {
        bottom: 122px;
        left: 16px;
        width: calc(100vw - 32px);
        max-width: 320px;
        padding: 10px 12px;
    }

    #asr-player-dock.pos-right {
        left: auto;
        right: 16px;
        bottom: 182px;
    }
}

/* Penyesuaian High Contrast untuk Seluruh Elemen Audio Reader */
body.high-contrast #asr-player-dock {
    background: #000000 !important;
    border-color: #ffff00 !important;
    box-shadow: 0 0 16px #ffff00 !important;
    color: #ffff00 !important;
}

body.high-contrast #asr-player-dock .asr-mode-card {
    background: #111111 !important;
    border-color: #ffff00 !important;
    color: #ffff00 !important;
}

body.high-contrast #asr-player-dock .asr-mode-card.active {
    background: #222222 !important;
    border-color: #ffff00 !important;
}

body.high-contrast #asr-player-dock .asr-mode-title,
body.high-contrast #asr-player-dock .asr-mode-desc,
body.high-contrast #asr-player-dock .asr-status-text {
    color: #ffff00 !important;
}

body.high-contrast #asr-player-dock .asr-status-bar {
    background: #111111 !important;
    border-color: #ffff00 !important;
}

body.high-contrast #asr-player-dock .asr-badge-brand,
body.high-contrast #asr-player-dock .asr-pill-btn {
    color: #ffff00 !important;
    background: #111111 !important;
    border-color: #ffff00 !important;
}

body.high-contrast #asr-player-dock .asr-btn {
    background: #111111 !important;
    color: #ffff00 !important;
    border: 1px solid #ffff00 !important;
}

body.high-contrast #asr-player-dock .asr-btn-play {
    background: #ffff00 !important;
    color: #000000 !important;
}

body.high-contrast #asr-player-dock .asr-toggle-pill.badge-on {
    background: #ffff00 !important;
    color: #000000 !important;
}

body.high-contrast #asr-player-dock .asr-toggle-pill.badge-off {
    background: #333333 !important;
    color: #ffffff !important;
    border: 1px solid #ffff00 !important;
}

body.high-contrast .article-audio-player {
    background: #000000 !important;
    border-color: #ffff00 !important;
}

body.high-contrast .article-audio-title,
body.high-contrast .article-audio-subtitle {
    color: #ffff00 !important;
}

/* ==========================================================
   FLOATING BUTTON - MODE AUTO READ & AUTO SOROT
   ========================================================== */
#asr-floating-btn {
    position: fixed;
    bottom: 88px;
    left: 25px;
    z-index: 99994;
    width: 52px;
    height: 52px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--skt-maroon, #9A2109) 0%, var(--skt-maroon-dark, #7B201F) 100%);
    color: #ffffff;
    border: 2.5px solid #ffffff;
    box-shadow: 0 4px 18px rgba(154, 33, 9, 0.45);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.25s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    text-decoration: none;
    outline: none;
    padding: 0;
    user-select: none;
}

#asr-floating-btn * {
    pointer-events: none;
}

#asr-floating-btn.pos-right {
    left: auto;
    right: 25px;
    bottom: 158px;
}

#asr-floating-btn:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 24px rgba(154, 33, 9, 0.65);
    background: linear-gradient(135deg, #b92b0b 0%, #8c1906 100%);
    color: #ffffff;
}

#asr-floating-btn:focus-visible {
    outline: 3px solid #ffcc00;
    outline-offset: 3px;
}

/* Icon & Gelombang Suara */
.asr-float-icon-wrap {
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    width: 28px;
    height: 28px;
}

.asr-float-icon {
    font-size: 1.35rem;
    line-height: 1;
    color: #ffffff;
    transition: transform 0.2s ease;
}

.asr-float-waves {
    display: none;
    align-items: flex-end;
    gap: 2px;
    height: 12px;
    position: absolute;
    right: -6px;
    bottom: 0;
}

.asr-float-waves span {
    width: 2.5px;
    background-color: #ffffff;
    border-radius: 2px;
    height: 3px;
    animation: asrWaveAnim 0.9s ease-in-out infinite alternate;
}

.asr-float-waves span:nth-child(1) { animation-delay: 0.1s; }
.asr-float-waves span:nth-child(2) { animation-delay: 0.3s; }
.asr-float-waves span:nth-child(3) { animation-delay: 0.2s; }

@keyframes asrWaveAnim {
    0% { height: 3px; }
    100% { height: 12px; }
}

/* Badge ON / OFF Status */
.asr-float-badge {
    position: absolute;
    top: -4px;
    right: -4px;
    font-size: 9px;
    font-weight: 800;
    padding: 1.5px 5.5px;
    border-radius: 10px;
    line-height: 1.1;
    border: 1.5px solid #ffffff;
    letter-spacing: 0.5px;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.25);
    transition: all 0.2s ease;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

.asr-float-badge.badge-off {
    background-color: #475569;
    color: #f8fafc;
}

.asr-float-badge.badge-on {
    background-color: #ffffff;
    color: #15803d;
}

/* STATE: ACTIVE (MODE AUTO READ & AUTO SOROT AKTIF) */
#asr-floating-btn.active {
    background: linear-gradient(135deg, #16a34a 0%, #15803d 100%);
    box-shadow: 0 0 0 4px rgba(34, 197, 94, 0.35), 0 6px 24px rgba(22, 163, 74, 0.6);
    border-color: #ffffff;
}

#asr-floating-btn.active:hover {
    background: linear-gradient(135deg, #22c55e 0%, #16a34a 100%);
    transform: scale(1.1);
}

#asr-floating-btn.active .asr-float-waves,
#asr-floating-btn.playing .asr-float-waves {
    display: inline-flex;
}

#asr-floating-btn.active::after {
    content: '';
    position: absolute;
    inset: -4px;
    border-radius: 50%;
    border: 2px solid #22c55e;
    animation: asrPulseRing 1.8s cubic-bezier(0.24, 0, 0.38, 1) infinite;
    pointer-events: none;
}

@keyframes asrPulseRing {
    0% { transform: scale(0.95); opacity: 0.8; }
    50% { transform: scale(1.25); opacity: 0; }
    100% { transform: scale(1.25); opacity: 0; }
}

/* Tooltip Hover Tag (Desktop) */
.asr-float-tooltip {
    position: absolute;
    left: calc(100% + 12px);
    top: 50%;
    transform: translateY(-50%) translateX(-8px);
    background: rgba(15, 23, 42, 0.94);
    backdrop-filter: blur(4px);
    color: #ffffff;
    padding: 5px 11px;
    border-radius: 6px;
    font-size: 11.5px;
    font-weight: 600;
    white-space: nowrap;
    opacity: 0;
    pointer-events: none;
    transition: all 0.2s ease;
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.25);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

.asr-float-tooltip::before {
    content: '';
    position: absolute;
    right: 100%;
    top: 50%;
    transform: translateY(-50%);
    border-width: 5px;
    border-style: solid;
    border-color: transparent rgba(15, 23, 42, 0.94) transparent transparent;
}

#asr-floating-btn.pos-right .asr-float-tooltip {
    left: auto;
    right: calc(100% + 12px);
    transform: translateY(-50%) translateX(8px);
}

#asr-floating-btn.pos-right .asr-float-tooltip::before {
    right: auto;
    left: 100%;
    border-color: transparent transparent transparent rgba(15, 23, 42, 0.94);
}

#asr-floating-btn:hover .asr-float-tooltip {
    opacity: 1;
    transform: translateY(-50%) translateX(0);
}

/* Responsif Tablet & Ponsel */
@media (max-width: 768px) {
    #asr-floating-btn {
        width: 48px;
        height: 48px;
        bottom: 78px;
        left: 20px;
    }
    #asr-floating-btn.pos-right {
        right: 20px;
        bottom: 142px;
    }
    .asr-float-tooltip {
        display: none !important;
    }
}

@media (max-width: 576px) {
    #asr-floating-btn {
        width: 44px;
        height: 44px;
        bottom: 70px;
        left: 16px;
    }
    #asr-floating-btn.pos-right {
        right: 16px;
        bottom: 130px;
    }
    .asr-float-icon {
        font-size: 1.15rem;
    }
}

/* High Contrast mode */
body.high-contrast #asr-floating-btn {
    background: #000000 !important;
    border-color: #ffff00 !important;
    color: #ffff00 !important;
}
body.high-contrast #asr-floating-btn.active {
    background: #ffff00 !important;
    color: #000000 !important;
    box-shadow: 0 0 16px #ffff00 !important;
}
body.high-contrast #asr-floating-btn .asr-float-badge {
    background: #ffff00 !important;
    color: #000000 !important;
    border-color: #000000 !important;
}

