/* CSS variables for ultra smooth theme transition */
:root {
    --global-bg: #050811; 
    --surface-bg: rgba(17, 24, 39, 0.7); 
    --text-primary: #F9FAFB;
    --text-secondary: #9CA3AF;
    --brand-primary: #6366F1;
    --brand-gradient: linear-gradient(135deg, #8B5CF6 0%, #4F46E5 100%);
    --accent-glow: rgba(99, 102, 241, 0.25);
    --border-light: rgba(255, 255, 255, 0.08);
    --card-bg: linear-gradient(145deg, rgba(21, 29, 48, 0.5) 0%, rgba(11, 15, 25, 0.6) 100%);
    --shadow-color: rgba(0, 0, 0, 0.5);
}

[data-theme="light"] {
    --global-bg: #F3F4F6;
    --surface-bg: rgba(255, 255, 255, 0.85);
    --text-primary: #1F2937;
    --text-secondary: #4B5563;
    --brand-primary: #4F46E5;
    --brand-gradient: linear-gradient(135deg, #4F46E5 0%, #3730A3 100%);
    --accent-glow: rgba(79, 70, 229, 0.12);
    --border-light: rgba(0, 0, 0, 0.1);
    --card-bg: linear-gradient(145deg, #FFFFFF 0%, #E5E7EB 100%);
    --shadow-color: rgba(0, 0, 0, 0.08);
}

* { margin: 0; padding: 0; box-sizing: border-box; font-family: 'Plus Jakarta Sans', sans-serif; -webkit-tap-highlight-color: transparent; }
body { background-color: var(--global-bg); color: var(--text-primary); overflow-x: hidden; padding-bottom: 0px; transition: background-color 0.4s ease, color 0.4s ease; }

#main-wrapper { transition: filter 0.4s cubic-bezier(0.4, 0, 0.2, 1); display: flex; flex-direction: column; min-height: 100vh; }
.body-blur { filter: blur(15px); pointer-events: none; }

/* NAVBAR */
.navbar { background: rgba(5, 8, 17, 0.4); backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px); border-bottom: 1px solid var(--border-light); position: sticky; top: 0; z-index: 1000; padding: 0 16px; height: 70px; display: flex; align-items: center; justify-content: space-between; transition: background-color 0.4s; }
body[data-theme="light"] .navbar { background: rgba(243, 244, 246, 0.4); }

.nav-left { display: flex; align-items: center; gap: 14px; }
.custom-menu-btn { background: rgba(255, 255, 255, 0.02); border: 1px solid var(--border-light); width: 44px; height: 44px; border-radius: 14px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 5px; cursor: pointer; transition: all 0.3s; box-shadow: 0 4px 10px var(--shadow-color); }
.custom-menu-btn span { display: block; width: 20px; height: 2.5px; background: var(--text-primary); border-radius: 4px; }
.custom-menu-btn span:nth-child(2) { width: 14px; background: var(--brand-primary); margin-left: -6px; }

.brand-logo { text-decoration: none; font-size: 21px; font-weight: 800; background: var(--brand-gradient); -webkit-background-clip: text; -webkit-text-fill-color: transparent; }
.nav-actions { display: flex; align-items: center; gap: 12px; }
.action-icon-btn { background: rgba(255, 255, 255, 0.02); border: 1px solid var(--border-light); width: 40px; height: 40px; border-radius: 12px; display: flex; align-items: center; justify-content: center; color: var(--text-secondary); font-size: 15px; cursor: pointer; transition: all 0.3s; box-shadow: 0 2px 6px var(--shadow-color); text-decoration: none;}
.action-icon-btn:active { transform: scale(0.9); }

/* CONTAINER & COMPONENTS */
.container { padding: 18px; display: flex; flex-direction: column; gap: 24px; flex: 1; }
.promo-banner { background: var(--brand-gradient); padding: 24px 20px; border-radius: 22px; border: 1px solid rgba(255, 255, 255, 0.15); box-shadow: 0 15px 35px var(--accent-glow); color: #FFF; }
.promo-banner h2 { font-size: 20px; font-weight: 800; margin-bottom: 6px; }
.promo-banner p { font-size: 13px; opacity: 0.9; line-height: 1.6; }

.section-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 14px; }
.section-title { font-size: 16px; font-weight: 800; display: flex; align-items: center; gap: 8px; }
.section-title::before { content: ''; display: inline-block; width: 4px; height: 15px; background: var(--brand-gradient); border-radius: 10px; }

/* GRID CARD ARCHITECTURE */
.apps-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 14px; }
.app-card { background: var(--card-bg); border: 1px solid var(--border-light); border-radius: 20px; padding: 16px 14px; display: flex; flex-direction: column; gap: 14px; transition: all 0.3s ease; box-shadow: 0 6px 15px var(--shadow-color); cursor: pointer; }
.app-card:active { transform: translateY(2px); border-color: var(--brand-primary); }

.card-top { display: flex; align-items: center; gap: 12px; }
.app-icon { width: 52px; height: 52px; border-radius: 16px; display: flex; align-items: center; justify-content: center; font-weight: 800; font-size: 22px; color: #FFF; box-shadow: 0 8px 16px rgba(0,0,0,0.15); border: 1px solid rgba(255,255,255,0.2); flex-shrink: 0; object-fit: cover; }

.app-meta-box { display: flex; flex-direction: column; min-width: 0; }
.app-name { font-size: 13.5px; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: var(--text-primary); }
.app-category { font-size: 11px; color: var(--text-secondary); margin-top: 2px; }

.card-bottom { display: flex; justify-content: space-between; align-items: center; border-top: 1px solid var(--border-light); padding-top: 12px; }
.app-rating { font-size: 11.5px; font-weight: 700; color: #FBBF24; display: flex; align-items: center; gap: 4px; }
.app-tag { font-size: 10px; color: #10B981; font-weight: 700; background: rgba(16, 185, 129, 0.1); padding: 3px 10px; border-radius: 10px; max-width: 100px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; border: 1px solid rgba(16, 185, 129, 0.15); }
body[data-theme="light"] .app-tag { color: #047857; background: rgba(4, 120, 87, 0.08); border-color: rgba(4, 120, 87, 0.12); }

.loading-text { grid-column: span 2; text-align: center; padding: 20px; font-size: 14px; color: var(--text-secondary); }

/* OVERLAY SYSTEM */
.sheet-overlay { position: fixed; inset: 0; background: rgba(2, 4, 8, 0.4); z-index: 2000; opacity: 0; visibility: hidden; transition: all 0.4s ease; display: flex; align-items: center; justify-content: center; }
.sheet-overlay.active { opacity: 1; visibility: visible; }

/* 3D GLASS BOX ARCHITECTURE */
.bottom-sheet, .download-modal, .search-modal { position: fixed; bottom: 20px; left: 16px; right: 16px; background: var(--surface-bg); backdrop-filter: blur(35px); -webkit-backdrop-filter: blur(35px); border-radius: 28px; z-index: 2001; padding: 24px 20px; transform: translateY(150%) scale(0.9); transition: transform 0.4s cubic-bezier(0.34, 1.56, 0.64, 1), opacity 0.3s; border: 1px solid var(--border-light); box-shadow: 0 25px 50px rgba(0,0,0,0.25), 0 0 30px var(--accent-glow); opacity: 0; }
.bottom-sheet.active, .download-modal.active, .search-modal.active { transform: translateY(0) scale(1); opacity: 1; }

.sheet-handle { width: 40px; height: 5px; background: rgba(255,255,255,0.2); border-radius: 10px; margin: -10px auto 22px; }
body[data-theme="light"] .sheet-handle { background: rgba(0,0,0,0.15); }
.sheet-title { font-size: 16px; font-weight: 800; text-align: center; margin-bottom: 22px; }

.sheet-list { display: flex; flex-direction: column; gap: 12px; }
.sheet-item { background: rgba(255,255,255,0.02); border: 1px solid var(--border-light); padding: 15px 18px; border-radius: 18px; font-size: 14px; font-weight: 600; color: var(--text-secondary); display: flex; align-items: center; gap: 14px; cursor: pointer; }
.sheet-item i { font-size: 16px; width: 22px; text-align: center; color: var(--brand-primary); }
.sheet-item.active { background: var(--brand-gradient); color: #FFF; border-color: transparent; box-shadow: 0 10px 20px rgba(99, 102, 241, 0.35); }
.sheet-item.active i { color: #FFF; }

/* CUSTOM ANIMATED SEARCH MODAL */
.search-modal { bottom: auto; top: 100px; }
.search-inner-box { background: rgba(255,255,255,0.04); border: 1px solid var(--border-light); border-radius: 16px; padding: 14px 18px; display: flex; align-items: center; gap: 14px; }
body[data-theme="light"] .search-inner-box { background: rgba(0,0,0,0.03); }
.search-inner-box input { background: none; border: none; outline: none; color: var(--text-primary); width: 100%; font-size: 15px; font-weight: 600; }
.search-inner-box input::placeholder { color: var(--text-secondary); }

/* DOWNLOAD SCREEN UI */
.dl-header { display: flex; gap: 16px; align-items: center; margin-bottom: 20px; }
.dl-icon { width: 64px; height: 64px; border-radius: 18px; display: flex; align-items: center; justify-content: center; font-size: 26px; color: white; font-weight: 800; box-shadow: 0 8px 20px rgba(0,0,0,0.15); }
.dl-btn { background: var(--brand-gradient); color: white; border: none; width: 100%; padding: 16px; border-radius: 16px; font-size: 15px; font-weight: 800; cursor: pointer; display: flex; align-items: center; justify-content: center; gap: 10px; box-shadow: 0 8px 20px var(--accent-glow); margin-top: 10px; }

/* PREMIUM FOOTER */
.premium-footer { padding: 30px 20px 40px; text-align: center; background: linear-gradient(180deg, transparent 0%, rgba(5, 8, 17, 0.8) 100%); margin-top: auto; }
body[data-theme="light"] .premium-footer { background: linear-gradient(180deg, transparent 0%, rgba(229, 231, 235, 0.5) 100%); }
.footer-divider { width: 40px; height: 3px; background: var(--brand-gradient); border-radius: 10px; margin: 0 auto 18px; opacity: 0.6; }
.footer-copyright { font-size: 13px; font-weight: 700; color: var(--text-primary); margin-bottom: 8px; letter-spacing: 0.5px; }
.brand-glow-text { background: var(--brand-gradient); -webkit-background-clip: text; -webkit-text-fill-color: transparent; font-weight: 800; }
.footer-disclaimer { font-size: 11px; line-height: 1.6; color: var(--text-secondary); max-width: 500px; margin: 0 auto; opacity: 0.65; }

/* 3D BUBBLE SEARCH */
.search-results-bubble-box { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 20px; justify-content: center; max-height: 250px; overflow-y: auto; padding: 10px 5px; }
.search-bubble { background: linear-gradient(135deg, rgba(255, 255, 255, 0.08) 0%, rgba(255, 255, 255, 0.01) 100%); border: 1px solid rgba(255, 255, 255, 0.15); padding: 10px 18px; border-radius: 30px; display: flex; align-items: center; gap: 8px; font-size: 13px; font-weight: 700; color: var(--text-primary); cursor: pointer; box-shadow: 0 8px 20px rgba(0, 0, 0, 0.2), inset 0 2px 4px rgba(255,255,255,0.1); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); animation: bubblePop 0.4s cubic-bezier(0.34, 1.56, 0.64, 1) forwards; transition: transform 0.2s, box-shadow 0.2s, border-color 0.2s; }
[data-theme="light"] .search-bubble { background: linear-gradient(135deg, rgba(255, 255, 255, 0.8) 0%, rgba(243, 244, 246, 0.5) 100%); border: 1px solid rgba(0, 0, 0, 0.08); box-shadow: 0 6px 15px rgba(0, 0, 0, 0.05), inset 0 2px 4px rgba(255,255,255,0.6); }
.search-bubble:active { transform: scale(0.92); }
.search-bubble-icon { width: 24px; height: 24px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 11px; font-weight: 800; color: #FFF; object-fit: cover; }
@keyframes bubblePop { 0% { transform: scale(0) translateY(20px); opacity: 0; } 100% { transform: scale(1) translateY(0); opacity: 1; } }
