/* ============================================
   app.css — Telegram Mini App Frontend Styles
   Dark theme, modern, rounded cards, responsive.
   ============================================ */

/* ─── Reset & Variables ──────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
    --bg:            #0f1117;
    --bg-card:       #1a1d2e;
    --bg-input:      #222639;
    --bg-overlay:    rgba(0,0,0,0.6);
    --border:        #2a2f45;
    --text:          #e2e8f0;
    --text-muted:    #8892a8;
    --primary:       #6c5ce7;
    --primary-dark:  #5a4bd1;
    --success:       #00b894;
    --danger:        #e74c3c;
    --warning:       #f39c12;
    --radius:        16px;
    --radius-sm:     10px;
    --shadow:        0 4px 20px rgba(0,0,0,0.3);
    --transition:    all 0.3s ease;
}

html, body {
    font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.5;
    overflow-x: hidden;
}

/* ─── Scrollbar ──────────────────────────────────────────── */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }

/* ─── Header / Navbar ─────────────────────────────────────── */
.app-header {
    position: sticky;
    top: 0;
    z-index: 50;
    background: rgba(15,17,23,0.85);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--border);
    padding: 12px 16px;
    display: flex;
    align-items: center;
    gap: 12px;
}

.app-header .logo {
    font-size: 18px;
    font-weight: 800;
    color: var(--primary);
    display: flex;
    align-items: center;
    gap: 8px;
}

.app-header .profile-btn {
    margin-left: auto;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border: 2px solid var(--border);
    background: var(--bg-card);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: var(--transition);
}
.app-header .profile-btn img {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    object-fit: cover;
}

/* ─── Search Bar ─────────────────────────────────────────── */
.search-container {
    padding: 12px 16px;
}

.search-box {
    display: flex;
    align-items: center;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 0 14px;
    gap: 10px;
    transition: var(--transition);
}
.search-box:focus-within { border-color: var(--primary); }

.search-box i { color: var(--text-muted); font-size: 16px; }

.search-box input {
    flex: 1;
    background: none;
    border: none;
    outline: none;
    color: var(--text);
    padding: 12px 0;
    font-size: 14px;
}
.search-box input::placeholder { color: var(--text-muted); }

/* ─── Category Slider ─────────────────────────────────────── */
.category-slider {
    padding: 8px 16px 16px;
    overflow-x: auto;
    white-space: nowrap;
    scrollbar-width: none;
}
.category-slider::-webkit-scrollbar { display: none; }

.category-list {
    display: inline-flex;
    gap: 8px;
}

.cat-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 24px;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-muted);
    cursor: pointer;
    transition: var(--transition);
    white-space: nowrap;
    user-select: none;
}
.cat-chip:hover { border-color: var(--primary); color: var(--text); }
.cat-chip.active {
    background: var(--primary);
    color: #fff;
    border-color: var(--primary);
}

/* ─── Section Headers ────────────────────────────────────── */
.section-title {
    padding: 8px 16px;
    font-size: 16px;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 8px;
}
.section-title i { color: var(--primary); }

/* ─── Video Grid ──────────────────────────────────────────── */
.video-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
    padding: 8px 16px 24px;
}

.video-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
    position: relative;
}
.video-card:hover {
    transform: translateY(-3px);
    box-shadow: var(--shadow);
}

.video-card .thumb {
    width: 100%;
    aspect-ratio: 16/9;
    object-fit: cover;
    background: var(--bg-input);
    display: block;
}

.video-card .badge {
    position: absolute;
    top: 8px;
    right: 8px;
    padding: 3px 10px;
    border-radius: 20px;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}
.badge-locked {
    background: rgba(231,76,60,0.9);
    color: #fff;
}
.badge-unlocked {
    background: rgba(0,184,148,0.9);
    color: #fff;
}

.video-card .card-body {
    padding: 10px 12px 12px;
}
.video-card .card-title {
    font-size: 13px;
    font-weight: 600;
    line-height: 1.4;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}
.video-card .card-meta {
    margin-top: 6px;
    font-size: 11px;
    color: var(--text-muted);
    display: flex;
    align-items: center;
    gap: 8px;
}

