/* ============================================================
   Telegram Video Sharing Mini App - Native Telegram Blue & White Theme
   ============================================================ */

:root {
    /* Native Telegram Blue Palette */
    --bg-primary: #f0f9ff;
    --bg-secondary: #ffffff;
    --text-primary: #0c4a6e;
    --text-muted: #64748b;
    --accent-color: #0088cc;
    --accent-light: #24a1de;
    --accent-dark: #006699;
    --accent-gradient: linear-gradient(135deg, #0088cc 0%, #24a1de 100%);
    --accent-text: #ffffff;
    
    /* Surface & Borders */
    --surface-card: #ffffff;
    --surface-border: rgba(0, 136, 204, 0.15);
    --surface-hover: rgba(0, 136, 204, 0.06);
    --shadow-soft: 0 10px 30px -5px rgba(0, 136, 204, 0.12);
    
    /* Constants */
    --radius-sm: 10px;
    --radius-md: 16px;
    --radius-lg: 24px;
    --radius-full: 9999px;
    --font-family: 'Inter', system-ui, -apple-system, sans-serif;
}

/* Reset & Base Setup */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

body {
    font-family: var(--font-family);
    background: var(--bg-primary) url('assets/bg.png') no-repeat center center fixed;
    background-size: cover;
    color: var(--text-primary);
    min-height: 100vh;
    padding: 0;
    overflow-x: hidden;
    user-select: none;
}

.app-container {
    max-width: 480px;
    margin: 0 auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 18px;
    backdrop-filter: blur(16px);
    background: rgba(240, 249, 255, 0.88);
    min-height: 100vh;
}

/* Header */
.app-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 0;
}

.user-profile {
    display: flex;
    align-items: center;
    gap: 10px;
}

.avatar {
    width: 44px;
    height: 44px;
    border-radius: var(--radius-full);
    background: var(--accent-gradient);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    color: #fff;
    box-shadow: 0 4px 14px rgba(0, 136, 204, 0.35);
}

.user-info {
    display: flex;
    flex-direction: column;
}

.user-greeting {
    font-size: 0.75rem;
    color: var(--text-muted);
}

.user-name {
    font-size: 0.98rem;
    font-weight: 700;
    color: var(--text-primary);
}

.app-badge {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 5px 12px;
    background: rgba(0, 136, 204, 0.12);
    border: 1px solid rgba(0, 136, 204, 0.3);
    border-radius: var(--radius-full);
    font-size: 0.75rem;
    color: #006699;
    font-weight: 600;
}

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background-color: #0088cc;
    box-shadow: 0 0 10px #0088cc;
}

