/* =========================================================
   JAVO GLOBAL PLAYER — BASE LAYOUT
   Mobile-first structural CSS
========================================================= */

:root {
    --javo-mini-player-height: 72px;
    --javo-player-max-width: 720px;
}

/* ---------------------------------------------------------
   ROOT
--------------------------------------------------------- */

#javo_master_player {
    position: fixed;
    right: 0;
    bottom: 0;
    left: 0;
    z-index: 1000;

    display: block;
    visibility: visible;
    opacity: 1;
    pointer-events: none;

    direction: rtl;
    box-sizing: border-box;
}

#javo_master_player *,
#javo_master_player *::before,
#javo_master_player *::after {
    box-sizing: border-box;
}

/* جلوگیری از قرار گرفتن محتوای سایت زیر مینی پلیر */
body {
    padding-bottom:
        calc(
            var(--javo-mini-player-height) +
            env(safe-area-inset-bottom)
        );
}

/* ---------------------------------------------------------
   MINI PLAYER
--------------------------------------------------------- */

.javo-player-mini {
    position: relative;
    z-index: 3;

    display: grid;
    grid-template-columns: 52px minmax(0, 1fr) 44px 38px;
    align-items: center;
    gap: 10px;

    width: 100%;
    min-height: var(--javo-mini-player-height);

    padding:
        8px
        12px
        calc(8px + env(safe-area-inset-bottom));

    background: rgba(255, 255, 255, 0.96);
    border-top: 1px solid rgba(15, 23, 42, 0.1);
    box-shadow: 0 -6px 24px rgba(15, 23, 42, 0.08);

    pointer-events: auto;
}

/* کاور مینی پلیر */

.javo-player-mini-artwork {
    width: 52px;
    height: 52px;
    overflow: hidden;
    flex-shrink: 0;

    border-radius: 10px;
    background: #eef2f7;
}

.javo-player-mini-artwork img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* اطلاعات مینی پلیر */

.javo-player-mini-info {
    min-width: 0;
    overflow: hidden;
}

.javo-player-mini-channel,
.javo-player-mini-title {
    margin: 0;
    overflow: hidden;

    white-space: nowrap;
    text-overflow: ellipsis;
}

.javo-player-mini-channel {
    margin-bottom: 3px;

    color: #64748b;
    font-size: 11px;
    font-weight: 500;
}

.javo-player-mini-title {
    color: #0f172a;
    font-size: 13px;
    font-weight: 700;
    line-height: 1.5;
}

/* دکمه‌های مینی پلیر */

.javo-player-mini-play,
.javo-player-expand-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;

    padding: 0;
    margin: 0;

    color: #0f172a;
    background: transparent;
    border: 0;
    border-radius: 50%;

    cursor: pointer;
    appearance: none;
}

.javo-player-mini-play {
    width: 44px;
    height: 44px;

    background: #0f172a;
    color: #ffffff;
}

.javo-player-expand-button {
    width: 38px;
    height: 38px;
}

.javo-player-mini-play svg {
    width: 20px;
    height: 20px;
    fill: currentColor;
}

.javo-player-expand-button svg {
    width: 20px;
    height: 20px;
}

/* ---------------------------------------------------------
   BACKDROP
--------------------------------------------------------- */

.javo-player-backdrop {
    position: fixed;
    inset: 0;
    z-index: 1;

    background: rgba(15, 23, 42, 0.48);

    opacity: 0;
    visibility: hidden;
    pointer-events: none;

    transition:
        opacity 180ms ease,
        visibility 180ms ease;
}

/* ---------------------------------------------------------
   EXPANDED PLAYER
--------------------------------------------------------- */

.javo-player-expanded {
    position: fixed;
    right: 0;
    bottom: 0;
    left: 0;
    z-index: 2;

    width: 100%;
    max-height: calc(100dvh - 20px);

    overflow: hidden;

    background: #ffffff;
    border-radius: 22px 22px 0 0;
    box-shadow: 0 -18px 60px rgba(15, 23, 42, 0.2);

    transform: translateY(105%);
    visibility: hidden;
    pointer-events: none;

    transition:
        transform 240ms ease,
        visibility 240ms ease;
}

/* حالت باز پلیر — بعداً JS این کلاس را روی Root می‌گذارد */

#javo_master_player.is-expanded .javo-player-expanded {
    transform: translateY(0);
    visibility: visible;
    pointer-events: auto;
}

#javo_master_player.is-expanded .javo-player-backdrop {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
}

