/* ============================================================
   ChatIA Player — barra minimalista con velocidad
   ============================================================ */

#chatia-player {
    position: fixed;
    bottom: 16px;
    left: 50%;
    transform: translate(-50%, 0);
    z-index: 9999;
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 7px 10px 7px 8px;
    height: 42px;
    background: rgba(255, 255, 255, 0.92);
    backdrop-filter: blur(14px) saturate(180%);
    -webkit-backdrop-filter: blur(14px) saturate(180%);
    border: 1px solid rgba(0, 0, 0, 0.08);
    border-radius: 999px;
    box-shadow: 0 6px 24px -8px rgba(0, 0, 0, 0.25), 0 2px 6px -2px rgba(0, 0, 0, 0.1);
    color: #1a1a1a;
    font-family: inherit;
    font-size: 12px;
    white-space: nowrap;
    transition: transform .25s cubic-bezier(.4,0,.2,1), opacity .25s;
    min-width: 280px;
    max-width: calc(100vw - 32px);
}
#chatia-player.chatia-hidden {
    transform: translate(-50%, 80px);
    opacity: 0;
    pointer-events: none;
}

.chatia-play-btn {
    width: 28px;
    height: 28px;
    flex: 0 0 28px;
    border-radius: 50%;
    border: none;
    background: #1a1a1a;
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: transform .15s, background .15s;
    padding: 0;
}
.chatia-play-btn:hover  { transform: scale(1.08); }
.chatia-play-btn:active { transform: scale(0.95); }
.chatia-play-btn svg    { width: 12px; height: 12px; }

.chatia-progress-wrap {
    display: flex;
    align-items: center;
    gap: 8px;
    flex: 1 1 auto;
    min-width: 0;
}
.chatia-bar {
    flex: 1 1 auto;
    height: 3px;
    background: rgba(0, 0, 0, 0.1);
    border-radius: 2px;
    cursor: pointer;
    position: relative;
    overflow: hidden;
    min-width: 60px;
}
.chatia-bar-fill {
    height: 100%;
    background: #1a1a1a;
    width: 0%;
    transition: width .1s linear;
    border-radius: 2px;
}
.chatia-time {
    font-variant-numeric: tabular-nums;
    font-size: 11px;
    color: #666;
    min-width: 36px;
    text-align: right;
    user-select: none;
}

/* ─── Botón velocidad ─── */
.chatia-speed-btn {
    border: none;
    background: rgba(0,0,0,0.06);
    color: #1a1a1a;
    font: 600 11px inherit;
    font-variant-numeric: tabular-nums;
    padding: 3px 8px;
    border-radius: 999px;
    cursor: pointer;
    transition: background .15s, transform .1s;
    min-width: 36px;
    text-align: center;
}
.chatia-speed-btn:hover  { background: rgba(0,0,0,0.12); }
.chatia-speed-btn:active { transform: scale(0.95); }

.chatia-close {
    width: 22px;
    height: 22px;
    flex: 0 0 22px;
    border: none;
    background: transparent;
    color: #999;
    cursor: pointer;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    transition: background .15s, color .15s;
}
.chatia-close:hover { background: rgba(0,0,0,0.08); color: #1a1a1a; }
.chatia-close svg   { width: 11px; height: 11px; }

.chatia-spinner {
    width: 12px;
    height: 12px;
    border: 2px solid rgba(255,255,255,0.3);
    border-top-color: #fff;
    border-radius: 50%;
    animation: chatia-spin .8s linear infinite;
}
@keyframes chatia-spin { to { transform: rotate(360deg); } }

.chatia-loading-state .chatia-bar,
.chatia-loading-state .chatia-time {
    visibility: hidden;
}
.chatia-loading-state .chatia-progress-wrap::before {
    content: "Generando audio…";
    flex: 1;
    color: #888;
    font-size: 11px;
    font-style: italic;
}

#chatia-player.chatia-error-state {
    background: rgba(254, 226, 226, 0.95);
    border-color: rgba(220, 38, 38, 0.3);
}
#chatia-player.chatia-error-state .chatia-progress-wrap::before {
    content: "Error al generar el audio";
    flex: 1;
    color: #b91c1c;
    font-size: 11px;
}
#chatia-player.chatia-error-state .chatia-play-btn { background: #b91c1c; }