/* Hero Section */
.hero-section {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.hero-title {
    font-size: 1.45rem;
    font-weight: 800;
    background: linear-gradient(135deg, #0c4a6e 0%, #0088cc 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    line-height: 1.2;
}

.hero-subtitle {
    font-size: 0.85rem;
    color: var(--text-muted);
    line-height: 1.4;
}

/* Search Box */
.search-box {
    position: relative;
    margin-top: 6px;
    display: flex;
    align-items: center;
}

.search-box input {
    width: 100%;
    padding: 13px 40px 13px 44px;
    background: #ffffff;
    border: 1px solid var(--surface-border);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font-size: 0.9rem;
    outline: none;
    box-shadow: var(--shadow-soft);
    transition: all 0.25s ease;
}

.search-box input:focus {
    border-color: var(--accent-color);
    box-shadow: 0 0 0 4px rgba(0, 136, 204, 0.15);
}

.search-icon {
    position: absolute;
    left: 14px;
    font-size: 1rem;
    color: var(--accent-color);
}

.clear-btn {
    position: absolute;
    right: 14px;
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 1.2rem;
    cursor: pointer;
}

/* Categories Bar */
.categories-wrapper {
    overflow-x: auto;
    scrollbar-width: none;
    margin: 0 -16px;
    padding: 0 16px;
}

.categories-wrapper::-webkit-scrollbar { display: none; }

.categories-scroll {
    display: flex;
    gap: 8px;
}

.cat-pill {
    padding: 8px 18px;
    border-radius: var(--radius-full);
    background: #ffffff;
    border: 1px solid var(--surface-border);
    color: var(--text-muted);
    font-size: 0.82rem;
    font-weight: 600;
    white-space: nowrap;
    cursor: pointer;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
    transition: all 0.2s ease;
}

.cat-pill.active, .cat-pill:hover {
    background: var(--accent-gradient);
    color: #ffffff;
    border-color: transparent;
    box-shadow: 0 4px 14px rgba(0, 136, 204, 0.35);
}

/* Content Section & Grid */
.content-section {
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.section-title {
    font-size: 1.1rem;
    font-weight: 700;
    color: #0c4a6e;
}

.video-count-badge {
    font-size: 0.75rem;
    background: rgba(0, 136, 204, 0.1);
    color: var(--accent-dark);
    padding: 4px 10px;
    border-radius: var(--radius-sm);
    font-weight: 600;
}

/* Video Cards Grid */
.video-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 14px;
}

.video-card {
    background: #ffffff;
    border: 1px solid var(--surface-border);
    border-radius: var(--radius-md);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    cursor: pointer;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    box-shadow: var(--shadow-soft);
}

.video-card:active {
    transform: scale(0.97);
}

.video-thumbnail-container {
    position: relative;
    width: 100%;
    padding-top: 60%;
    background: #e2e8f0;
    overflow: hidden;
}

.video-thumbnail-container img {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.3s ease;
}

.video-card:hover img {
    transform: scale(1.05);
}

.duration-tag {
    position: absolute;
    bottom: 6px;
    right: 6px;
    background: rgba(12, 74, 110, 0.85);
    color: #fff;
    font-size: 0.7rem;
    font-weight: 600;
    padding: 2px 6px;
    border-radius: 4px;
}

.play-overlay {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 136, 204, 0.25);
    opacity: 0;
    transition: opacity 0.2s ease;
}

.video-card:hover .play-overlay {
    opacity: 1;
}

.play-icon {
    width: 38px;
    height: 38px;
    background: var(--accent-gradient);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-size: 0.9rem;
    box-shadow: 0 0 14px rgba(0, 136, 204, 0.6);
}

.video-info {
    padding: 12px;
    display: flex;
    flex-direction: column;
    gap: 6px;
    flex-grow: 1;
}

.video-card-title {
    font-size: 0.88rem;
    font-weight: 700;
    line-height: 1.3;
    color: #0c4a6e;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.video-meta {
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 0.73rem;
    color: var(--text-muted);
    margin-top: auto;
    font-weight: 500;
}

/* Modal Window */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(12, 74, 110, 0.6);
    backdrop-filter: blur(8px);
    display: flex;
    align-items: flex-end;
    justify-content: center;
    z-index: 1000;
    animation: fadeIn 0.25s ease;
}

.modal-card {
    width: 100%;
    max-width: 480px;
    background: #ffffff;
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
    overflow: hidden;
    position: relative;
    max-height: 88vh;
    display: flex;
    flex-direction: column;
    animation: slideUp 0.3s ease;
    box-shadow: 0 -10px 40px rgba(0, 0, 0, 0.15);
}

.modal-close {
    position: absolute;
    top: 12px;
    right: 12px;
    z-index: 10;
    width: 34px;
    height: 34px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.9);
    border: 1px solid var(--surface-border);
    color: #0c4a6e;
    font-size: 1.4rem;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.1);
}

.modal-thumbnail-wrapper {
    position: relative;
    width: 100%;
    height: 200px;
    background: #f1f5f9;
}

.modal-thumbnail-wrapper img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.modal-duration {
    position: absolute;
    bottom: 10px;
    right: 10px;
    background: rgba(12, 74, 110, 0.85);
    color: #fff;
    padding: 3px 8px;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 600;
}

.modal-body {
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 14px;
    overflow-y: auto;
}

