@import url('https://fonts.googleapis.com/css2?family=Montserrat:wght@900&display=swap');

:root {
    --header-bg: rgba(0, 0, 0, 0.6); 
    --text-color: #ffffff;
    --badge-color: #30d158;
    --accent-blue: #007aff;
    --card-bg: rgba(255, 255, 255, 0.12);
}

/* --- BASE SETTINGS --- */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

body {
    margin: 0;
    width: 100%;
    /* Фикс для Telegram: используем переменную из JS или fallback */
    height: 100vh;
    height: calc(var(--vh, 1vh) * 100);
    color: var(--text-color);
    font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", sans-serif;
    background-color: #007aff;
    /* Разрешаем скролл body, чтобы контент в Telegram не обрезался */
    overflow-x: hidden;
    overflow-y: auto;
    position: relative;
}

/* --- ANIMATED BACKGROUND --- */
body::before {
    content: "";
    position: fixed;
    top: -50%; left: -50%; width: 200%; height: 200%;
    background: radial-gradient(circle at center, #00d2ff 0%, #3a7bd5 30%, #007aff 60%, #00c6ff 100%);
    background-size: cover;
    animation: rotateGradient 15s linear infinite;
    z-index: -1;
}

body::after {
    content: "";
    position: fixed;
    top: 0; left: 0; width: 100%; height: 100%;
    background-image: url("https://grainy-gradients.vercel.app/noise.svg");
    opacity: 0.12;
    pointer-events: none;
    z-index: 0;
}

@keyframes rotateGradient {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

/* --- HEADER --- */
.main-header {
    position: sticky;
    top: 0;
    z-index: 1000;
    width: 100%;
    padding: 8px 20px; 
    background: var(--header-bg);
    backdrop-filter: blur(20px) saturate(180%);
    -webkit-backdrop-filter: blur(20px) saturate(180%);
    border-bottom: 0.5px solid rgba(255, 255, 255, 0.1);
    display: flex;
    justify-content: center;
    align-items: center;
}

.header-content {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
}

.main-header h1 {
    font-family: 'Montserrat', sans-serif;
    font-size: 26px; 
    font-weight: 900;
    letter-spacing: 2px;
    text-transform: uppercase;
    margin: 0;
    background: linear-gradient(to bottom, #ffffff 0%, #ffffff 45%, #a1a1a1 50%, #ffffff 55%, #ffffff 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    filter: drop-shadow(0 2px 4px rgba(0,0,0,0.3));
}

.badge {
    position: absolute;
    right: -55px; 
    font-family: -apple-system, sans-serif;
    font-size: 9px;
    font-weight: 900;
    color: var(--badge-color);
    border: 1px solid var(--badge-color);
    padding: 1px 5px;
    border-radius: 5px;
    background: rgba(48, 209, 88, 0.1);
    text-transform: uppercase;
    animation: blinkFree 1.5s ease-in-out infinite;
}

@keyframes blinkFree {
    0%, 100% { opacity: 1; filter: brightness(1.2); }
    50% { opacity: 0.2; filter: brightness(0.8); }
}

/* --- CATEGORY BAR --- */
.category-bar {
    display: flex;
    gap: 10px;
    overflow-x: auto;
    padding: 10px 0;
    margin-bottom: 5px;
    scrollbar-width: none; 
}

.category-bar::-webkit-scrollbar {
    display: none; 
}

.category-btn {
    background: rgba(255, 255, 255, 0.12);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: white;
    padding: 8px 18px;
    border-radius: 20px;
    font-size: 13px;
    font-weight: 700;
    white-space: nowrap;
    cursor: pointer;
    transition: all 0.2s ease;
}

.category-btn.active {
    background: var(--accent-blue);
    border-color: var(--accent-blue);
    box-shadow: 0 4px 15px rgba(0, 122, 255, 0.4);
}

/* --- SEARCH OVERLAY --- */
.search-overlay {
    position: fixed;
    top: 0; left: 0;
    width: 100%; height: 100%;
    background: rgba(0, 0, 0, 0.4);
    backdrop-filter: blur(30px) saturate(150%);
    -webkit-backdrop-filter: blur(30px) saturate(150%);
    z-index: 1500;
    display: none;
    flex-direction: column;
}

.search-overlay.active {
    display: flex;
}

.search-header {
    padding: 15px 20px;
    display: flex;
    align-items: center;
    gap: 12px;
    background: var(--header-bg);
}

.search-input-wrapper {
    flex: 1;
    position: relative;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 12px;
    display: flex;
    align-items: center;
    padding: 0 10px;
}

#search-input {
    flex: 1;
    background: none;
    border: none;
    height: 38px;
    color: white;
    font-size: 16px;
    outline: none;
}

#search-input::placeholder {
    color: rgba(255, 255, 255, 0.4);
}

.clear-btn {
    background: #48484a;
    color: white;
    border: none;
    width: 18px; height: 18px;
    border-radius: 50%;
    font-size: 10px;
    cursor: pointer;
    display: none;
}

.cancel-btn {
    background: none;
    border: none;
    color: var(--accent-blue);
    font-size: 16px;
    font-weight: 500;
    cursor: pointer;
}

.search-results {
    flex: 1;
    overflow-y: auto;
    padding: 15px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

/* --- CONTENT & CARDS --- */
#content {
    position: relative;
    z-index: 1;
    padding: 15px;
    /* Фикс высоты контента */
    height: auto;
    min-height: calc(var(--vh, 1vh) * 100 - 150px);
    overflow-y: visible;
}

#app-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
    padding-bottom: 100px;
}