#javo_master_player.is-expanded .javo-player-mini {
    visibility: hidden;
    pointer-events: none;
}

/* ---------------------------------------------------------
   EXPANDED HEADER
--------------------------------------------------------- */

.javo-player-expanded-header {
    display: flex;
    align-items: center;
    justify-content: space-between;

    min-height: 54px;
    padding: 10px 16px;

    border-bottom: 1px solid rgba(15, 23, 42, 0.08);
}

.javo-player-expanded-eyebrow {
    color: #64748b;
    font-size: 12px;
    font-weight: 600;
}

.javo-player-close-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;

    width: 40px;
    height: 40px;
    padding: 0;

    color: #0f172a;
    background: transparent;
    border: 0;
    border-radius: 50%;

    cursor: pointer;
}

.javo-player-close-btn svg {
    width: 22px;
    height: 22px;
}

/* ---------------------------------------------------------
   EXPANDED SCROLL AREA
--------------------------------------------------------- */

.javo-player-expanded-scroll {
    display: flex;
    flex-direction: column;
    gap: 24px;

    max-height: calc(100dvh - 74px);
    padding:
        18px
        18px
        calc(24px + env(safe-area-inset-bottom));

    overflow-y: auto;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
}

.javo-player-expanded-primary,
.javo-player-expanded-secondary {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

/* ---------------------------------------------------------
   ARTWORK
--------------------------------------------------------- */

.javo-player-expanded-artwork {
    position: relative;

    width: min(68vw, 280px);
    aspect-ratio: 1;
    margin-inline: auto;

    overflow: hidden;
    border-radius: 20px;

    background: #eef2f7;
}

.javo-player-expanded-artwork img {
    position: relative;
    z-index: 1;

    display: block;
    width: 100%;
    height: 100%;

    object-fit: cover;
}

.javo-cover-ring-glow {
    position: absolute;
    inset: 0;
    z-index: 0;
}

/* ---------------------------------------------------------
   EPISODE INFORMATION
--------------------------------------------------------- */

.javo-player-expanded-info {
    min-width: 0;
    text-align: center;
}

.javo-player-channel-name,
.javo-player-episode-title {
    margin: 0;
}

.javo-player-channel-name {
    margin-bottom: 6px;

    color: #64748b;
    font-size: 13px;
    font-weight: 600;
}

.javo-player-episode-title {
    color: #0f172a;
    font-size: 18px;
    font-weight: 800;
    line-height: 1.65;
}

/* ---------------------------------------------------------
   TIMELINE
--------------------------------------------------------- */

.javo-timeline-container {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.javo-player-timeline-track,
.javo-waveform-wrapper {
    position: relative;
    width: 100%;
}

.javo-waveform-wrapper {
    height: 24px;
}

.javo-waveform-bg,
.javo-waveform-progress {
    position: absolute;
    top: 50%;
    right: 0;

    height: 4px;
    border-radius: 999px;

    transform: translateY(-50%);
}

.javo-waveform-bg {
    width: 100%;
    background: #dbe3ec;
}

.javo-waveform-progress {
    width: 0%;
    background: #0f172a;
}

#javo_seek {
    position: absolute;
    inset: 0;

    width: 100%;
    height: 24px;
    margin: 0;

    opacity: 0;
    cursor: pointer;
}

.javo-player-time-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}

.javo-player-time-item {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.javo-player-time-label {
    color: #94a3b8;
    font-size: 9px;
}

.javo-time-digit {
    color: #475569;
    font-size: 11px;
    font-variant-numeric: tabular-nums;
}

/* ---------------------------------------------------------
   PLAYBACK CONTROLS
--------------------------------------------------------- */

.javo-player-controls-zone {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 28px;
}

.javo-control-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;

    padding: 0;

    color: #0f172a;
    background: transparent;
    border: 0;
    border-radius: 50%;

    cursor: pointer;
}

.skip-btn {
    width: 46px;
    height: 46px;
}

.skip-btn svg {
    width: 32px;
    height: 32px;
}

.play-main-btn {
    position: relative;

    width: 68px;
    height: 68px;

    color: #ffffff;
    background: #0f172a;
}

.play-main-btn svg {
    width: 28px;
    height: 28px;
    fill: currentColor;
}

.play-btn-glow {
    position: absolute;
    inset: -5px;

    border-radius: inherit;
    border: 1px solid rgba(15, 23, 42, 0.14);

    pointer-events: none;
}

