/* ==========================================================================
   FITUR NARRATOR & PEMBACA LAYAR DISABILITAS (ACCESSIBILITY SCREEN READER)
   Balai Kekarantinaan Kesehatan Kelas I Banda Aceh
   ========================================================================== */

/* 1. Tombol Top Bar Narrator */
.topbar-narrator-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: rgba(255, 255, 255, 0.15);
    border: 1px solid rgba(255, 255, 255, 0.3);
    color: #ffffff;
    padding: 3px 10px;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    margin-left: 8px;
}

.topbar-narrator-btn:hover {
    background: #00a7a0;
    border-color: #00a7a0;
    color: #ffffff;
    transform: translateY(-1px);
}

/* 2. Floating Launcher Button (Kiri Bawah & Draggable) */
.narrator-float-launcher {
    position: fixed;
    bottom: 28px;
    left: 28px;
    z-index: 9998;
    display: flex;
    align-items: center;
    gap: 10px;
    touch-action: none;
    user-select: none;
}

.narrator-float-launcher.is-dragging {
    cursor: grabbing !important;
    transition: none !important;
}

.narrator-float-launcher.is-dragging .narrator-launcher-btn {
    cursor: grabbing !important;
    transform: scale(1.08) !important;
    box-shadow: 0 12px 30px rgba(0, 167, 160, 0.65) !important;
}