.app-card {
    background: rgba(255, 255, 255, 0.16);
    backdrop-filter: blur(25px) saturate(150%);
    -webkit-backdrop-filter: blur(25px) saturate(150%);
    border-radius: 20px;
    padding: 14px;
    display: flex;
    align-items: center;
    gap: 14px;
    border: 1px solid rgba(255, 255, 255, 0.2);
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.12);
}

.app-card:active {
    transform: scale(0.96);
    background: rgba(255, 255, 255, 0.25);
}

.app-icon {
    width: 62px;
    height: 62px;
    border-radius: 14px;
    object-fit: cover;
    box-shadow: 0 4px 12px rgba(0,0,0,0.3);
}

.app-info { flex: 1; min-width: 0; }

.app-name {
    font-size: 17px;
    font-weight: 700;
    color: #ffffff;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-bottom: 3px;
    text-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
}

.app-meta { 
    font-size: 12px; 
    color: rgba(255, 255, 255, 0.7); 
    margin-bottom: 4px; 
}

.app-date { 
    font-size: 10px; 
    color: var(--badge-color); 
    font-weight: 700; 
    letter-spacing: 0.3px;
}

.download-btn {
    background: #ffffff;
    border: none;
    color: var(--accent-blue);
    font-weight: 800;
    font-size: 13px;
    padding: 7px 20px;
    border-radius: 20px;
    pointer-events: none;
    box-shadow: 0 4px 10px rgba(0,0,0,0.15);
    text-transform: uppercase;
}

/* --- MODAL WINDOW (DETAIL VIEW) --- */
.modal-overlay {
    position: fixed;
    top: 0; left: 0;
    width: 100%; height: 100%;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    display: none;
    z-index: 2000;
    justify-content: center;
    align-items: flex-end;
}

.modal-overlay.active { display: flex; }

.modal-content {
    background: #1c1c1e;
    width: 100%;
    max-width: 500px;
    border-radius: 32px 32px 0 0;
    padding: 25px;
    position: relative;
    animation: slideUp 0.35s cubic-bezier(0.15, 1, 0.3, 1);
    color: white;
    max-height: 90vh;
    overflow-y: auto;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
}

@keyframes slideUp {
    from { transform: translateY(100%); }
    to { transform: translateY(0); }
}

.close-btn {
    position: absolute;
    top: 15px; right: 20px;
    background: #323234;
    border: none;
    color: white;
    width: 32px; height: 32px;
    border-radius: 50%;
    font-size: 20px;
    cursor: pointer;
    z-index: 10;
}

.modal-header-info {
    display: flex;
    gap: 18px;
    margin-bottom: 24px;
    align-items: center;
    position: relative;
}

.modal-icon-big {
    width: 86px;
    height: 86px;
    border-radius: 20px;
    box-shadow: 0 10px 24px rgba(0,0,0,0.4);
}

.modal-title-wrap { 
    flex: 1; 
    min-width: 0; 
    display: flex; 
    flex-direction: column; 
    gap: 8px; 
}

.modal-title-wrap h2 { 
    font-size: 22px; 
    font-weight: 800; 
    line-height: 1.2; 
}

.share-btn-rect {
    display: flex;
    align-items: center;
    gap: 8px;
    background: rgba(255, 255, 255, 0.1);
    border: none;
    padding: 6px 14px;
    border-radius: 10px;
    color: white;
    cursor: pointer;
    width: fit-content;
    transition: background 0.2s, transform 0.1s;
}

.share-btn-rect img { 
    width: 14px; 
    height: 14px; 
    filter: invert(1); 
}

.share-btn-rect span { 
    font-size: 11px; 
    font-weight: 800; 
    letter-spacing: 0.5px; 
}

.share-btn-rect:active { 
    background: rgba(255, 255, 255, 0.2); 
    transform: scale(0.95); 
}

.bundle-id-text { 
    opacity: 0.4; 
    font-size: 12px; 
    font-family: monospace; 
}

.modal-stats {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    background: rgba(255, 255, 255, 0.05);
    padding: 18px;
    border-radius: 20px;
    margin-bottom: 24px;
}

