@import url('https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:wght@400;700;800&display=swap');

/* THE CANVAS FIX: 
   Syncs the browser's base layer color to your specific theme backgrounds.
   This kills the "white sneak-in" during fast scrolls.
*/
html { background-color: #050505; transition: background-color 0.3s ease; }
html:has(body.theme-light) { background-color: #f4f4f5; }
html:has(body.theme-blue) { background-color: #020617; }

/* Variable Definitions */
:root {
    --bg: #050505;
    --card-bg: #121212;
    --text-main: #ffffff;
    --text-dim: #71717a;
    --border: rgba(255, 255, 255, 0.1);
    --input-bg: rgba(255, 255, 255, 0.05);
}

body.theme-light {
    --bg: #f4f4f5;
    --card-bg: #ffffff;
    --text-main: #09090b; 
    --text-dim: #71717a;
    --border: rgba(0, 0, 0, 0.1);
    --input-bg: #ededf0;
}

body.theme-blue {
    --bg: #020617;
    --card-bg: #0f172a;
    --text-main: #f8fafc;
    --text-dim: #94a3b8;
    --border: rgba(255, 255, 255, 0.08);
    --input-bg: rgba(255, 255, 255, 0.03);
}

/* Global Apply */
body { 
    font-family: 'Plus Jakarta Sans', sans-serif; 
    background-color: var(--bg); 
    color: var(--text-main);
    transition: background-color 0.3s ease, color 0.3s ease; 
    overflow-x: hidden; 
    margin: 0;
    min-height: 100vh;
}

/* SCROLL-UP OPTIMIZATION:
   Add this class to your post card containers.
   It tells the browser not to "forget" the layout when off-screen.
*/
.post-container-item {
    content-visibility: auto;
    contain-intrinsic-size: 1px 500px; /* Adjust 500px to your avg post height */
}

.glass-header {
    position: sticky; top: 0; z-index: 50;
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    background: var(--input-bg);
    border-bottom: 1px solid var(--border);
    padding: 0.6rem 1.2rem;
}

/* Target all Modals and Containers */
#token-bar, #auth-modal > div, #profile-modal > div, #upgrade-modal > div, #token-modal > div, #withdraw-modal > div {
    background-color: var(--card-bg) !important;
    color: var(--text-main) !important;
    border-color: var(--border) !important;
}

/* Specific ID Fixes */
#token-count, #calc-gross, #pro-name-preview, #withdraw-modal h2, #token-modal h2,
.pack-option span:not(.text-amber-500) {
    color: var(--text-main) !important;
}

/* Target Inputs and Items */
input, .pack-option, #payout-history-list > div {
    background-color: var(--input-bg) !important;
    color: var(--text-main) !important;
    border-color: var(--border) !important;
}

/* Button Adaptations for Light Mode */
body.theme-light button.bg-zinc-800 {
    background-color: #e4e4e7 !important;
    color: #09090b !important;
    border-color: rgba(0,0,0,0.1) !important;
}

.truncate-name { max-width: 100px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; display: inline-block; }
.premium-tag { background: #F59E0B; color: black; font-size: 8px; font-weight: 900; padding: 2px 5px; border-radius: 4px; position: absolute; top: 4px; right: 4px; }
.theme-btn.active { outline: 2px solid #F59E0B; outline-offset: 2px; }

.custom-scrollbar::-webkit-scrollbar { width: 4px; }
.custom-scrollbar::-webkit-scrollbar-thumb { background: var(--border); border-radius: 10px; }

.stop-scrolling { height: 100vh; overflow: hidden; }

/* Vault Access Master Overlay */
#admin-verify-modal {
    position: fixed; inset: 0; width: 100%; height: 100%; z-index: 9999; 
    display: flex; align-items: center; justify-content: center;
    background-color: rgba(0, 0, 0, 0.85); backdrop-filter: blur(8px); padding: 1rem;
}
#admin-verify-modal.hidden { display: none !important; }
#admin-verify-modal:not(.hidden) > div { animation: modalPop 0.3s ease-out; }

@keyframes modalPop {
    from { transform: scale(0.9); opacity: 0; }
    to { transform: scale(1); opacity: 1; }
}

/* Animations & Skeletons */
@keyframes shimmer {
    0% { background-position: -200% 0; }
    100% { background-position: 200% 0; }
}

@keyframes shimmer-swipe {
    100% { transform: translateX(100%); }
}

@keyframes shimmer-pulse {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

.skeleton-item {
    background: linear-gradient(90deg, #18181b 25%, #27272a 50%, #18181b 75%);
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite linear;
}

.skeleton-card {
    background-color: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: 32px;
    padding: 1.25rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
    position: relative;
    overflow: hidden;
}

.shimmer {
    position: relative;
    overflow: hidden;
    background-color: var(--input-bg);
}

.shimmer::after {
    content: "";
    position: absolute;
    inset: 0;
    transform: translateX(-100%);
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.05), transparent);
    animation: shimmer-swipe 1.5s infinite;
}

body.theme-light .shimmer::after {
    background: linear-gradient(90deg, transparent, rgba(0, 0, 0, 0.05), transparent);
}

/* Loader Styles */
#master-loader {
    position: fixed; top: 72px; left: 0; right: 0; bottom: 0;
    background: var(--bg);
    z-index: 40;
    transition: opacity 0.6s ease, visibility 0.6s;
}

#master-loader .shimmer {
    background: linear-gradient(90deg, var(--input-bg) 25%, var(--border) 50%, var(--input-bg) 75%);
    background-size: 200% 100%;
    animation: shimmer-pulse 1.5s infinite linear;
}

.loader-fade-out { opacity: 0 !important; pointer-events: none !important; visibility: hidden; }
.hide-loader { opacity: 0; pointer-events: none; transition: opacity 0.5s ease; }

/* Notification System (iOS Style) */
#notify-box {
    position: fixed; top: 20px; left: 50%;
    transform: translateX(-50%);
    z-index: 9999; display: flex; flex-direction: column;
    align-items: center; pointer-events: none; width: 100%;
}

.toast {
    background: rgba(28, 28, 30, 0.8);
    backdrop-filter: blur(15px) saturate(180%);
    -webkit-backdrop-filter: blur(15px) saturate(180%);
    color: white;
    padding: 12px 24px; border-radius: 24px;
    font-size: 13px; font-weight: 600;
    letter-spacing: -0.2px; margin-bottom: 10px;
    border: 0.5px solid rgba(255, 255, 255, 0.1);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
    opacity: 0; transform: translateY(-20px) scale(0.9);
    transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.toast.show { opacity: 1; transform: translateY(0) scale(1); pointer-events: auto; }
.loader-fade-out {
    opacity: 0 !important;
    visibility: hidden !important;
    pointer-events: none !important;
    transition: opacity 0.6s ease, visibility 0.6s;
}
