:root {
    --primary: #6366f1;
    --primary-dark: #4f46e5;
    --secondary: #8b5cf6;
    --accent: #ec4899;
    --bg-primary: #0f172a;
    --bg-secondary: #1e293b;
    --bg-card: rgba(30, 41, 59, 0.8);
    --text-primary: #f1f5f9;
    --text-secondary: #94a3b8;
    --border: rgba(148, 163, 184, 0.1);
    --shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
    --gradient: linear-gradient(135deg, var(--primary) 0%, var(--secondary) 100%);
    --danger: #ef4444; 
}

[data-theme="light"] {
    --bg-primary: #f8fafc;
    --bg-secondary: #ffffff;
    --bg-card: rgba(255, 255, 255, 0.9);
    --text-primary: #1e293b;
    --text-secondary: #64748b;
    --border: rgba(100, 116, 139, 0.1);
    --shadow: 0 10px 30px rgba(0, 0, 0, 0.1);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    min-height: 100vh;
    transition: all 0.3s ease;
    overflow-x: hidden;
}

body::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: 
        radial-gradient(circle at 20% 50%, rgba(99, 102, 241, 0.1) 0%, transparent 50%),
        radial-gradient(circle at 80% 80%, rgba(139, 92, 246, 0.1) 0%, transparent 50%),
        radial-gradient(circle at 40% 20%, rgba(236, 72, 153, 0.1) 0%, transparent 50%);
    z-index: -1;
    animation: gradientShift 20s ease infinite;
}

@keyframes gradientShift {
    0%, 100% { transform: translate(0, 0) rotate(0deg); }
    33% { transform: translate(-20px, -20px) rotate(120deg); }
    66% { transform: translate(20px, -10px) rotate(240deg); }
}

/* Navigation Bar */
.navbar {
    background: var(--bg-card);
    backdrop-filter: blur(10px);
    border-bottom: 1px solid var(--border);
    padding: 1rem 1.5rem;
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: var(--shadow);
}

.navbar-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    max-width: 1200px;
    margin: 0 auto;
}

.nav-icon {
    background: var(--gradient);
    border: none;
    color: white;
    width: 40px;
    height: 40px;
    border-radius: 12px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    font-size: 1.2rem;
}

.app-title {
    font-size: 1.5rem;
    font-weight: 700;
    background: var(--gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

/* Search Overlay */
.search-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(15, 23, 42, 0.95);
    backdrop-filter: blur(10px);
    z-index: 200;
    display: none;
    align-items: flex-start;
    justify-content: center;
    padding-top: 5rem;
    animation: fadeIn 0.3s ease;
}

.search-input {
    width: 100%;
    padding: 1rem 3rem 1rem 1.5rem;
    background: var(--bg-card);
    border: 2px solid var(--primary);
    border-radius: 20px;
    color: var(--text-primary);
    font-size: 1.1rem;
    outline: none;
    transition: all 0.3s ease;
}

.search-close {
    position: absolute;
    right: 15px;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 1.2rem;
    cursor: pointer;
}

/* Tabs */
.tabs-container {
    background: var(--bg-card);
    padding: 1rem;
    margin: 1rem;
    border-radius: 20px;
    box-shadow: var(--shadow);
}

.tabs {
    display: flex;
    gap: 0.5rem;
    overflow-x: auto;
    scrollbar-width: none;
}

.tab {
    padding: 0.75rem 1.5rem;
    background: transparent;
    border: 2px solid var(--border);
    border-radius: 15px;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.3s ease;
    white-space: nowrap;
    font-weight: 500;
}

.tab.active {
    background: var(--gradient);
    border-color: transparent;
    color: white;
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(99, 102, 241, 0.3);
}

/* App Cards / Product Grid */
.apps-container {
    padding: 1rem;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); 
    gap: 1rem;
    max-width: 1200px;
    margin: 0 auto;
}

@media (min-width: 768px) {
    .apps-container {
        grid-template-columns: repeat(4, 1fr); 
        gap: 1.5rem;
    }
}

.app-card {
    background: var(--bg-card);
    backdrop-filter: blur(10px);
    border: 1px solid var(--border);
    border-radius: 20px;
    padding: 1rem;
    transition: all 0.3s ease;
    cursor: pointer;
    animation: slideUp 0.5s ease;
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
}

/* Sort Options */
.sort-container {
    padding: 1rem;
    display: flex;
    justify-content: flex-start;
    gap: 0.5rem;
    overflow-x: auto;
    scrollbar-width: none;
    padding-bottom: 0.5rem;
    margin: 0 1rem;
}
.sort-container::-webkit-scrollbar {
    display: none;
}

.sort-btn {
    padding: 0.75rem 1rem;
    background: var(--bg-card);
    border: 2px solid var(--border);
    border-radius: 15px;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.3s ease;
    white-space: nowrap;
    font-weight: 500;
}

.sort-btn.active {
    background: var(--gradient);
    border-color: transparent;
    color: white;
}

/* --- Modals CSS (CRITICAL FIX: Ensuring Display: none;) --- */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(15, 23, 42, 0.95);
    backdrop-filter: blur(10px);
    z-index: 300;
    display: none !important; /* KEY FIX: Force hide initially */
    align-items: center;
    justify-content: center;
    padding: 1rem;
    overflow-y: auto; 
    opacity: 0;
    transition: opacity 0.3s ease-in-out;
}

