/* ==========================================================================
CYBER HUD - AUDIO RECORDER PANEL & PLAYER HUD
========================================================================== */

.audio-recorder-panel {
    background: rgba(3, 10, 25, 0.95);
    border: 1px solid var(--hud-panel-border);
    border-radius: 4px;
    padding: 12px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    min-height: 0;
    height: 100%;
    box-sizing: border-box;
    overflow: hidden;
}

.audio-control-row {
    display: flex;
    align-items: center;
    gap: 10px;
}

.audio-tool-grid {
    display: grid;
    grid-template-columns: minmax(280px, 1fr) minmax(300px, 1.1fr);
    gap: 8px;
    min-height: 0;
    flex: 1;
}

.audio-single-panel {
    gap: 8px;
    padding: 10px;
}

.audio-top-controls {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
}

.audio-top-controls .audio-file-status,
.audio-top-controls #live-translate-status {
    max-width: 22%;
}

.audio-tool-block {
    min-width: 0;
    min-height: 0;
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 10px;
    border: 1px solid var(--hud-panel-border);
    border-radius: 4px;
    background: rgba(3, 10, 25, 0.55);
}

.audio-utility-panel {
    min-width: 0;
}

.audio-utility-row {
    display: flex;
    align-items: center;
    gap: 8px;
}

.audio-utility-row .audio-file-status {
    flex: 1;
}

.audio-tool-heading {
    display: flex;
    align-items: center;
    gap: 7px;
    color: var(--hud-cyan);
    font: 0.75rem 'Share Tech Mono', monospace;
    letter-spacing: 0.04em;
}

.audio-button-group {
    display: flex;
    gap: 8px;
}

.audio-file-status {
    min-height: 1.2rem;
    overflow: hidden;
    color: var(--hud-text-secondary, #8b9bb4);
    font: 0.72rem 'Share Tech Mono', monospace;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* 修正：在 live-controls 內的檔名狀態要可被 flex 壓縮，
   並給一個明確的像素上限，避免長檔名撐開整個 live-controls
   觸發外層 wrap 把兩個開關擠到第二行。完整檔名仍可透過 title hover 查看。 */
.audio-live-controls .audio-file-status {
    flex: 0 1 auto;
    min-width: 0;
    max-width: 12rem;
}

.audio-text-output {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    padding: 8px;
    border: 1px dashed rgba(0, 243, 255, 0.16);
    background: rgba(2, 5, 12, 0.72);
    color: #d8faff;
    font-size: 0.78rem;
    line-height: 1.35;
    white-space: pre-wrap;
}

.audio-live-controls {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 12px;
}

/* 翻譯機呼吸燈：取代原本的「翻譯器關閉」文字提示 */
.live-translate-indicator {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    flex-shrink: 0;
    transition: background-color 0.25s ease, box-shadow 0.25s ease;
}

.live-translate-indicator .live-dot {
    display: block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: rgba(139, 155, 180, 0.35);
    box-shadow: 0 0 0 1px rgba(139, 155, 180, 0.25);
    transition: background-color 0.25s ease, box-shadow 0.25s ease;
}

/* 連線中 / 運作中：青色呼吸 */
.live-translate-indicator[data-state="connecting"] .live-dot,
.live-translate-indicator[data-state="running"] .live-dot {
    background: var(--hud-cyan, #00f3ff);
    box-shadow: 0 0 6px var(--hud-cyan, #00f3ff), 0 0 12px rgba(0, 243, 255, 0.6);
    animation: liveDotPulse 1.4s ease-in-out infinite;
}

/* 錯誤狀態：紅色 */
.live-translate-indicator[data-state="error"] .live-dot {
    background: var(--hud-red, #ff3e3e);
    box-shadow: 0 0 6px var(--hud-red, #ff3e3e);
}

@keyframes liveDotPulse {
    0%, 100% { opacity: 0.55; transform: scale(0.85); }
    50%      { opacity: 1;    transform: scale(1.1); }
}

.shared-audio-display {
    position: relative;
    flex: 1 1 0;
    min-height: 40px;
    border: 1px dashed rgba(0, 243, 255, 0.16);
    background: rgba(2, 5, 12, 0.72);
    overflow: hidden;
}

.shared-audio-display .visualizer-container {
    width: 100%;
    height: 100%;
    border: 0;
    border-radius: 0;
}

.shared-audio-display .visualizer-container[hidden],
.shared-audio-display .audio-text-output[hidden] {
    display: none;
}

.shared-audio-display .audio-text-output {
    height: 100%;
    box-sizing: border-box;
    border: 0;
}

.hud-switch-label {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    color: #b9c7d9;
    font-size: 0.72rem;
    white-space: nowrap;
}

.glow-red-rec {
    border-color: rgba(255, 62, 62, 0.4);
}

.glow-red-rec:hover, .hud-icon-btn.active-rec {
    color: #fff;
    background-color: var(--hud-red) !important;
    border-color: var(--hud-red) !important;
    box-shadow: var(--hud-red-glow), 0 0 15px rgba(255, 62, 62, 0.4) !important;
}

/* 錄音呼吸燈動畫 */
.pulse {
    animation: textPulse 1.5s infinite alternate;
}

@keyframes textPulse {
    from { opacity: 0.6; text-shadow: 0 0 2px var(--hud-red); }
    to { opacity: 1; text-shadow: var(--hud-red-glow), 0 0 8px rgba(255,62,62,0.8); }
}

.visualizer-container {
    border: 1px dashed rgba(0, 243, 255, 0.15);
    background: rgba(2, 5, 12, 0.8);
    height: 100%;
    min-height: 40px;
    border-radius: 4px;
    overflow: hidden;
    display: flex;
    align-items: center;
}

#audio-visualizer {
    display: block;
}

#record-pause:disabled, #record-stop:disabled {
    opacity: 0.3;
    cursor: not-allowed;
    border-color: rgba(0, 243, 255, 0.05);
}

#audio-transcribe-btn:disabled {
    opacity: 0.35;
    cursor: not-allowed;
}

/* HUD 內置音訊播放控制列補齊樣式 */
.audio-playback-row {
    display: flex;
    align-items: center;
    gap: 10px;
    background: rgba(0, 243, 255, 0.03);
    border: 1px solid rgba(0, 243, 255, 0.1);
    padding: 6px 10px;
    border-radius: 4px;
    flex-shrink: 0;
    margin-top: 5px;
}

.audio-progress-container {
    flex: 1;
    height: 6px;
    background: rgba(3, 10, 25, 0.9);
    border: 1px solid rgba(0, 243, 255, 0.15);
    border-radius: 3px;
    cursor: pointer;
    position: relative;
    overflow: hidden;
}

#audio-progress-bar {
    width: 0%;
    height: 100%;
    background: linear-gradient(90deg, var(--hud-blue), var(--hud-cyan));
    box-shadow: var(--hud-cyan-glow);
    border-radius: 3px;
    transition: width 0.1s linear;
}

#audio-time-display {
    font-size: 0.75rem;
    color: var(--hud-cyan);
    white-space: nowrap;
    text-shadow: var(--hud-cyan-glow);
}

@media (max-width: 900px) {
    .audio-tool-grid {
        grid-template-columns: 1fr;
        overflow-y: auto;
    }

    .audio-tool-block {
        min-height: 150px;
    }
}

@media (max-width: 620px) {
    .audio-tool-grid {
        grid-template-columns: 1fr;
    }

    .audio-utility-row {
        align-items: stretch;
        flex-direction: column;
    }

    .audio-top-controls .audio-file-status,
    .audio-top-controls #live-translate-status {
        max-width: 100%;
    }
}