/* ═══════════════════════════════════════════════════════════════
   main.css — Core styles: variables, reset, layout, theme
   Full-Download-Pro Mini App
   ═══════════════════════════════════════════════════════════════ */

/* ── CSS Custom Properties ──────────────────────────────────── */
:root {
    /* Dark theme — default */
    --bg-primary: #1a1a2e;
    --bg-secondary: #16213e;
    --bg-card: #1f2b47;
    --bg-surface: #253352;
    --text-primary: #ffffff;
    --text-secondary: #a8b2c1;
    --text-muted: #6b7a90;
    --accent: #6c63ff;
    --accent-hover: #5a52d5;
    --accent-glow: rgba(108, 99, 255, 0.25);
    --danger: #ff4757;
    --success: #2ed573;
    --warning: #ffa502;
    --border: rgba(255, 255, 255, 0.06);
    --shadow: 0 4px 24px rgba(0, 0, 0, 0.3);
    --radius: 14px;
    --radius-sm: 8px;
    --transition: 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    --safe-bottom: env(safe-area-inset-bottom, 0px);
}

:root.light-theme {
    --bg-primary: #f0f2f5;
    --bg-secondary: #ffffff;
    --bg-card: #ffffff;
    --bg-surface: #f7f8fa;
    --text-primary: #1a1a2e;
    --text-secondary: #5a6577;
    --text-muted: #8e99a8;
    --accent: #6c63ff;
    --accent-hover: #5a52d5;
    --accent-glow: rgba(108, 99, 255, 0.12);
    --border: rgba(0, 0, 0, 0.06);
    --shadow: 0 4px 24px rgba(0, 0, 0, 0.08);
}

/* ── Reset ──────────────────────────────────────────────────── */
*,
*::before,
*::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

/* ── Base ───────────────────────────────────────────────────── */
html,
body {
    height: 100%;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
        "Noto Sans Arabic", sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    -webkit-tap-highlight-color: transparent;
}

/* ── App Layout ─────────────────────────────────────────────── */
.app {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    min-height: 100dvh;
    max-width: 640px;
    margin: 0 auto;
    padding: 16px;
    padding-bottom: calc(16px + var(--safe-bottom));
    gap: 14px;
}

/* ── Header ─────────────────────────────────────────────────── */
.header {
    text-align: center;
    padding: 10px 0;
}

.header__badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: var(--accent-glow);
    color: var(--accent);
    font-size: 12px;
    font-weight: 600;
    padding: 5px 14px;
    border-radius: 20px;
    margin-bottom: 10px;
    letter-spacing: 0.3px;
    user-select: none;
}

.header__badge .dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--danger);
    animation: pulse-dot 1.8s ease-in-out infinite;
}

.header__badge.ended .dot {
    background: var(--success);
    animation: none;
}

.header__badge.upcoming .dot {
    background: var(--warning);
    animation: pulse-dot 1.2s ease-in-out infinite;
}

.header__title {
    font-size: 17px;
    font-weight: 700;
    line-height: 1.5;
    color: var(--text-primary);
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
}

.header__channel {
    font-size: 13px;
    color: var(--text-secondary);
    margin-top: 4px;
}

/* ── Stats Bar ──────────────────────────────────────────────── */
.stats-bar {
    display: flex;
    justify-content: space-around;
    background: var(--bg-card);
    border-radius: var(--radius);
    padding: 14px 0;
    box-shadow: var(--shadow);
}

.stat {
    text-align: center;
}

.stat__value {
    font-size: 16px;
    font-weight: 700;
    color: var(--text-primary);
}

.stat__label {
    font-size: 11px;
    color: var(--text-muted);
    margin-top: 2px;
}

.stat--accent .stat__value {
    color: var(--accent);
}

/* ── Action Panel (generic) ─────────────────────────────────── */
.action-panel {
    background: var(--bg-card);
    border-radius: var(--radius);
    padding: 16px;
    box-shadow: var(--shadow);
    text-align: center;
}

.action-panel__title {
    font-size: 15px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 4px;
}

.action-panel__desc {
    font-size: 12px;
    color: var(--text-muted);
    margin-bottom: 14px;
    line-height: 1.5;
}

/* ── Buttons ────────────────────────────────────────────────── */
.action-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100%;
    padding: 14px 20px;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    text-decoration: none;
    -webkit-user-select: none;
    user-select: none;
}

.action-btn--primary {
    background: var(--accent);
    color: #fff;
    box-shadow: 0 4px 16px var(--accent-glow);
}

.action-btn--primary:hover {
    background: var(--accent-hover);
    transform: translateY(-1px);
}

.action-btn:active {
    transform: scale(0.97);
}

/* ── Toast ──────────────────────────────────────────────────── */
.toast {
    position: fixed;
    top: 16px;
    left: 50%;
    transform: translateX(-50%) translateY(-100px);
    background: var(--bg-card);
    color: var(--text-primary);
    padding: 10px 20px;
    border-radius: var(--radius-sm);
    font-size: 13px;
    font-weight: 500;
    box-shadow: var(--shadow);
    z-index: 1000;
    transition: transform 0.35s cubic-bezier(0.4, 0, 0.2, 1);
    border: 1px solid var(--border);
    max-width: 90%;
    pointer-events: none;
}

.toast.show {
    transform: translateX(-50%) translateY(0);
}

/* ── Live Ended Panel ───────────────────────────────────────── */
.live-ended-panel {
    background: var(--bg-card);
    border-radius: var(--radius);
    padding: 20px 16px;
    box-shadow: var(--shadow);
    text-align: center;
    display: none;
}

.live-ended-panel.visible {
    display: block;
    animation: fade-in 0.4s ease forwards;
}

.live-ended-panel__icon {
    font-size: 36px;
    margin-bottom: 10px;
}

.live-ended-panel__title {
    font-size: 16px;
    font-weight: 700;
    color: var(--success);
    margin-bottom: 6px;
}

.live-ended-panel__desc {
    font-size: 13px;
    color: var(--text-muted);
    margin-bottom: 16px;
    line-height: 1.5;
}

.live-ended-panel__actions {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

/* ── Animations ─────────────────────────────────────────────── */
@keyframes pulse-dot {
    0%,
    100% {
        opacity: 1;
        transform: scale(1);
    }
    50% {
        opacity: 0.5;
        transform: scale(1.3);
    }
}

@keyframes fade-in {
    from {
        opacity: 0;
        transform: translateY(8px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.fade-in {
    animation: fade-in 0.4s ease forwards;
}

/* ── Utility ────────────────────────────────────────────────── */
.hidden {
    display: none !important;
}

/* ── Scrollbar ──────────────────────────────────────────────── */
::-webkit-scrollbar {
    width: 4px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: var(--text-muted);
    border-radius: 4px;
}