.modal.active {
    display: flex !important;
    opacity: 1; /* Force show when active */
}

.modal-content {
    background: var(--bg-card);
    border-radius: 20px;
    padding: 2rem;
    width: 100%;
    max-width: 500px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: var(--shadow);
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
}

.modal-title {
    font-size: 1.5rem;
    font-weight: 700;
    background: var(--gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.modal-close {
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 1.5rem;
    cursor: pointer;
    transition: color 0.3s ease;
}

/* Forms */
.form-group {
    margin-bottom: 1rem;
}
.form-label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 600;
    color: var(--text-primary);
}
.form-input, .form-textarea, .form-select {
    width: 100%;
    padding: 0.75rem;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 10px;
    color: var(--text-primary);
    font-size: 1rem;
    outline: none;
    transition: border-color 0.3s;
}
.form-button {
    width: 100%;
    padding: 1rem;
    margin-top: 1rem;
    background: var(--primary);
    border: none;
    border-radius: 10px;
    color: white;
    font-size: 1.1rem;
    font-weight: 700;
    cursor: pointer;
    transition: background 0.3s ease;
}

/* Settings/Menu List */
.settings-list {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}
.settings-item {
    background: var(--bg-secondary);
    border: none;
    color: var(--text-primary);
    text-align: left;
    padding: 1rem;
    border-radius: 10px;
    font-size: 1rem;
    cursor: pointer;
    transition: background 0.2s;
    display: flex;
    align-items: center;
}
.settings-item i {
    margin-right: 10px;
    color: var(--primary);
}
.settings-item:hover {
    background: rgba(99, 102, 241, 0.1);
}
/* --- End Modals CSS --- */


/* --- Bottom Navigation Styles --- */
main {
    padding-bottom: 70px; /* Space for fixed bottom navigation */
}

.bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 60px;
    background: var(--bg-card);
    backdrop-filter: blur(8px);
    box-shadow: 0 -5px 20px rgba(0, 0, 0, 0.1);
    display: flex;
    justify-content: space-around;
    align-items: center;
    border-top: 1px solid var(--border);
    z-index: 1000;
    padding: 0 10px;
}

.nav-item {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    padding: 5px;
    display: flex;
    flex-direction: column;
    align-items: center;
    font-size: 0.75rem;
    cursor: pointer;
    transition: color 0.3s ease;
    min-width: 50px;
}

.nav-item i {
    font-size: 1.2rem;
    margin-bottom: 2px;
}

.nav-item.active {
    color: var(--primary); 
}

.nav-upload {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: var(--gradient) !important;
    color: white;
    box-shadow: 0 4px 15px rgba(99, 102, 241, 0.6);
    transform: translateY(-20px);
    transition: transform 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-direction: row; 
    font-size: 1.5rem;
}

/* --- Profile Page Styles (Instagram Style) --- */
.profile-view {
    padding: 1rem 0 2rem 0;
    max-width: 800px;
    margin: 0 auto;
}
.profile-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    padding: 0 1rem;
}
.profile-pic-area {
    width: 100px;
    height: 100px;
    border-radius: 50%;
    background: var(--bg-secondary);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-secondary);
    font-size: 2rem;
    box-shadow: var(--shadow);
}
.profile-wallet-icon {
    background: var(--accent);
    color: white;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    cursor: pointer;
    box-shadow: 0 2px 10px rgba(236, 72, 153, 0.5);
    margin-top: 10px;
}

.profile-metrics {
    display: flex;
    justify-content: space-between;
    background: var(--bg-secondary);
    padding: 1rem;
    border-radius: 15px;
    margin-bottom: 1rem;
    text-align: center;
    gap: 10px;
}
.profile-metrics strong {
    font-size: 1.2rem;
    color: var(--primary);
    font-weight: 700;
}
.profile-metrics span {
    font-size: 0.8rem;
    color: var(--text-secondary);
    margin-top: 2px;
}

.edit-profile-btn {
    width: 100%;
    padding: 0.6rem;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 10px;
    color: var(--text-primary);
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s;
}

.profile-options button {
    background: var(--danger);
    color: white;
    border: none;
    padding: 0.6rem 1rem;
    border-radius: 10px;
    margin-top: 1rem;
    cursor: pointer;
}
.profile-options {
    display: flex;
    justify-content: space-around;
}
.verified-badge-lg {
    color: #2563eb;
    margin-left: 5px;
}

/* Utility */
.loading-spinner {
    border: 4px solid rgba(255, 255, 255, 0.1);
    border-top: 4px solid var(--primary);
    border-radius: 50%;
    width: 40px;
    height: 40px;
    animation: spin 1s linear infinite;
    margin: 50px auto;
    display: none;
}
.loading-spinner.active {
    display: block;
}
@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.toast {
    position: fixed;
    bottom: 80px;
    left: 50%;
    transform: translateX(-50%);
    background: #10b981;
    color: white;
    padding: 1rem 1.5rem;
    border-radius: 10px;
    box-shadow: var(--shadow);
    z-index: 10000;
    display: none;
    align-items: center;
    gap: 10px;
    font-weight: 600;
}

.toast.error {
    background: var(--danger);
}
