@import url('https://fonts.googleapis.com/css2?family=IBM+Plex+Sans+Arabic:wght@400;500;600&family=Reem+Kufi:wght@500;600;700&display=swap');

:root {
    --bg: #21241a;
    --bg-deep: #191b13;
    --surface: #2a2e21;
    --surface-2: #323727;
    --line: #3d4231;
    --olive: #8a9a5b;
    --olive-soft: rgba(138, 154, 91, 0.16);
    --gold: #c9a24b;
    --gold-ink: #231d0c;
    --text: #ece6d3;
    --muted: #a4a28c;
    --danger: #c9634a;
    --danger-soft: rgba(201, 99, 74, 0.14);

    --font-body: 'IBM Plex Sans Arabic', 'Segoe UI', Tahoma, sans-serif;
    --font-head: 'Reem Kufi', 'IBM Plex Sans Arabic', Tahoma, sans-serif;

    --radius-sm: 6px;
    --radius: 10px;
}

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

html { -webkit-text-size-adjust: 100%; }

body {
    margin: 0;
    min-height: 100vh;
    background: var(--bg);
    color: var(--text);
    font-family: var(--font-body);
    font-size: 16px;
    line-height: 1.6;
}

h1, h2, h3 { font-family: var(--font-head); font-weight: 600; line-height: 1.25; margin: 0; }

a { color: var(--gold); }

:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }

.wrap { width: min(1040px, 100% - 32px); margin-inline: auto; }