/* ---------------------------------------------------------
   SLEEP TIMER
--------------------------------------------------------- */

.javo-player-sleep-timer,
.javo-player-up-next {
    padding-top: 18px;
    border-top: 1px solid rgba(15, 23, 42, 0.08);
}

.javo-player-section-header h3,
.javo-player-up-next-header h3 {
    margin: 0;

    color: #0f172a;
    font-size: 15px;
    font-weight: 800;
}

.javo-sleep-timer-options {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;

    margin-top: 12px;
}

.javo-sleep-option {
    min-height: 42px;
    padding: 8px 10px;

    color: #334155;
    background: #f1f5f9;
    border: 1px solid transparent;
    border-radius: 10px;

    font: inherit;
    font-size: 12px;

    cursor: pointer;
}

.javo-sleep-option[aria-pressed="true"] {
    color: #0f172a;
    background: #b3e7ff;
    border-color: rgba(15, 23, 42, 0.12);
}

.javo-sleep-timer-status {
    margin: 10px 0 0;

    color: #64748b;
    font-size: 11px;
}

/* ---------------------------------------------------------
   UP NEXT
--------------------------------------------------------- */

.javo-player-up-next-header {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 12px;
}

.javo-player-section-eyebrow {
    display: block;
    margin-bottom: 4px;

    color: #94a3b8;
    font-size: 10px;
}

.javo-player-up-next-channel {
    color: #64748b;
    font-size: 11px;
}

.javo-player-up-next-list {
    display: flex;
    flex-direction: column;
    gap: 8px;

    margin-top: 12px;
}

.javo-player-up-next-empty,
.javo-player-up-next-error,
.javo-player-up-next-loading {
    margin: 0;
    padding: 14px;

    color: #64748b;
    background: #f8fafc;
    border-radius: 10px;

    font-size: 12px;
    text-align: center;
}

/* آیتم‌های Playlist که بعداً توسط JS ساخته می‌شوند */

.javo-up-next-item {
    margin: 0;
}

.javo-up-next-item-button {
    display: grid;
    grid-template-columns: 48px minmax(0, 1fr) 32px;
    align-items: center;
    gap: 10px;

    width: 100%;
    padding: 8px;

    color: inherit;
    text-align: right;

    background: #f8fafc;
    border: 0;
    border-radius: 12px;

    cursor: pointer;
}

.javo-up-next-item-artwork {
    width: 48px;
    height: 48px;
    overflow: hidden;

    border-radius: 8px;
    background: #eef2f7;
}

.javo-up-next-item-cover {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.javo-up-next-item-content {
    min-width: 0;
}

.javo-up-next-item-title {
    display: block;
    overflow: hidden;

    color: #0f172a;
    font-size: 12px;
    font-weight: 700;

    white-space: nowrap;
    text-overflow: ellipsis;
}

.javo-up-next-item-meta {
    display: flex;
    gap: 8px;

    margin-top: 4px;

    color: #64748b;
    font-size: 10px;
}

.javo-up-next-item-action {
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.javo-up-next-item-action svg {
    width: 18px;
    height: 18px;
    fill: currentColor;
}

/* ---------------------------------------------------------
   FOCUS
--------------------------------------------------------- */

#javo_master_player button:focus-visible,
#javo_master_player input:focus-visible {
    outline: 2px solid #0f172a;
    outline-offset: 3px;
}

/* ---------------------------------------------------------
   DESKTOP
--------------------------------------------------------- */

@media (min-width: 768px) {

    .javo-player-mini {
        width: min(100% - 32px, var(--javo-player-max-width));
        margin-inline: auto;
        margin-bottom: 16px;

        border: 1px solid rgba(15, 23, 42, 0.1);
        border-radius: 16px;
    }

    .javo-player-expanded {
        right: 50%;
        left: auto;

        width: min(94vw, 860px);
        max-height: calc(100dvh - 40px);

        border-radius: 24px 24px 0 0;

        transform: translate(50%, 105%);
    }

    #javo_master_player.is-expanded .javo-player-expanded {
        transform: translate(50%, 0);
    }

    .javo-player-expanded-scroll {
        padding-inline: 28px;
    }

    .javo-player-expanded-primary {
        max-width: 620px;
        width: 100%;
        margin-inline: auto;
    }

    .javo-player-expanded-artwork {
        width: 260px;
    }

    .javo-sleep-timer-options {
        grid-template-columns: repeat(4, minmax(0, 1fr));
    }
}