/* ─── Video Detail Page ───────────────────────────────────── */
.page {
    display: none;
    flex-direction: column;
    min-height: 100vh;
}
.page.active { display: flex; }

.video-detail {
    flex: 1;
    padding-bottom: 100px;
}

.video-detail .detail-thumb {
    width: 100%;
    aspect-ratio: 16/9;
    object-fit: cover;
    background: var(--bg-input);
}

.video-detail .detail-body {
    padding: 16px;
}

.detail-title {
    font-size: 20px;
    font-weight: 700;
    margin-bottom: 4px;
}
.detail-category {
    font-size: 12px;
    color: var(--text-muted);
    margin-bottom: 12px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}
.detail-desc {
    font-size: 14px;
    color: var(--text-muted);
    line-height: 1.6;
    margin-bottom: 20px;
}

/* ─── Progress Section ────────────────────────────────────── */
.progress-section {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px;
    margin-bottom: 16px;
}

.progress-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
}
.progress-label {
    font-size: 14px;
    font-weight: 600;
}
.progress-count {
    font-size: 14px;
    color: var(--primary);
    font-weight: 700;
}

.progress-bar-bg {
    width: 100%;
    height: 8px;
    background: var(--bg-input);
    border-radius: 4px;
    overflow: hidden;
    margin-bottom: 12px;
}
.progress-bar-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--primary), var(--success));
    border-radius: 4px;
    transition: width 0.5s ease;
}

.ad-status {
    display: flex;
    gap: 12px;
}
.ad-step {
    flex: 1;
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px;
    background: var(--bg-input);
    border-radius: var(--radius-sm);
    font-size: 13px;
    font-weight: 600;
}
.ad-step.done {
    background: rgba(0,184,148,0.15);
    color: var(--success);
}
.ad-step.done i { color: var(--success); }
.ad-step i { font-size: 16px; }

/* ─── Action Buttons ──────────────────────────────────────── */
.action-area {
    padding: 16px;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: linear-gradient(transparent, var(--bg) 20%);
    padding-top: 32px;
    z-index: 40;
}

.btn-main {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100%;
    padding: 14px 20px;
    border: none;
    border-radius: var(--radius);
    font-size: 16px;
    font-weight: 700;
    cursor: pointer;
    transition: var(--transition);
    color: #fff;
}