/* ==================== الأزرار ==================== */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-height: 40px;
    padding: 0 18px;
    border: 1px solid transparent;
    border-radius: var(--radius-sm);
    background: var(--surface-2);
    color: var(--text);
    font: 500 0.95rem var(--font-body);
    text-decoration: none;
    cursor: pointer;
    white-space: nowrap;
}
.btn:hover { background: #3a3f2d; }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.btn-primary { background: var(--gold); color: var(--gold-ink); font-weight: 600; }
.btn-primary:hover { background: #d6b05a; }
.btn-olive { background: var(--olive); color: #15170f; font-weight: 600; }
.btn-olive:hover { background: #97a867; }
.btn-danger { background: transparent; border-color: var(--danger); color: #e7917c; }
.btn-danger:hover { background: var(--danger-soft); }
.btn-ghost { background: transparent; border-color: var(--line); }
.btn-ghost:hover { background: var(--surface); }
.btn-sm { min-height: 32px; padding: 0 12px; font-size: 0.85rem; }

/* ==================== الحقول ==================== */
.field { display: grid; gap: 6px; }
.field label { font-size: 0.9rem; color: var(--muted); }
.input {
    width: 100%;
    min-height: 44px;
    padding: 0 14px;
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    background: var(--bg-deep);
    color: var(--text);
    font: 400 1rem var(--font-body);
}
.input:focus { border-color: var(--olive); outline: none; box-shadow: 0 0 0 3px var(--olive-soft); }
.input-prefix { position: relative; }
.input-prefix span {
    position: absolute; inset-inline-start: 14px; top: 50%; transform: translateY(-50%);
    color: var(--muted); pointer-events: none; direction: ltr;
}
.input-prefix .input { padding-inline-start: 34px; direction: ltr; text-align: right; }

/* ==================== الشريط العلوي ==================== */
.topbar {
    border-bottom: 1px solid var(--line);
    background: var(--bg-deep);
}
.topbar .wrap {
    display: flex; align-items: center; justify-content: space-between; gap: 16px;
    min-height: 64px;
}
.brand {
    font-family: var(--font-head); font-weight: 700; font-size: 1.35rem;
    color: var(--text); text-decoration: none; letter-spacing: 0.01em;
}
.brand b { color: var(--gold); font-weight: 700; }
.topbar-end { display: flex; align-items: center; gap: 10px; }
.user-chip { color: var(--muted); font-size: 0.9rem; direction: ltr; }

/* ==================== شريط "على الهواء" ==================== */
.onair {
    background: var(--gold);
    color: var(--gold-ink);
}
.onair[hidden] { display: none; }
.onair .wrap {
    display: flex; align-items: center; gap: 14px; flex-wrap: wrap;
    min-height: 56px; padding-block: 8px;
}
.onair-dot {
    width: 10px; height: 10px; border-radius: 50%; background: #9e2a17; flex: none;
    animation: pulse 1.6s ease-in-out infinite;
}
.onair-text { flex: 1; min-width: 200px; font-weight: 500; }
.onair-text strong { font-family: var(--font-head); font-size: 1.1rem; font-weight: 700; }
.onair .btn { background: rgba(35, 29, 12, 0.12); color: var(--gold-ink); }
.onair .btn:hover { background: rgba(35, 29, 12, 0.22); }
.onair .btn-stop { background: var(--gold-ink); color: var(--gold); }
.onair .btn-stop:hover { background: #3a3016; }

@keyframes pulse { 50% { opacity: 0.3; } }

/* ==================== النافذة المنبثقة ==================== */
dialog.modal {
    width: min(440px, 100% - 32px);
    padding: 0;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--surface);
    color: var(--text);
}
dialog.modal::backdrop { background: rgba(12, 13, 9, 0.72); }
.modal-body { padding: 28px 26px 22px; text-align: center; }
.modal-icon {
    width: 64px; height: 64px; margin: 0 auto 16px;
    display: grid; place-items: center;
    border-radius: 50%;
    background: var(--danger-soft);
    border: 1px solid rgba(201, 99, 74, 0.45);
    font-size: 1.7rem;
}
.modal-icon svg { width: 30px; height: 30px; color: var(--gold); }
.modal-icon.neutral { background: var(--olive-soft); border-color: rgba(138, 154, 91, 0.45); }
.modal-title { font-size: 1.3rem; margin-bottom: 8px; }
.modal-text { color: var(--muted); margin: 0; }
.modal-actions {
    display: flex; flex-direction: column; gap: 8px;
    padding: 0 26px 24px;
}

/* ==================== التنبيهات القصيرة ==================== */
.toast {
    position: fixed; inset-inline: 0; bottom: 24px; margin-inline: auto;
    width: max-content; max-width: calc(100% - 32px);
    padding: 10px 18px; border-radius: var(--radius-sm);
    background: var(--text); color: var(--bg); font-weight: 500;
    z-index: 50;
}
.toast[hidden] { display: none; }

.muted { color: var(--muted); }
.error-text { color: #e7917c; font-size: 0.9rem; min-height: 1.5em; margin: 0; }

@media (prefers-reduced-motion: reduce) {
    .onair-dot { animation: none; }
}

/* ==================== شارة حالة البث في صفحات ألعاب اللايف ==================== */
.tiktok-pill {
    display: inline-flex; align-items: center; gap: 8px;
    min-height: 32px; padding: 0 12px;
    border: 1px solid var(--line); border-radius: 999px;
    font-size: 0.85rem; color: var(--muted);
}
.tiktok-pill[hidden] { display: none; }
.tiktok-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--muted); }
.tiktok-pill[data-state="connected"] { color: var(--text); border-color: rgba(138, 154, 91, 0.6); }
.tiktok-pill[data-state="connected"] .tiktok-dot { background: var(--olive); }
.tiktok-pill[data-state="waiting"] .tiktok-dot,
.tiktok-pill[data-state="connecting"] .tiktok-dot { background: var(--gold); }
.tiktok-pill[data-state="error"] .tiktok-dot,
.tiktok-pill[data-state="ended"] .tiktok-dot { background: var(--danger); }

@media (max-width: 640px) {
    .tiktok-label { display: none; }
    .topbar .wrap { flex-wrap: wrap; padding-block: 10px; }
}
.modal-icon .emoji { font-size: 1.7rem; }
