/* ==========================================================
   Nexora TTS — compact WhatsApp-style voice player (RTL)
   Prefix: nexora-tts-
   Desktop: single full-width row | Mobile: compact stack
   ========================================================== */

.nexora-tts-player{
    --nexora-tts-bg:var(--surface,#FFFFFF);
    --nexora-tts-bg-2:var(--surface-alt,#F1F4F9);
    --nexora-tts-text:var(--text,#101828);
    --nexora-tts-muted:var(--text-muted,#94A0B4);
    --nexora-tts-accent:var(--primary,#2563EB);
    --nexora-tts-accent-2:var(--accent,#3B82F6);
    --nexora-tts-wave:#C5CDD8;
    --nexora-tts-wave-on:var(--accent,#3B82F6);
    --nexora-tts-chip:rgba(16,24,40,.04);
    --nexora-tts-chip-border:var(--border,#E7EAF0);
    --nexora-tts-shadow:var(--shadow-sm);
    direction:rtl;
    position:relative;
    width:100%;
    max-width:100%;
    margin:0 0 16px;
    padding:8px 12px;
    border-radius:14px;
    background:
        radial-gradient(120% 80% at 100% 0%,rgba(37,99,235,.08),transparent 55%),
        linear-gradient(160deg,var(--nexora-tts-bg) 0%,var(--nexora-tts-bg-2) 100%);
    color:var(--nexora-tts-text);
    box-shadow:var(--nexora-tts-shadow);
    border:1px solid var(--nexora-tts-chip-border);
    font-family:"Noto Naskh Arabic","Poppins",sans-serif;
    display:flex;
    flex-wrap:nowrap;
    align-items:center;
    gap:8px;
    min-height:48px;
    overflow-x:auto;
    -webkit-overflow-scrolling:touch;
    scrollbar-width:none;
    opacity:1;
    transition:opacity .2s ease,box-shadow .25s ease,background .25s ease,color .25s ease,border-color .25s ease;
}

body.dark-mode .nexora-tts-player{
    --nexora-tts-bg:#0F172A;
    --nexora-tts-bg-2:#1E293B;
    --nexora-tts-text:#F8FAFC;
    --nexora-tts-muted:#94A3B8;
    --nexora-tts-accent:#3B82F6;
    --nexora-tts-accent-2:#60A5FA;
    --nexora-tts-wave:#475569;
    --nexora-tts-wave-on:#38BDF8;
    --nexora-tts-chip:rgba(15,23,42,.45);
    --nexora-tts-chip-border:rgba(148,163,184,.2);
    --nexora-tts-shadow:var(--shadow-sm);
    background:
        radial-gradient(120% 80% at 100% 0%,rgba(59,130,246,.18),transparent 55%),
        linear-gradient(160deg,var(--nexora-tts-bg) 0%,var(--nexora-tts-bg-2) 100%);
}

.nexora-tts-player::-webkit-scrollbar{
    display:none;
}

.nexora-tts-player.is-booting{
    opacity:.72;
}

.nexora-tts-player.is-complete{
    box-shadow:0 0 0 1px rgba(34,197,94,.45),var(--shadow-sm);
}

.nexora-tts-head{
    display:flex;
    align-items:center;
    gap:6px;
    flex:0 0 auto;
    margin:0;
}

.nexora-tts-langs{
    display:inline-flex;
    align-items:center;
    gap:4px;
    flex:0 0 auto;
    padding:2px;
    border-radius:999px;
    background:var(--nexora-tts-chip);
    border:1px solid var(--nexora-tts-chip-border);
}

.nexora-tts-lang{
    min-height:26px;
    min-width:34px;
    padding:2px 8px;
    border:0;
    border-radius:999px;
    background:transparent;
    color:var(--nexora-tts-muted);
    font-size:10px;
    font-weight:700;
    font-family:"Poppins","Noto Naskh Arabic",sans-serif;
    line-height:1;
}

.nexora-tts-lang.is-active{
    background:rgba(59,130,246,.28);
    color:var(--nexora-tts-text);
}

.nexora-tts-title{
    display:inline-flex;
    align-items:center;
    gap:5px;
    font-size:12px;
    font-weight:700;
    white-space:nowrap;
}

.nexora-tts-title i{
    color:var(--nexora-tts-accent-2);
    font-size:11px;
}

.nexora-tts-stop{
    width:28px;
    height:28px;
    min-width:28px;
    border:0;
    border-radius:50%;
    background:var(--nexora-tts-chip);
    color:var(--nexora-tts-text);
    display:inline-flex;
    align-items:center;
    justify-content:center;
    font-size:10px;
    flex:0 0 auto;
    transition:background .2s ease,transform .15s ease,opacity .15s ease;
}

.nexora-tts-stop.is-idle{
    opacity:0;
    pointer-events:none;
}

.nexora-tts-stop:not(.is-idle):hover{
    filter:brightness(0.97);
}

body.dark-mode .nexora-tts-stop:not(.is-idle):hover{
    background:rgba(248,250,252,.16);
    filter:none;
}

/* Absolute overlay — never wraps / shifts the main row */
.nexora-tts-status{
    position:absolute;
    left:12px;
    right:12px;
    bottom:calc(100% + 4px);
    margin:0;
    padding:5px 10px;
    border-radius:8px;
    font-size:11px;
    line-height:1.35;
    color:var(--nexora-tts-text);
    background:var(--nexora-tts-bg);
    border:1px solid var(--nexora-tts-chip-border);
    box-shadow:var(--nexora-tts-shadow);
    z-index:3;
    pointer-events:none;
    opacity:0;
    transform:translateY(4px);
    transition:opacity .18s ease,transform .18s ease;
}

.nexora-tts-status.is-visible,
.nexora-tts-status:not([hidden]){
    display:block;
}

.nexora-tts-player.has-status .nexora-tts-status{
    opacity:1;
    transform:translateY(0);
}

.nexora-tts-status[hidden]{
    display:none !important;
}

.nexora-tts-status.is-error{
    color:#FECACA;
    border-color:rgba(248,113,113,.45);
}

.nexora-tts-row{
    display:flex;
    align-items:center;
    gap:8px;
    flex:1 1 auto;
    min-width:0;
    overflow:hidden;
}

.nexora-tts-tools{
    display:inline-flex;
    align-items:center;
    gap:6px;
    flex:0 0 auto;
    flex-shrink:0;
    position:relative;
    z-index:2;
}

.nexora-tts-play{
    width:36px;
    height:36px;
    min-width:36px;
    border:0;
    border-radius:50%;
    background:linear-gradient(145deg,var(--nexora-tts-accent),#1D4ED8);
    color:#fff;
    display:inline-flex;
    align-items:center;
    justify-content:center;
    font-size:12px;
    box-shadow:0 4px 12px rgba(37,99,235,.3);
    flex:0 0 auto;
    transition:transform .15s ease,filter .2s ease;
}

.nexora-tts-play:hover{
    filter:brightness(1.06);
}

.nexora-tts-play:active{
    transform:scale(.96);
}

.nexora-tts-play.is-playing{
    background:linear-gradient(145deg,#0EA5E9,#0369A1);
}

.nexora-tts-play.is-finished{
    background:linear-gradient(145deg,#22C55E,#15803D);
}

.nexora-tts-play:disabled{
    opacity:.45;
    cursor:not-allowed;
    box-shadow:none;
}

.nexora-tts-wave{
    appearance:none;
    border:0;
    background:transparent;
    padding:4px 0;
    margin:0;
    min-height:32px;
    cursor:pointer;
    flex:1 1 auto;
    min-width:48px;
    width:auto;
}

.nexora-tts-wave-track{
    display:flex;
    align-items:center;
    justify-content:space-between;
    gap:1.5px;
    height:22px;
    width:100%;
}

.nexora-tts-bar{
    flex:1 1 0;
    min-width:1.5px;
    max-width:4px;
    height:var(--nexora-tts-h,40%);
    border-radius:99px;
    background:var(--nexora-tts-wave);
    opacity:.55;
    transition:background .2s ease,opacity .2s ease,transform .2s ease;
    transform-origin:center;
}

.nexora-tts-bar.is-active{
    background:var(--nexora-tts-wave-on);
    opacity:1;
}

.nexora-tts-player.is-playing .nexora-tts-bar.is-now{
    animation:nexora-tts-pulse 900ms ease-in-out infinite;
}

@keyframes nexora-tts-pulse{
    0%,100%{ transform:scaleY(1); }
    50%{ transform:scaleY(1.3); }
}

@media (prefers-reduced-motion:reduce){
    .nexora-tts-player.is-playing .nexora-tts-bar.is-now{
        animation:none;
    }
}

.nexora-tts-meta{
    display:flex;
    flex-direction:row;
    align-items:center;
    gap:6px;
    flex:0 0 auto;
    flex-shrink:0;
    min-width:0;
    direction:ltr;
}

.nexora-tts-time{
    display:inline-flex;
    flex-direction:row;
    align-items:center;
    gap:0;
    direction:ltr;
    unicode-bidi:isolate;
    font-size:10px;
    font-variant-numeric:tabular-nums;
    font-feature-settings:"tnum" 1;
    color:var(--nexora-tts-muted);
    font-family:"Poppins",sans-serif;
    white-space:nowrap;
    min-width:7.2em;
    justify-content:flex-start;
    letter-spacing:0;
}

.nexora-tts-elapsed,
.nexora-tts-total{
    display:inline-block;
    min-width:2.6em;
    text-align:left;
    font-variant-numeric:tabular-nums;
    unicode-bidi:isolate;
}

.nexora-tts-time-sep{
    opacity:.7;
    padding:0 2px;
    flex:0 0 auto;
}

.nexora-tts-speed{
    min-width:34px;
    min-height:24px;
    padding:2px 7px;
    border-radius:999px;
    border:1px solid var(--nexora-tts-chip-border);
    background:var(--nexora-tts-chip);
    color:var(--nexora-tts-text);
    font-size:10px;
    font-weight:600;
    font-family:"Poppins",sans-serif;
    direction:ltr;
    unicode-bidi:isolate;
    flex:0 0 auto;
    flex-shrink:0;
    position:relative;
    z-index:1;
}

.nexora-tts-speed:hover{
    border-color:var(--nexora-tts-accent-2);
}

.nexora-tts-vol{
    display:inline-flex;
    align-items:center;
    gap:5px;
    flex:0 0 auto;
    flex-shrink:0;
    padding:2px 8px;
    border-radius:999px;
    background:var(--nexora-tts-chip);
    border:1px solid var(--nexora-tts-chip-border);
    direction:ltr;
}

.nexora-tts-vol-range{
    -webkit-appearance:none;
    appearance:none;
    width:56px;
    height:4px;
    border-radius:99px;
    background:var(--nexora-tts-wave);
    outline:none;
    cursor:pointer;
    accent-color:var(--nexora-tts-accent);
}

.nexora-tts-vol-range::-webkit-slider-thumb{
    -webkit-appearance:none;
    appearance:none;
    width:12px;
    height:12px;
    border-radius:50%;
    background:var(--nexora-tts-accent);
    border:0;
    cursor:pointer;
}

.nexora-tts-vol-range::-moz-range-thumb{
    width:12px;
    height:12px;
    border-radius:50%;
    background:var(--nexora-tts-accent);
    border:0;
    cursor:pointer;
}

.nexora-tts-vol-icon{
    font-size:11px;
    color:var(--nexora-tts-accent-2);
    width:14px;
    text-align:center;
}

.nexora-tts-voices{
    display:inline-flex;
    align-items:center;
    gap:3px;
    flex:0 0 auto;
    flex-shrink:0;
    width:auto;
    margin:0;
    padding:2px;
    border-radius:999px;
    background:var(--nexora-tts-chip);
    border:1px solid var(--nexora-tts-chip-border);
}

.nexora-tts-voice{
    position:relative;
    min-height:28px;
    min-width:28px;
    width:28px;
    border-radius:50%;
    border:0;
    background:transparent;
    color:var(--nexora-tts-muted);
    font-size:11px;
    font-weight:600;
    display:inline-flex;
    align-items:center;
    justify-content:center;
    gap:0;
    padding:0;
    overflow:hidden;
    white-space:nowrap;
    transition:background .2s ease,color .2s ease;
}

.nexora-tts-voice-label{
    position:absolute;
    width:1px;
    height:1px;
    padding:0;
    margin:-1px;
    overflow:hidden;
    clip:rect(0,0,0,0);
    white-space:nowrap;
    border:0;
}

.nexora-tts-voice i{
    font-size:12px;
    color:inherit;
    opacity:1;
}

.nexora-tts-voice.is-active{
    background:rgba(59,130,246,.35);
    color:var(--nexora-tts-text);
    box-shadow:none;
}

.nexora-tts-voice:hover{
    color:var(--nexora-tts-text);
}

/* Paragraph highlight while reading */
.article-content p.tts-reading,
#article-body p.tts-reading{
    background:rgba(59,130,246,.14);
    box-shadow:inset 3px 0 0 var(--primary);
    border-radius:8px;
    transition:background .25s ease,box-shadow .25s ease;
}

body.dark-mode .article-content p.tts-reading,
body.dark-mode #article-body p.tts-reading{
    background:rgba(96,165,250,.16);
    box-shadow:inset 3px 0 0 var(--accent);
}

/* Mobile: two clean rows — no overlay */
@media (max-width:720px){
    .nexora-tts-player{
        flex-wrap:wrap;
        padding:8px 10px;
        gap:8px;
        margin-bottom:12px;
        overflow:visible;
    }

    .nexora-tts-head{
        width:auto;
        justify-content:flex-start;
    }

    .nexora-tts-title{
        font-size:0;
        gap:0;
    }

    .nexora-tts-title i{
        font-size:12px;
    }

    .nexora-tts-row{
        flex:1 1 100%;
        width:100%;
        min-width:0;
        gap:8px;
        overflow:hidden;
        order:1;
    }

    .nexora-tts-langs{
        order:2;
    }

    .nexora-tts-tools{
        flex:1 1 auto;
        justify-content:flex-end;
        flex-wrap:nowrap;
        gap:6px;
        order:3;
        min-width:0;
        overflow:visible;
    }

    .nexora-tts-voices{
        width:auto;
        flex:0 0 auto;
        display:inline-flex;
        gap:2px;
    }

    .nexora-tts-voice{
        min-height:26px;
        min-width:26px;
        width:26px;
    }

    .nexora-tts-play{
        width:32px;
        height:32px;
        min-width:32px;
        font-size:11px;
    }

    .nexora-tts-stop{
        width:26px;
        height:26px;
        min-width:26px;
    }

    .nexora-tts-wave{
        min-width:0;
        min-height:28px;
        flex:1 1 auto;
    }

    .nexora-tts-wave-track{
        height:18px;
    }

    .nexora-tts-time{
        font-size:9px;
        min-width:0;
    }

    .nexora-tts-elapsed,
    .nexora-tts-total{
        min-width:2.2em;
    }

    .nexora-tts-speed{
        min-width:32px;
        min-height:26px;
        font-size:10px;
        padding:2px 8px;
    }

    .nexora-tts-vol-range{
        width:40px;
    }
}