.modal-tags {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.modal-tag {
    font-size: 0.75rem;
    padding: 4px 12px;
    border-radius: var(--radius-sm);
    background: rgba(0, 136, 204, 0.12);
    color: var(--accent-dark);
    font-weight: 600;
}

.size-tag { background: #f1f5f9; color: var(--text-muted); }
.task-req-tag { background: rgba(245, 158, 11, 0.15); color: #d97706; }

.modal-title { font-size: 1.2rem; font-weight: 800; color: #0c4a6e; line-height: 1.3; }
.modal-description { font-size: 0.88rem; color: var(--text-muted); line-height: 1.5; }

.modal-long-text {
    font-size: 0.85rem;
    color: #334155;
    background: #f8fafc;
    padding: 14px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--surface-border);
    white-space: pre-line;
    line-height: 1.6;
}

/* Screenshots Gallery */
.screenshots-section { display: flex; flex-direction: column; gap: 8px; }
.screenshots-title { font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.5px; color: var(--text-muted); font-weight: 700; }

.screenshots-scroll {
    display: flex;
    gap: 10px;
    overflow-x: auto;
    padding-bottom: 6px;
    scrollbar-width: none;
}
.screenshots-scroll::-webkit-scrollbar { display: none; }

.screenshot-item {
    width: 140px;
    height: 90px;
    flex-shrink: 0;
    border-radius: var(--radius-sm);
    overflow: hidden;
    border: 1px solid var(--surface-border);
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.05);
}
.screenshot-item img { width: 100%; height: 100%; object-fit: cover; }

/* Progress Bar */
.task-progress-box {
    background: #f8fafc;
    border: 1px solid var(--surface-border);
    padding: 14px;
    border-radius: var(--radius-md);
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.progress-info { display: flex; justify-content: space-between; font-size: 0.8rem; font-weight: 700; }
.progress-label { color: #0c4a6e; }
.progress-percent { color: var(--accent-color); }

.progress-bar-bg { width: 100%; height: 10px; background: #e0f2fe; border-radius: 5px; overflow: hidden; }
.progress-bar-fill { height: 100%; background: var(--accent-gradient); border-radius: 5px; transition: width 0.3s ease; }

/* Action Button */
.unlock-btn {
    width: 100%;
    padding: 15px;
    background: var(--accent-gradient);
    border: none;
    border-radius: var(--radius-md);
    color: #ffffff;
    font-size: 0.98rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    cursor: pointer;
    box-shadow: 0 6px 20px rgba(0, 136, 204, 0.35);
    transition: transform 0.2s ease, filter 0.2s ease;
    margin-top: 4px;
}

.unlock-btn:disabled {
    opacity: 0.7;
    cursor: not-allowed;
    filter: grayscale(0.4);
    box-shadow: none;
}

/* Loader & Toast */
.loader-container { display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 40px 0; gap: 12px; color: var(--text-muted); font-size: 0.85rem; }
.spinner { width: 32px; height: 32px; border: 3px solid rgba(0, 136, 204, 0.2); border-top-color: var(--accent-color); border-radius: 50%; animation: spin 0.8s linear infinite; }
.empty-state { display: flex; flex-direction: column; align-items: center; text-align: center; padding: 40px 16px; gap: 8px; }
.empty-icon { font-size: 2.5rem; }
.toast { position: fixed; top: 16px; left: 50%; transform: translateX(-50%); background: #ffffff; border: 1px solid var(--surface-border); padding: 12px 20px; border-radius: var(--radius-full); display: flex; align-items: center; gap: 8px; font-size: 0.88rem; font-weight: 600; color: #0c4a6e; box-shadow: 0 10px 30px rgba(0, 0, 0, 0.15); z-index: 2000; animation: fadeIn 0.2s ease; }

@keyframes spin { to { transform: rotate(360deg); } }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes slideUp { from { transform: translateY(100%); } to { transform: translateY(0); } }
.hidden { display: none !important; }