.btn-watch-ads {
    background: linear-gradient(135deg, var(--primary), #8b7cf7);
}
.btn-watch-ads:hover { opacity: 0.9; transform: scale(1.01); }

.btn-watch-ads:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

.btn-play {
    background: linear-gradient(135deg, var(--success), #00d2a0);
}
.btn-play:hover { opacity: 0.9; }

/* ─── Profile Page ────────────────────────────────────────── */
.profile-page {
    flex: 1;
    padding: 24px 16px;
}

.profile-header {
    text-align: center;
    margin-bottom: 24px;
}

.profile-avatar {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    object-fit: cover;
    border: 3px solid var(--primary);
    margin-bottom: 12px;
    background: var(--bg-card);
}

.profile-name {
    font-size: 20px;
    font-weight: 700;
}
.profile-username {
    font-size: 14px;
    color: var(--text-muted);
    margin-bottom: 16px;
}

.profile-stats {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
}

.profile-stat {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px;
    text-align: center;
}
.profile-stat .stat-value {
    font-size: 22px;
    font-weight: 700;
    color: var(--primary);
}
.profile-stat .stat-label {
    font-size: 11px;
    color: var(--text-muted);
    text-transform: uppercase;
    margin-top: 4px;
}

/* ─── Back Button ────────────────────────────────────────── */
.back-btn {
    position: absolute;
    top: 12px;
    left: 12px;
    width: 36px;
    height: 36px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    z-index: 5;
    color: var(--text);
    font-size: 16px;
    transition: var(--transition);
}
.back-btn:hover { background: var(--primary); }

/* ─── Loading Spinner ────────────────────────────────────── */
.loader {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 40px;
}
.spinner {
    width: 36px;
    height: 36px;
    border: 3px solid var(--border);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ─── Empty State ────────────────────────────────────────── */
.empty-state {
    text-align: center;
    padding: 48px 24px;
    color: var(--text-muted);
}
.empty-state i { font-size: 48px; margin-bottom: 12px; opacity: 0.3; }
.empty-state p { font-size: 14px; }

/* ─── Responsive ──────────────────────────────────────────── */
@media (min-width: 480px) {
    .video-grid { grid-template-columns: repeat(2, 1fr); gap: 16px; }
}
@media (min-width: 768px) {
    .video-grid { grid-template-columns: repeat(3, 1fr); }
}

/* ─── Browser Blocked / Telegram Only Screen ──────────────── */
.browser-blocked-screen {
    display: none;
    min-height: 100vh;
    padding: 24px 16px;
    align-items: center;
    justify-content: center;
    background: radial-gradient(circle at 50% 20%, rgba(36, 161, 222, 0.15), transparent 70%), var(--bg);
}
.browser-blocked-screen.active {
    display: flex;
}

.browser-blocked-card {
    background: rgba(26, 29, 46, 0.95);
    border: 1px solid rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-radius: 24px;
    padding: 36px 24px;
    max-width: 420px;
    width: 100%;
    text-align: center;
    box-shadow: 0 16px 40px rgba(0, 0, 0, 0.5);
    animation: fadeInBlocked 0.4s ease-out;
}

@keyframes fadeInBlocked {
    from { opacity: 0; transform: translateY(16px); }
    to { opacity: 1; transform: translateY(0); }
}

.tg-icon-wrapper {
    position: relative;
    width: 84px;
    height: 84px;
    margin: 0 auto 20px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.tg-icon-pulse {
    position: absolute;
    inset: -6px;
    border-radius: 50%;
    background: rgba(36, 161, 222, 0.3);
    animation: pulseRing 2s cubic-bezier(0.215, 0.61, 0.355, 1) infinite;
}

@keyframes pulseRing {
    0% { transform: scale(0.9); opacity: 0.8; }
    50% { transform: scale(1.15); opacity: 0.3; }
    100% { transform: scale(0.9); opacity: 0.8; }
}

.tg-icon-circle {
    position: relative;
    width: 76px;
    height: 76px;
    border-radius: 50%;
    background: linear-gradient(135deg, #2AABEE, #229ED9);
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 8px 24px rgba(34, 158, 217, 0.4);
}

.tg-icon-circle i {
    font-size: 38px;
    color: #fff;
    margin-right: 4px;
    margin-top: 2px;
}

.blocked-title {
    font-size: 22px;
    font-weight: 800;
    margin-bottom: 8px;
    color: #fff;
    letter-spacing: -0.5px;
}

.blocked-subtitle {
    font-size: 13.5px;
    color: var(--text-muted);
    line-height: 1.55;
    margin-bottom: 24px;
}

.blocked-subtitle strong {
    color: #2AABEE;
}

.btn-telegram {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    width: 100%;
    padding: 14px 20px;
    background: linear-gradient(135deg, #2AABEE, #1E88E5);
    color: #fff;
    text-decoration: none;
    font-size: 15px;
    font-weight: 700;
    border-radius: var(--radius);
    box-shadow: 0 6px 20px rgba(42, 171, 238, 0.35);
    transition: var(--transition);
    margin-bottom: 24px;
}

.btn-telegram:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(42, 171, 238, 0.5);
    color: #fff;
}

.btn-telegram i {
    font-size: 18px;
}

.blocked-instructions {
    text-align: left;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 14px 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-bottom: 20px;
}

.instruction-step {
    display: flex;
    align-items: center;
    gap: 12px;
}

.instruction-step .step-number {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: rgba(42, 171, 238, 0.15);
    color: #2AABEE;
    font-size: 12px;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.instruction-step .step-text {
    font-size: 12.5px;
    color: var(--text);
    line-height: 1.4;
}

.blocked-footer {
    font-size: 12px;
    color: var(--text-muted);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
}
.blocked-footer i {
    color: var(--success);
}