.stat-item { font-size: 11px; color: #8e8e93; text-transform: uppercase; font-weight: 600; }
.stat-item b { 
    display: block; 
    font-size: 15px; 
    margin-top: 4px; 
    color: white; 
    text-transform: none;
    font-weight: 700;
    white-space: pre-wrap !important;
    word-break: break-word;
}

.modal-desc {
    font-size: 15px;
    opacity: 0.85;
    line-height: 1.6;
    margin-bottom: 30px;
    white-space: pre-wrap !important;
    word-break: break-word;
}

.get-btn-big {
    width: 100%;
    background: var(--accent-blue);
    color: white;
    border: none;
    padding: 18px;
    border-radius: 16px;
    font-size: 18px;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.2s;
}

.get-btn-big:active { 
    transform: scale(0.98);
    opacity: 0.9;
}

/* --- BOTTOM NAVIGATION --- */
.bottom-nav {
    position: fixed;
    bottom: 20px; 
    left: 50%;
    transform: translateX(-50%);
    width: 92%;
    max-width: 420px;
    height: 64px; 
    background: rgba(0, 0, 0, 0.65);
    backdrop-filter: blur(24px) saturate(180%);
    -webkit-backdrop-filter: blur(24px) saturate(180%);
    border-radius: 24px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    display: flex;
    justify-content: space-around;
    align-items: center;
    z-index: 1000;
    box-shadow: 0 12px 48px rgba(0, 0, 0, 0.6);
}

.nav-item {
    background: none;
    border: none;
    display: flex;
    flex-direction: column;
    align-items: center;
    flex: 1;
    gap: 3px;
    cursor: pointer;
}

.nav-icon {
    font-size: 19px;
    opacity: 0.4;
    filter: grayscale(1);
    transition: 0.25s;
}

.nav-item.active .nav-icon {
    opacity: 1;
    filter: grayscale(0);
    transform: translateY(-2px);
}

.nav-label {
    font-size: 9px;
    font-weight: 700;
    color: #8e8e93;
    text-transform: uppercase;
}

.nav-item.active .nav-label { color: #ffffff; }

/* --- MORE PAGE STYLES --- */
.more-page {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 20px 5px;
    gap: 25px;
    animation: fadeIn 0.4s ease-out;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

.more-header-brand {
    text-align: center;
}

.more-logo {
    width: 100px;
    height: 100px;
    border-radius: 22px;
    margin-bottom: 12px;
    box-shadow: 0 10px 25px rgba(0,0,0,0.4);
    border: 1px solid rgba(255,255,255,0.1);
    object-fit: cover;
}

.more-header-brand h2 {
    font-size: 20px;
    font-weight: 800;
    letter-spacing: 0.5px;
    opacity: 0.9;
}

.more-group {
    width: 100%;
    background: rgba(255, 255, 255, 0.12);
    backdrop-filter: blur(15px);
    border-radius: 20px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    overflow: hidden;
}

.stats-card {
    display: flex;
    padding: 20px;
    justify-content: space-around;
    align-items: center;
}

.stat-box {
    text-align: center;
    flex: 1;
}

.stat-value {
    display: block;
    font-size: 24px;
    font-weight: 800;
    color: var(--accent-blue);
    text-shadow: 0 0 15px rgba(0, 122, 255, 0.3);
}

.stat-label {
    font-size: 10px;
    font-weight: 700;
    opacity: 0.5;
    letter-spacing: 1px;
    text-transform: uppercase;
}

.stat-divider {
    width: 1px;
    height: 30px;
    background: rgba(255, 255, 255, 0.1);
}

.more-item-link {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 20px;
    text-decoration: none;
    color: white;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    cursor: pointer;
    transition: background 0.2s;
}

.more-item-link:last-child { border-bottom: none; }
.more-item-link:active { background: rgba(255, 255, 255, 0.1); }

.more-item-content {
    display: flex;
    align-items: center;
    gap: 15px;
    font-weight: 600;
}

.item-icon { font-size: 20px; }

.arrow {
    font-size: 22px;
    opacity: 0.2;
    font-weight: 300;
}

.more-footer {
    text-align: center;
    font-size: 12px;
    opacity: 0.4;
    line-height: 1.8;
    margin-bottom: 40px;
}

/* --- AUTH & PROFILE STYLES --- */
.login-promo-card {
    background: linear-gradient(135deg, #007aff, #00c6ff);
    padding: 20px;
    border-radius: 20px;
    width: 100%;
    text-align: center;
    margin-bottom: 10px;
    box-shadow: 0 10px 20px rgba(0,122,255,0.2);
}

.user-profile-card {
    display: flex;
    align-items: center;
    background: rgba(255, 255, 255, 0.1);
    padding: 15px;
    border-radius: 20px;
    width: 100%;
    margin-bottom: 10px;
    border: 1px solid rgba(255, 255, 255, 0.05);
}

.user-profile-card img {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    border: 2px solid #007aff;
    object-fit: cover;
}

/* --- NOTIFICATIONS STYLES --- */
.notify-status {
    font-size: 10px;
    font-weight: 800;
    background: rgba(255, 255, 255, 0.1);
    padding: 3px 10px;
    border-radius: 8px;
    color: white;
    transition: all 0.3s ease;
    min-width: 40px;
    text-align: center;
}

/* --- RESPONSIVE FIXES --- */
@media (max-width: 375px) {
    .main-header h1 { font-size: 22px; }
    .nav-label { font-size: 8px; }
    .bottom-nav { width: 95%; height: 60px; }
}
