/* ============================================================
   style.css - واجهة إذاعة رضوان (Neumorphism + ألوان الشعار)
   الخط: Baloo Bhaijaan 2 | يدعم السمة الفاتحة والداكنة
   ============================================================ */

:root {
    /* ألوان الشعار */
    --purple: #9585c7;
    --teal:   #3fc8b3;
    --green:  #3fc961;
    --blue:   #67aac4;
    --brand:  linear-gradient(135deg, var(--purple), var(--teal) 55%, var(--green));

    /* السمة الفاتحة */
    --bg:       #e9ece4;
    --surface:  #f2eee3;
    --surface2: #f7e9d3;
    --text:     #1e2530;
    --muted:    #6b7280;
    --sh-dark:  rgba(150, 140, 115, .38);
    --sh-light: rgba(255, 255, 255, .95);
    --danger:   #e5484d;
    --amber:    #f5a524;

    --raise:    7px 7px 16px var(--sh-dark), -7px -7px 16px var(--sh-light);
    --raise-sm: 4px 4px 10px var(--sh-dark), -4px -4px 10px var(--sh-light);
    --inset:    inset 4px 4px 9px var(--sh-dark), inset -4px -4px 9px var(--sh-light);
    color-scheme: light;
}

:root[data-theme="dark"] {
    --bg:       #14171c;
    --surface:  #1c2027;
    --surface2: #232830;
    --text:     #eef2f7;
    --muted:    #9aa4b2;
    --sh-dark:  rgba(0, 0, 0, .6);
    --sh-light: rgba(255, 255, 255, .045);
    color-scheme: dark;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
[hidden] { display: none !important; }

html { background: var(--bg); }

body {
    margin: 0;
    min-height: 100vh;
    color: var(--text);
    font-family: "Baloo Bhaijaan 2", "Segoe UI", Tahoma, "Noto Sans Arabic", Arial, sans-serif;
    line-height: 1.5;
    background:
        radial-gradient(700px 420px at 100% 0%, rgba(63, 201, 97, .16), transparent 65%),
        radial-gradient(700px 480px at 0% 100%, rgba(149, 133, 199, .20), transparent 65%),
        radial-gradient(500px 360px at 50% 40%, rgba(63, 200, 179, .10), transparent 70%),
        var(--bg);
    background-attachment: fixed;
    transition: background-color .3s, color .3s;
}

button { font: inherit; color: inherit; cursor: pointer; }
a { color: inherit; }
button:focus-visible, a:focus-visible, input:focus-visible {
    outline: 3px solid var(--teal);
    outline-offset: 3px;
}

/* أيقونات SVG */
.ic {
    width: 24px; height: 24px; flex: none;
    fill: none; stroke: currentColor; stroke-width: 2;
    stroke-linecap: round; stroke-linejoin: round;
}

/* ============================================================
   الهيكل العام
   ============================================================ */
.app {
    width: 100%;
    max-width: 540px;
    min-height: 100vh;
    margin: 0 auto;
    padding: max(14px, env(safe-area-inset-top)) 16px 0;
    display: flex;
    flex-direction: column;
}

@media (min-width: 640px) {
    body { padding: 26px 0; }
    .app {
        min-height: calc(100vh - 52px);
        padding-top: 20px;
        border-radius: 40px;
        background: color-mix(in srgb, var(--surface) 55%, transparent);
        border: 1px solid color-mix(in srgb, var(--text) 8%, transparent);
        box-shadow: 0 30px 80px rgba(0, 0, 0, .18);
    }
}

/* ---------------- الشريط العلوي ---------------- */
.topbar {
    display: grid;
    grid-template-columns: 52px 1fr 52px;
    align-items: center;
    gap: 12px;
    margin-bottom: 18px;
}

.title-pill {
    margin: 0;
    padding: 8px 18px;
    text-align: center;
    font-size: 1.45rem;
    font-weight: 800;
    line-height: 1.5;
    border-radius: 999px;
    background: var(--surface2);
    box-shadow: var(--raise-sm);
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

/* أزرار بارزة دائرية */
.neu-btn {
    display: inline-flex; align-items: center; justify-content: center;
    border: 0;
    color: var(--text);
    background: var(--surface);
    box-shadow: var(--raise-sm);
    transition: box-shadow .15s, transform .15s, opacity .2s;
}
.neu-btn:hover { transform: translateY(-1px); }
.neu-btn:active { box-shadow: var(--inset); transform: none; }
.neu-btn.round { width: 52px; height: 52px; border-radius: 50%; }
.neu-btn.round.sm { width: 44px; height: 44px; }
.neu-btn:disabled { opacity: .4; cursor: not-allowed; transform: none; }

#themeBtn .ic-moon { display: none; }
:root[data-theme="dark"] #themeBtn .ic-sun { display: none; }
:root[data-theme="dark"] #themeBtn .ic-moon { display: block; }
#themeBtn .ic-sun { color: #f59e0b; }
#reloadBtn.spin .ic { animation: spin .8s linear; }
@keyframes spin { to { transform: rotate(360deg); } }

.content { flex: 1; }

/* ---------------- التبويبات ---------------- */
.tab { display: none; padding-bottom: 24px; }
.tab.active { display: block; animation: fade .35s ease; }
@keyframes fade { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

/* ============================================================
   الرئيسية
   ============================================================ */
.hero {
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    align-items: center;
    gap: 10px;
    margin-bottom: 22px;
}

/* بطاقة المستمعين */
.mini-card {
    justify-self: start;
    display: flex; flex-direction: column; align-items: center; gap: 2px;
    padding: 14px 12px;
    min-width: 96px;
    border-radius: 22px;
    background: var(--surface);
    box-shadow: var(--raise-sm);
    color: var(--muted);
    font-size: .8rem;
    text-align: center;
}
.mini-card .ic { color: var(--teal); }
.mini-card strong { font-size: 1.7rem; line-height: 1.1; color: var(--text); }

/* حلقة الشعار */
.logo-ring {
    width: 148px; height: 148px;
    padding: 5px;
    border-radius: 34%;
    background: var(--brand);
    box-shadow: var(--raise), 0 0 0 6px color-mix(in srgb, var(--teal) 14%, transparent);
}
.logo-ring img { display: block; width: 100%; height: 100%; object-fit: cover; border-radius: 30%; background: var(--surface); }
.is-playing .logo-ring { animation: glow 2.4s ease-in-out infinite; }
@keyframes glow {
    0%, 100% { box-shadow: var(--raise), 0 0 0 6px color-mix(in srgb, var(--teal) 14%, transparent); }
    50%      { box-shadow: var(--raise), 0 0 0 14px color-mix(in srgb, var(--teal) 6%, transparent); }
}
.logo-ring.sm { width: 112px; height: 112px; margin: 0 auto 12px; }

/* الساعة */
.clock-box { justify-self: end; display: flex; flex-direction: column; align-items: center; gap: 8px; }
.clock { width: 104px; height: 104px; filter: drop-shadow(5px 5px 8px var(--sh-dark)) drop-shadow(-4px -4px 7px var(--sh-light)); }
.clock-face { fill: var(--surface); stroke: color-mix(in srgb, var(--text) 10%, transparent); stroke-width: 1.2; }
.tick { stroke: var(--muted); stroke-width: 1.6; stroke-linecap: round; }
.hand { stroke-linecap: round; }
.hand-h { stroke: var(--text); stroke-width: 3.6; }
.hand-m { stroke: var(--text); stroke-width: 2.6; }
.hand-s { stroke: #ff7a45; stroke-width: 1.3; }
.hand-s-dot { fill: #ff7a45; }
.date-pill {
    padding: 2px 10px; border-radius: 999px; font-size: .74rem; color: var(--muted);
    background: var(--surface); box-shadow: var(--inset); white-space: nowrap;
}

/* شريط الآن يُبث */
.np-bar {
    display: flex; align-items: center; gap: 12px;
    padding: 12px 18px;
    margin-bottom: 26px;
    border-radius: 22px;
    background: var(--surface2);
    box-shadow: var(--raise-sm);
}
.np-icon { color: var(--teal); }
.is-playing .np-icon { animation: beat 1.6s ease-in-out infinite; }
@keyframes beat { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.2); } }
.np-text { flex: 1; min-width: 0; }
.np-title { font-weight: 700; font-size: 1.05rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.np-artist { font-size: .82rem; color: var(--muted); }
.np-artist:empty { display: none; }

.equalizer { display: inline-flex; gap: 3px; height: 18px; align-items: flex-end; }
.equalizer i { width: 3.5px; height: 4px; border-radius: 3px; background: var(--brand); background-color: var(--teal); }
.is-playing .equalizer i { animation: eq 1s ease-in-out infinite; }
.is-playing .equalizer i:nth-child(2) { animation-delay: .2s; }
.is-playing .equalizer i:nth-child(3) { animation-delay: .4s; }
.is-playing .equalizer i:nth-child(4) { animation-delay: .1s; }
@keyframes eq { 0%, 100% { height: 4px; } 50% { height: 18px; } }

/* منطقة التحكم */
.stage {
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    align-items: center;
    gap: 12px;
}
.tiles { display: grid; gap: 14px; justify-items: center; align-content: center; }
.tiles:first-child { justify-items: end; }
.tiles:last-child  { justify-items: start; }

.tile {
    display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px;
    width: 88px; padding: 12px 6px;
    border-radius: 22px;
    background: var(--surface);
    box-shadow: var(--raise-sm);
    text-decoration: none;
    font-weight: 600; font-size: .85rem;
    transition: transform .15s, box-shadow .15s;
}
.tile:hover { transform: translateY(-2px); }
.tile:active { box-shadow: var(--inset); transform: none; }
.tile .ic { width: 28px; height: 28px; }
.t-telegram .ic { color: #2aa3dc; }
.t-facebook .ic { color: #1877f2; fill: currentColor; stroke: none; }
.t-whatsapp .ic { color: #25b85a; }
.t-app .ic      { color: #3ddc84; }
.tile.wide { width: auto; flex-direction: row; justify-content: flex-start; gap: 12px; padding: 14px 18px; font-size: 1rem; }

.transport { display: flex; flex-direction: column; align-items: center; gap: 22px; }

/* زر التشغيل الكبير */
.play {
    position: relative;
    width: 104px; height: 104px;
    display: grid; place-items: center;
    border-radius: 50%;
    border: 5px solid transparent;
    background: linear-gradient(var(--surface), var(--surface)) padding-box, var(--brand) border-box;
    box-shadow: var(--raise);
    color: var(--text);
    transition: transform .15s, box-shadow .15s;
}
.play:hover { transform: scale(1.04); }
.play:active { box-shadow: var(--inset); transform: scale(.98); }
.play .ic { width: 42px; height: 42px; grid-area: 1 / 1; }
.play .i-play { margin-inline-start: -4px; }  /* توازن بصري لمثلث التشغيل */
.play .i-pause { display: none; }
.is-playing .play .i-play { display: none; }
.is-playing .play .i-pause { display: block; }
.play.attention { animation: bump 1.5s ease-in-out infinite; }
@keyframes bump {
    0%, 100% { transform: scale(1); box-shadow: var(--raise), 0 0 0 0 color-mix(in srgb, var(--teal) 55%, transparent); }
    50%      { transform: scale(1.06); box-shadow: var(--raise), 0 0 0 16px color-mix(in srgb, var(--teal) 0%, transparent); }
}

.mini-controls { display: flex; align-items: center; gap: 12px; }
.btn-mute { width: 58px !important; height: 58px !important; color: #fff; background: #1c232b; visibility: hidden; }
.started .btn-mute { visibility: visible; }
.btn-mute .i-mute { display: none; }
.btn-mute.is-muted { background: var(--danger); }
.btn-mute.is-muted .i-vol { display: none; }
.btn-mute.is-muted .i-mute { display: block; }

/* الحالة */
.state-line {
    display: flex; align-items: center; justify-content: center; gap: 10px;
    margin-top: 22px; font-weight: 600; color: var(--muted);
}
.state-line .dot { width: 11px; height: 11px; border-radius: 50%; background: #8a93a0; }
.state-line[data-state="loading"] .dot { background: var(--amber); animation: blink 1s infinite; }
.state-line[data-state="live"]    .dot { background: var(--green); animation: live 1.6s infinite; }
.state-line[data-state="live"] { color: var(--text); }
.state-line[data-state="error"]   .dot { background: var(--danger); }
@keyframes blink { 50% { opacity: .25; } }
@keyframes live { 0%, 100% { box-shadow: 0 0 0 0 rgba(63, 201, 97, .6); } 50% { box-shadow: 0 0 0 8px rgba(63, 201, 97, 0); } }

.hint { min-height: 24px; margin: 4px 0 18px; text-align: center; font-size: .92rem; color: var(--muted); }
.hint.error { color: var(--danger); }

.desc-card {
    padding: 18px 20px;
    border-radius: 22px;
    text-align: center;
    font-weight: 700; font-size: 1.15rem;
    background: var(--surface2);
    box-shadow: var(--raise-sm);
}

/* ============================================================
   الملفات الصوتية
   ============================================================ */
.section-head { display: flex; align-items: center; gap: 10px; }
.head-ic { width: 30px; height: 30px; color: var(--teal); }
.section-head h2 { margin: 0; font-size: 1.5rem; font-weight: 800; }
.count-badge {
    min-width: 28px; padding: 0 9px; text-align: center; font-weight: 700; font-size: .85rem;
    color: #06231f; border-radius: 999px; background: var(--brand);
}
.count-badge:empty { display: none; }
.section-sub { margin: 4px 0 18px; color: var(--muted); font-size: .95rem; }

.files { list-style: none; margin: 0; padding: 0; display: grid; gap: 14px; }
.file {
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 6px 14px;
    align-items: center;
    padding: 14px;
    border-radius: 24px;
    background: var(--surface);
    box-shadow: var(--raise-sm);
    border: 2px solid transparent;
    transition: border-color .2s;
}
.file.active { border-color: color-mix(in srgb, var(--teal) 70%, transparent); }
.file-play {
    grid-row: span 2;
    width: 54px; height: 54px; border-radius: 50%; border: 0;
    display: grid; place-items: center;
    color: #06231f; background: var(--brand);
    box-shadow: var(--raise-sm);
}
.file-play .ic { grid-area: 1 / 1; width: 24px; height: 24px; }
.file-play .i-pause { display: none; }
.file.playing .file-play .i-play { display: none; }
.file.playing .file-play .i-pause { display: block; }

.file-meta { min-width: 0; }
.file-title { font-weight: 700; font-size: 1.05rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-artist { color: var(--muted); font-size: .85rem; }
.file-artist:empty { display: none; }

.file-bottom { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.file-progress { flex: 1; min-width: 120px; display: flex; align-items: center; gap: 8px; }
.file-progress input[type=range] { flex: 1; min-width: 0; accent-color: var(--teal); height: 20px; }
.file-progress input[type=range]:disabled { opacity: .45; }
.file-time { font-size: .78rem; color: var(--muted); font-variant-numeric: tabular-nums; direction: ltr; min-width: 38px; }
.file-actions { display: flex; gap: 8px; }
.file-actions .neu-btn { width: 38px; height: 38px; }
.file-actions .ic { width: 18px; height: 18px; }
.file-actions a.neu-btn { text-decoration: none; }

.empty { padding: 30px; text-align: center; color: var(--muted); border-radius: 22px; background: var(--surface); box-shadow: var(--inset); }

/* ============================================================
   عن الإذاعة
   ============================================================ */
.about-card { text-align: center; padding: 24px 18px; margin-bottom: 18px; border-radius: 28px; background: var(--surface); box-shadow: var(--raise-sm); }
.about-card h2 { margin: 0 0 6px; font-size: 1.6rem; font-weight: 800; }
.about-card p { margin: 0; color: var(--muted); }

.link-card { padding: 16px; margin-bottom: 18px; border-radius: 24px; background: var(--surface); box-shadow: var(--raise-sm); }
.link-label { margin-bottom: 8px; font-weight: 600; color: var(--muted); font-size: .9rem; }
.link-row { display: flex; align-items: center; gap: 10px; }
.link-row input {
    flex: 1; min-width: 0; padding: 10px 14px; border: 0; border-radius: 14px;
    color: var(--text); background: var(--surface); box-shadow: var(--inset); font: inherit; font-size: .9rem;
}
.about-links { display: grid; gap: 14px; }

/* ============================================================
   التبويبات السفلية
   ============================================================ */
.bottom-nav {
    position: sticky; bottom: max(10px, env(safe-area-inset-bottom));
    display: grid; grid-template-columns: repeat(5, 1fr); gap: 4px;
    padding: 6px; margin: 10px 0 12px;
    border-radius: 28px;
    background: var(--surface);
    box-shadow: var(--raise);
    z-index: 5;
}
.nav-btn {
    display: flex; flex-direction: column; align-items: center; gap: 2px;
    padding: 8px 2px; border: 0; border-radius: 20px;
    background: transparent; color: var(--muted);
    font-size: .74rem; font-weight: 600; line-height: 1.2; white-space: nowrap;
    transition: all .2s;
}
.nav-btn .ic { width: 24px; height: 24px; }
.nav-btn.active { color: var(--teal); box-shadow: var(--inset); background: var(--surface); }
.nav-btn.active .ic { stroke: var(--teal); }

/* ---------------- إشعار صغير ---------------- */
.toast {
    position: fixed; left: 50%; bottom: 110px; z-index: 50;
    transform: translate(-50%, 20px); opacity: 0; pointer-events: none;
    padding: 10px 20px; border-radius: 999px;
    color: #fff; background: #1c232b; font-weight: 600; font-size: .92rem;
    box-shadow: 0 10px 30px rgba(0, 0, 0, .3);
    transition: opacity .25s, transform .25s;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ============================================================
   شاشات صغيرة
   ============================================================ */
@media (max-width: 420px) {
    .app { padding-inline: 12px; }
    .hero { gap: 6px; }
    .logo-ring { width: 118px; height: 118px; }
    .clock { width: 84px; height: 84px; }
    .date-pill { font-size: .68rem; padding-inline: 8px; }
    .mini-card { min-width: 78px; padding: 12px 8px; font-size: .72rem; }
    .mini-card strong { font-size: 1.4rem; }
    .stage { gap: 6px; }
    .tile { width: 72px; font-size: .75rem; border-radius: 18px; }
    .tile .ic { width: 24px; height: 24px; }
    .play { width: 92px; height: 92px; }
    .neu-btn.round.sm { width: 38px; height: 38px; }
    .btn-mute { width: 50px !important; height: 50px !important; }
    .mini-controls { gap: 8px; }
    .title-pill { font-size: 1.2rem; }
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* ============================================================
   إعلانات (اللقاء القادم)
   ============================================================ */
.ann-card { border-radius: 28px; overflow: hidden; background: var(--surface); box-shadow: var(--raise); }
.ann-media { background: var(--surface2); }
.ann-media img { display: block; width: 100%; max-height: 340px; object-fit: cover; }
.ann-body { padding: 20px 20px 22px; }
.ann-badge {
    display: inline-block; padding: 2px 14px; margin-bottom: 10px;
    border-radius: 999px; font-weight: 700; font-size: .85rem; color: #06231f; background: var(--brand);
}
.ann-title { margin: 0 0 6px; font-size: 1.6rem; font-weight: 800; line-height: 1.35; }
.ann-note { margin: 0 0 14px; color: var(--muted); }
.ann-rows { list-style: none; margin: 14px 0 0; padding: 0; display: grid; gap: 12px; }
.ann-rows li {
    display: flex; align-items: center; gap: 14px;
    padding: 12px 16px; border-radius: 18px; background: var(--surface); box-shadow: var(--inset);
}
.ann-rows .ic { width: 26px; height: 26px; color: var(--teal); }
.ann-rows small { display: block; color: var(--muted); font-size: .8rem; line-height: 1.2; }
.ann-rows strong { font-size: 1.08rem; }
.ann-count {
    margin-top: 14px; padding: 10px 16px; text-align: center; font-weight: 700;
    border-radius: 16px; background: var(--surface2); box-shadow: var(--raise-sm);
}

/* ============================================================
   الشركاء (3 خانات)
   ============================================================ */
.partners-card { margin-top: 20px; padding: 18px 16px 20px; border-radius: 26px; background: var(--surface); box-shadow: var(--raise-sm); }
.partners-title { margin: 0 0 14px; text-align: center; font-size: 1.25rem; font-weight: 800; }
.partners { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.partner-wrap { display: flex; flex-direction: column; align-items: center; gap: 6px; min-width: 0; }
.partner {
    width: 100%; aspect-ratio: 1; padding: 10px;
    display: grid; place-items: center; overflow: hidden;
    border-radius: 22px; background: #fff; box-shadow: var(--raise-sm);
    text-decoration: none; transition: transform .15s;
}
a.partner:hover { transform: translateY(-2px); }
.partner img { max-width: 100%; max-height: 100%; object-fit: contain; }
.partner.empty { background: var(--surface); box-shadow: var(--inset); color: var(--muted); border: 2px dashed color-mix(in srgb, var(--muted) 45%, transparent); }
.partner.empty .ic { width: 28px; height: 28px; opacity: .6; }
.partner-name { font-size: .78rem; color: var(--muted); text-align: center; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 100%; min-height: 1.2em; }

@media (max-width: 420px) {
    .nav-btn { font-size: .66rem; }
    .nav-btn .ic { width: 22px; height: 22px; }
    .ann-title { font-size: 1.35rem; }
}