.narrator-launcher-btn {
    width: 54px;
    height: 54px;
    border-radius: 50%;
    background: linear-gradient(135deg, #00a7a0 0%, #00877a 100%);
    border: 3px solid #ffffff;
    color: #ffffff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.45rem;
    cursor: grab;
    box-shadow: 0 4px 20px rgba(0, 167, 160, 0.45);
    transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    position: relative;
    outline: none;
    touch-action: none;
}

.narrator-launcher-btn:hover {
    transform: scale(1.1) translateY(-2px);
    box-shadow: 0 8px 25px rgba(0, 167, 160, 0.6);
}

.narrator-launcher-btn:active {
    cursor: grabbing;
}

.narrator-launcher-btn.speaking {
    animation: pulse-narrator 1.6s infinite ease-in-out;
}

@keyframes pulse-narrator {
    0%, 100% {
        box-shadow: 0 0 0 0 rgba(0, 167, 160, 0.7), 0 4px 20px rgba(0, 167, 160, 0.4);
    }
    50% {
        box-shadow: 0 0 0 14px rgba(0, 167, 160, 0), 0 6px 25px rgba(0, 167, 160, 0.6);
    }
}

.narrator-launcher-badge {
    position: absolute;
    top: -4px;
    right: -4px;
    background: #f08e20;
    color: #ffffff;
    font-size: 0.65rem;
    font-weight: 800;
    padding: 2px 6px;
    border-radius: 10px;
    border: 2px solid #ffffff;
    box-shadow: 0 2px 6px rgba(0,0,0,0.2);
}

.narrator-launcher-tooltip {
    background: #0f172a;
    color: #ffffff;
    padding: 6px 12px;
    border-radius: 8px;
    font-size: 0.8rem;
    font-weight: 600;
    white-space: nowrap;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    pointer-events: none;
    opacity: 0;
    transform: translateX(-8px);
    transition: all 0.25s ease;
}

.narrator-float-launcher:hover .narrator-launcher-tooltip {
    opacity: 1;
    transform: translateX(0);
}

.narrator-float-launcher.is-dragging .narrator-launcher-tooltip {
    opacity: 0 !important;
}

/* 3. Panel Kontrol Utama Narrator (Draggable Header) */
.narrator-panel {
    position: fixed;
    bottom: 92px;
    left: 28px;
    width: 360px;
    max-width: calc(100vw - 40px);
    background: #ffffff;
    border-radius: 18px;
    box-shadow: 0 16px 40px -8px rgba(15, 23, 42, 0.25), 0 0 0 1px rgba(15, 23, 42, 0.08);
    z-index: 9999;
    display: none;
    flex-direction: column;
    overflow: hidden;
    animation: slideUpNarrator 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    touch-action: pan-y;
}

.narrator-panel.open {
    display: flex;
}

.narrator-panel.is-dragging {
    transition: none !important;
    animation: none !important;
    user-select: none;
    box-shadow: 0 20px 50px -10px rgba(0, 167, 160, 0.38), 0 0 0 2px #00a7a0 !important;
}

@keyframes slideUpNarrator {
    from {
        opacity: 0;
        transform: translateY(16px) scale(0.96);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

/* Panel Header (Drag Handle) */
.narrator-panel-header {
    background: linear-gradient(135deg, #00a7a0 0%, #0f766e 100%);
    color: #ffffff;
    padding: 13px 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    cursor: grab;
    touch-action: none;
    user-select: none;
}

.narrator-panel-header:active,
.narrator-panel.is-dragging .narrator-panel-header {
    cursor: grabbing !important;
}

.narrator-header-title {
    display: flex;
    align-items: center;
    gap: 8px;
}

.narrator-drag-grip {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    opacity: 0.65;
    font-size: 0.95rem;
    cursor: grab;
    transition: opacity 0.2s, transform 0.2s;
    padding: 2px 4px;
}

.narrator-panel-header:hover .narrator-drag-grip {
    opacity: 1;
    transform: scale(1.1);
}

.narrator-header-title i.fa-volume-up {
    font-size: 1.15rem;
}

.narrator-header-text h3 {
    margin: 0;
    font-size: 0.92rem;
    font-weight: 800;
    line-height: 1.2;
}

.narrator-header-text span {
    font-size: 0.7rem;
    opacity: 0.9;
    font-weight: 500;
}

.narrator-header-actions {
    display: flex;
    align-items: center;
    gap: 6px;
}

.narrator-btn-icon,
.narrator-btn-close {
    background: rgba(255, 255, 255, 0.2);
    border: none;
    color: #ffffff;
    width: 28px;
    height: 28px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 0.8rem;
    transition: all 0.2s ease;
}

.narrator-btn-icon:hover {
    background: rgba(255, 255, 255, 0.35);
    transform: rotate(-90deg);
}

.narrator-btn-close:hover {
    background: rgba(255, 255, 255, 0.35);
    transform: scale(1.08);
}

/* Panel Status Bar & Visualizer */
.narrator-status-bar {
    background: #f8fafc;
    border-bottom: 1px solid #e2e8f0;
    padding: 10px 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.narrator-status-info {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.8rem;
    font-weight: 600;
    color: #475569;
    flex: 1;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
}

.narrator-status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #94a3b8;
    flex-shrink: 0;
}

.narrator-status-dot.active {
    background: #10b981;
    box-shadow: 0 0 8px #10b981;
}

.narrator-status-dot.paused {
    background: #f59e0b;
}

/* Audio Wave Animation */
.narrator-soundwave {
    display: flex;
    align-items: center;
    gap: 2.5px;
    height: 14px;
}

.narrator-soundwave span {
    display: inline-block;
    width: 2.5px;
    height: 4px;
    background: #00a7a0;
    border-radius: 2px;
    transition: height 0.15s ease;
}

.narrator-soundwave.animating span:nth-child(1) { animation: wave 0.8s infinite ease-in-out 0.1s; }
.narrator-soundwave.animating span:nth-child(2) { animation: wave 0.8s infinite ease-in-out 0.3s; }
.narrator-soundwave.animating span:nth-child(3) { animation: wave 0.8s infinite ease-in-out 0.2s; }
.narrator-soundwave.animating span:nth-child(4) { animation: wave 0.8s infinite ease-in-out 0.4s; }

@keyframes wave {
    0%, 100% { height: 4px; }
    50% { height: 14px; }
}

/* Panel Body */
.narrator-panel-body {
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 14px;
}

/* Playback Control Buttons */
.narrator-playback-btns {
    display: grid;
    grid-template-columns: 2fr 1.2fr 1fr;
    gap: 8px;
}

.btn-narrator-ctrl {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    padding: 10px 14px;
    border-radius: 10px;
    font-weight: 700;
    font-size: 0.875rem;
    border: none;
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn-narrator-play {
    background: #00a7a0;
    color: #ffffff;
    box-shadow: 0 4px 12px rgba(0, 167, 160, 0.3);
}

.btn-narrator-play:hover {
    background: #00877a;
    transform: translateY(-1px);
}

.btn-narrator-pause {
    background: #f1f5f9;
    color: #334155;
    border: 1px solid #cbd5e1;
}

.btn-narrator-pause:hover {
    background: #e2e8f0;
    color: #0f172a;
}

.btn-narrator-stop {
    background: #fee2e2;
    color: #dc2626;
    border: 1px solid #fca5a5;
}

.btn-narrator-stop:hover {
    background: #fecaca;
}

/* Section Options */
.narrator-setting-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.narrator-setting-label {
    font-size: 0.725rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: #64748b;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

/* Mode Switches */
.narrator-mode-toggles {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
}

.btn-mode-select {
    padding: 8px 10px;
    background: #f8fafc;
    border: 1px solid #cbd5e1;
    border-radius: 9px;
    font-size: 0.775rem;
    font-weight: 600;
    color: #475569;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    transition: all 0.2s ease;
}

.btn-mode-select:hover {
    border-color: #00a7a0;
    color: #00877a;
}

.btn-mode-select.active {
    background: #f0fdfa;
    border-color: #00a7a0;
    color: #00877a;
    box-shadow: 0 1px 4px rgba(0, 167, 160, 0.15);
}

/* Speed Controls */
.narrator-speed-pills {
    display: flex;
    align-items: center;
    gap: 6px;
}

.btn-speed-pill {
    flex: 1;
    padding: 6px 0;
    text-align: center;
    background: #f8fafc;
    border: 1px solid #cbd5e1;
    border-radius: 7px;
    font-size: 0.75rem;
    font-weight: 700;
    color: #475569;
    cursor: pointer;
    transition: all 0.15s ease;
}

.btn-speed-pill.active {
    background: #0f172a;
    border-color: #0f172a;
    color: #ffffff;
}

/* Read Selected Text Banner */
.narrator-selection-notice {
    background: #fffbeb;
    border: 1px solid #fde68a;
    border-radius: 10px;
    padding: 8px 12px;
    display: none;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    font-size: 0.775rem;
    color: #92400e;
}

.narrator-selection-notice.show {
    display: flex;
}

.btn-read-selection {
    background: #f59e0b;
    color: #ffffff;
    border: none;
    padding: 4px 8px;
    border-radius: 6px;
    font-weight: 700;
    font-size: 0.725rem;
    cursor: pointer;
    white-space: nowrap;
}

/* Panel Footer Help */
.narrator-panel-footer {
    background: #f8fafc;
    border-top: 1px solid #e2e8f0;
    padding: 8px 16px;
    font-size: 0.7rem;
    color: #64748b;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}

.narrator-drag-hint {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    color: #00877a;
    background: rgba(0, 167, 160, 0.08);
    padding: 2px 7px;
    border-radius: 12px;
    font-weight: 600;
    font-size: 0.68rem;
}

/* ==========================================================================
   4. HIGHLIGHT STYLING PADA KONTEN WEBSITE
   ========================================================================== */
.narrator-highlight {
    background: #fef08a !important; /* Soft yellow highlight */
    color: #0f172a !important;
    border-radius: 4px;
    box-shadow: 0 0 0 4px #fef08a;
    transition: background 0.25s ease;
}

/* Mode Klik & Dengar: Hover outline */
body.narrator-click-mode * {
    cursor: pointer !important;
}

.narrator-hoverable-target:hover {
    outline: 2px dashed #00a7a0 !important;
    outline-offset: 3px !important;
    background: rgba(0, 167, 160, 0.06) !important;
}

/* ==========================================================================
   5. RESPONSIVE FOR MOBILE (max-width: 768px)
   ========================================================================== */
@media (max-width: 768px) {
    .narrator-float-launcher {
        bottom: 22px;
        left: 20px;
    }

    .narrator-launcher-btn {
        width: 48px;
        height: 48px;
        font-size: 1.25rem;
    }

    .narrator-panel {
        left: 16px;
        bottom: 80px;
        width: calc(100vw - 32px);
    }

    .narrator-launcher-tooltip {
        display: none;
    }
}