/* ═══════════ TEMA OSCURO ═══════════ */
@media (prefers-color-scheme: dark) {
    #chatia-player {
        background: rgba(28, 28, 30, 0.92);
        border-color: rgba(255, 255, 255, 0.1);
        color: #f5f5f5;
    }
    .chatia-play-btn { background: #f5f5f5; color: #1a1a1a; }
    .chatia-bar { background: rgba(255,255,255,0.15); }
    .chatia-bar-fill { background: #f5f5f5; }
    .chatia-time { color: #aaa; }
    .chatia-speed-btn { background: rgba(255,255,255,0.1); color: #f5f5f5; }
    .chatia-speed-btn:hover { background: rgba(255,255,255,0.18); }
    .chatia-close { color: #888; }
    .chatia-close:hover { background: rgba(255,255,255,0.1); color: #fff; }
    .chatia-spinner { border-color: rgba(0,0,0,0.3); border-top-color: #1a1a1a; }
}
body.dark-theme #chatia-player, [data-theme="dark"] #chatia-player {
    background: rgba(28, 28, 30, 0.92);
    border-color: rgba(255, 255, 255, 0.1);
    color: #f5f5f5;
}
body.dark-theme .chatia-play-btn, [data-theme="dark"] .chatia-play-btn { background: #f5f5f5; color: #1a1a1a; }
body.dark-theme .chatia-bar, [data-theme="dark"] .chatia-bar { background: rgba(255,255,255,0.15); }
body.dark-theme .chatia-bar-fill, [data-theme="dark"] .chatia-bar-fill { background: #f5f5f5; }
body.dark-theme .chatia-time, [data-theme="dark"] .chatia-time { color: #aaa; }
body.dark-theme .chatia-speed-btn, [data-theme="dark"] .chatia-speed-btn { background: rgba(255,255,255,0.1); color: #f5f5f5; }
body.dark-theme .chatia-close, [data-theme="dark"] .chatia-close { color: #888; }

@media (max-width: 600px) {
    #chatia-player {
        bottom: calc(env(safe-area-inset-bottom, 0px) + 12px);
        min-width: 0;
        width: auto;                  /* se ajusta al contenido */
        max-width: calc(100vw - 32px);
        padding: 8px 10px;
        height: 48px;
        gap: 8px;
        font-size: 12px;
    }
    .chatia-play-btn { width: 36px; height: 36px; flex: 0 0 36px; }
    .chatia-play-btn svg { width: 16px; height: 16px; }
    .chatia-bar { min-width: 70px; max-width: 100px; }
    .chatia-time { font-size: 11px; min-width: 32px; }
    .chatia-speed-btn {
        font-size: 12px;
        font-weight: 600;
        padding: 4px 10px;
        min-width: 38px;
        height: 28px;
    }
    .chatia-close { width: 30px; height: 30px; flex: 0 0 30px; }
    .chatia-close svg { width: 14px; height: 14px; }
}

/* ============================================================
   Panel ajustes — sección "Voz"
   ============================================================ */

#settings-voice .voice-list-header {
    font-size: 13px;
    color: var(--text-secondary, #666);
    margin: 0 0 14px;
    line-height: 1.5;
}

.voice-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.voice-filter-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 12px;
    background: var(--bg-secondary, #fafafa);
    border: 1px solid var(--border, #e5e5e5);
    border-radius: 8px;
    font-size: 12px;
    margin-bottom: 4px;
}
.voice-toggle {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    user-select: none;
    color: var(--text-primary, #1a1a1a);
}
.voice-toggle input { margin: 0; cursor: pointer; }
.voice-count {
    color: var(--text-secondary, #888);
    font-size: 11px;
}
.voice-loading, .voice-error {
    padding: 24px;
    text-align: center;
    color: var(--text-secondary, #888);
    font-size: 13px;
}
.voice-error { color: #b91c1c; }

.voice-card {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 12px 14px;
    background: var(--bg-secondary, #fafafa);
    border: 1px solid var(--border, #e5e5e5);
    border-radius: 10px;
    transition: border-color .15s, background .15s;
}
.voice-card.selected {
    border-color: #1a1a1a;
    background: rgba(0,0,0,0.02);
}
.voice-card.is-fav {
    background: rgba(255, 209, 102, 0.08);
    border-color: rgba(255, 209, 102, 0.5);
}
.voice-card.is-fav.selected {
    border-color: #d97706;
    background: rgba(255, 209, 102, 0.15);
}

.voice-btn-fav {
    width: 32px;
    height: 32px;
    flex-shrink: 0;
    border: none;
    background: transparent;
    color: #ccc;
    font-size: 20px;
    cursor: pointer;
    border-radius: 6px;
    padding: 0;
    transition: color .15s, background .15s, transform .1s;
    line-height: 1;
}
.voice-btn-fav:hover {
    background: rgba(0,0,0,0.04);
    color: #f59e0b;
}
.voice-btn-fav:active { transform: scale(0.9); }
.voice-card.is-fav .voice-btn-fav { color: #f59e0b; }
.voice-card-main {
    flex: 1 1 auto;
    min-width: 0;
}
.voice-card-name {
    font-weight: 600;
    font-size: 14px;
    color: var(--text-primary, #1a1a1a);
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}
.voice-badge {
    display: inline-block;
    padding: 1px 8px;
    border-radius: 999px;
    background: rgba(0,0,0,0.06);
    color: #555;
    font-size: 10px;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}
.voice-badge-active {
    background: #1a1a1a;
    color: #fff;
}
.voice-card-meta {
    font-size: 12px;
    color: var(--text-secondary, #666);
    margin-top: 3px;
}
.voice-card-lang {
    font-size: 11px;
    color: var(--text-muted, #999);
    margin-top: 2px;
    text-transform: uppercase;
    letter-spacing: 0.4px;
}
.voice-card-actions {
    display: flex;
    flex-direction: column;
    gap: 6px;
    flex-shrink: 0;
}
.voice-btn-preview, .voice-btn-select {
    padding: 6px 14px;
    border-radius: 6px;
    border: 1px solid var(--border, #e5e5e5);
    background: #fff;
    color: var(--text-primary, #1a1a1a);
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    transition: background .15s, border-color .15s;
    white-space: nowrap;
}
.voice-btn-preview:hover {
    background: var(--bg-hover, #f5f5f5);
    border-color: #1a1a1a;
}
.voice-btn-select {
    background: #1a1a1a;
    color: #fff;
    border-color: #1a1a1a;
}
.voice-btn-select:hover:not(:disabled) {
    background: #333;
}
.voice-btn-select.is-selected,
.voice-btn-select:disabled {
    background: rgba(0,0,0,0.05);
    color: #888;
    border-color: var(--border, #e5e5e5);
    cursor: default;
}

@media (max-width: 600px) {
    .voice-card { flex-direction: column; align-items: stretch; }
    .voice-card-actions { flex-direction: row; }
    .voice-btn-preview, .voice-btn-select { flex: 1; }
}

@media (prefers-color-scheme: dark) {
    .voice-card { background: #1f1f1f; border-color: #333; }
    .voice-card.selected { border-color: #f5f5f5; background: rgba(255,255,255,0.02); }
    .voice-card-name { color: #f5f5f5; }
    .voice-card-meta { color: #aaa; }
    .voice-card-lang { color: #777; }
    .voice-badge { background: rgba(255,255,255,0.1); color: #ccc; }
    .voice-badge-active { background: #f5f5f5; color: #1a1a1a; }
    .voice-btn-preview { background: #2a2a2a; color: #f5f5f5; border-color: #444; }
    .voice-btn-preview:hover { background: #333; border-color: #f5f5f5; }
    .voice-btn-select { background: #f5f5f5; color: #1a1a1a; border-color: #f5f5f5; }
    .voice-btn-select.is-selected { background: rgba(255,255,255,0.08); color: #888; border-color: #444; }
}
