/* ============================================
   InvestLinks — Shared styles
   Dark mode, scroll progress, back-to-top,
   mega-menu, mobile slide-in, animated counters
   ============================================ */

/* --- Dark mode overrides --- */
html.dark { color-scheme: dark; }
html.dark body { background: #0b1220; color: #94a3b8; }

html.dark .bg-white { background: #111827 !important; }
html.dark .bg-surface { background: #0b1220 !important; }
html.dark .bg-slate-50 { background: rgba(255,255,255,0.03) !important; }
html.dark .bg-slate-100 { background: rgba(255,255,255,0.05) !important; }

html.dark .glass-nav { background: rgba(11,18,32,0.85) !important; border-bottom-color: rgba(255,255,255,0.06) !important; }
html.dark .glass-card { background: rgba(17,24,39,0.85) !important; border-color: rgba(255,255,255,0.05) !important; box-shadow: 0 8px 32px 0 rgba(0,0,0,0.3) !important; }

html.dark .text-slate-900 { color: #f1f5f9 !important; }
html.dark .text-slate-800 { color: #e2e8f0 !important; }
html.dark .text-slate-700 { color: #cbd5e1 !important; }
html.dark .text-slate-600 { color: #94a3b8 !important; }
html.dark .text-slate-500 { color: #64748b !important; }
html.dark .text-slate-400 { color: #475569 !important; }

/* Override inline-styled black text in dark mode (from direct edits) */
html.dark [style*="color: rgb(0, 0, 0)"],
html.dark [style*="color: #000"],
html.dark [style*="color:#000"],
html.dark [style*="color: black"] { color: #f1f5f9 !important; }

html.dark .border-slate-100 { border-color: rgba(255,255,255,0.05) !important; }
html.dark .border-slate-200 { border-color: rgba(255,255,255,0.08) !important; }
html.dark .divide-slate-100 > * + * { border-color: rgba(255,255,255,0.05) !important; }

html.dark .bg-primary-50 { background: rgba(37,99,235,0.12) !important; }
html.dark .bg-blue-50 { background: rgba(37,99,235,0.12) !important; }
html.dark .bg-indigo-50 { background: rgba(99,102,241,0.12) !important; }
html.dark .bg-sky-50 { background: rgba(14,165,233,0.12) !important; }
html.dark .bg-emerald-50 { background: rgba(16,185,129,0.12) !important; }
html.dark .bg-amber-50 { background: rgba(245,158,11,0.12) !important; }
html.dark .bg-rose-50 { background: rgba(244,63,94,0.12) !important; }
html.dark .bg-purple-50 { background: rgba(168,85,247,0.12) !important; }
html.dark .bg-green-50 { background: rgba(16,185,129,0.12) !important; }
html.dark .bg-green-100 { background: rgba(16,185,129,0.18) !important; }
html.dark .bg-primary-100 { background: rgba(37,99,235,0.18) !important; }
html.dark .bg-primary-50\/30 { background: rgba(37,99,235,0.06) !important; }

html.dark .border-primary-100 { border-color: rgba(37,99,235,0.3) !important; }
html.dark .border-primary-200 { border-color: rgba(37,99,235,0.4) !important; }
html.dark .border-green-200 { border-color: rgba(16,185,129,0.3) !important; }

html.dark .from-white { --tw-gradient-from: #111827 var(--tw-gradient-from-position) !important; }
html.dark .via-white\/50 { --tw-gradient-stops: var(--tw-gradient-from), rgba(17,24,39,0.5), var(--tw-gradient-to) !important; }
html.dark .to-surface { --tw-gradient-to: #0b1220 var(--tw-gradient-to-position) !important; }
html.dark .from-white\/0 { --tw-gradient-from: rgba(17,24,39,0) var(--tw-gradient-from-position) !important; }

html.dark .border-white { border-color: rgba(255,255,255,0.1) !important; }
html.dark .bg-slate-900 { background: #060912 !important; }

html.dark input, html.dark textarea, html.dark select {
    background: rgba(255,255,255,0.04) !important;
    border-color: rgba(255,255,255,0.1) !important;
    color: #e2e8f0 !important;
}
html.dark input::placeholder, html.dark textarea::placeholder { color: #475569 !important; }

html.dark .marquee img {
    filter: none;
    opacity: 0.95;
    background: white;
    padding: 8px 14px;
    border-radius: 12px;
}
html.dark .marquee img:hover { opacity: 1; transform: scale(1.05); }

html.dark .bg-grid-pattern {
    background-image: linear-gradient(to right, rgba(255,255,255,0.04) 1px, transparent 1px),
                      linear-gradient(to bottom, rgba(255,255,255,0.04) 1px, transparent 1px) !important;
}

/* --- Scroll progress bar --- */
.scroll-progress {
    position: fixed;
    top: 0; left: 0;
    height: 3px;
    width: 0;
    background: linear-gradient(90deg, #2563eb 0%, #60a5fa 100%);
    z-index: 100;
    transition: width 0.1s linear;
    box-shadow: 0 0 10px rgba(37,99,235,0.5);
}

/* --- Back to top button --- */
.back-to-top {
    position: fixed;
    bottom: 24px;
    right: 24px;
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: #2563eb;
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 8px 24px rgba(37,99,235,0.4);
    opacity: 0;
    transform: translateY(20px) scale(0.8);
    pointer-events: none;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 90;
    border: none;
    cursor: pointer;
}
.back-to-top.visible { opacity: 1; transform: translateY(0) scale(1); pointer-events: auto; }
.back-to-top:hover { background: #1d4ed8; transform: translateY(-4px) scale(1.05); }

/* --- Mega menu --- */
.has-mega { position: relative; }
.mega-menu {
    position: absolute;
    top: calc(100% + 14px);
    left: 50%;
    transform: translateX(-50%) translateY(-8px);
    width: 720px;
    max-width: 92vw;
    background: rgba(255,255,255,0.98);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid rgba(0,0,0,0.05);
    border-radius: 24px;
    box-shadow: 0 24px 60px -20px rgba(15,23,42,0.25);
    padding: 24px;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease, transform 0.2s ease;
    z-index: 60;
}
html.dark .mega-menu { background: rgba(17,24,39,0.98); border-color: rgba(255,255,255,0.06); }
.has-mega:hover .mega-menu,
.has-mega:focus-within .mega-menu {
    opacity: 1;
    pointer-events: auto;
    transform: translateX(-50%) translateY(0);
}
.mega-menu::before {
    content: '';
    position: absolute;
    top: -14px;
    left: 0; right: 0;
    height: 14px;
}
.mega-item {
    display: flex;
    gap: 12px;
    padding: 12px;
    border-radius: 14px;
    transition: background 0.15s ease;
    text-decoration: none;
}
.mega-item:hover { background: #f1f5f9; }
html.dark .mega-item:hover { background: rgba(255,255,255,0.04); }
.mega-icon {
    width: 36px; height: 36px;
    border-radius: 10px;
    display: flex; align-items: center; justify-content: center;
    flex-shrink: 0;
}
.mega-title { font-weight: 600; color: #0f172a; font-size: 0.875rem; margin-bottom: 2px; line-height: 1.3; }
.mega-desc { font-size: 0.75rem; color: #64748b; line-height: 1.4; }
html.dark .mega-title { color: #f1f5f9; }
html.dark .mega-desc { color: #94a3b8; }

/* --- Mobile menu slide-in --- */
.mobile-menu-panel {
    position: fixed;
    top: 0; right: 0;
    width: 320px;
    max-width: 85vw;
    height: 100vh;
    background: rgba(255,255,255,0.98);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    box-shadow: -20px 0 60px -20px rgba(0,0,0,0.2);
    transform: translateX(100%);
    transition: transform 0.35s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 100;
    padding: 24px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
}
html.dark .mobile-menu-panel { background: rgba(11,18,32,0.98); }
.mobile-menu-panel.open { transform: translateX(0); }
.mobile-menu-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(15,23,42,0.4);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
    z-index: 99;
}
.mobile-menu-backdrop.open { opacity: 1; pointer-events: auto; }
.mobile-menu-panel a {
    display: block;
    padding: 14px 16px;
    border-radius: 12px;
    font-weight: 500;
    color: #334155;
    transition: all 0.15s ease;
}
.mobile-menu-panel a:hover { background: #f1f5f9; color: #2563eb; }
.mobile-menu-panel a.active { background: #eff6ff; color: #2563eb; }
html.dark .mobile-menu-panel a { color: #cbd5e1; }
html.dark .mobile-menu-panel a:hover { background: rgba(37,99,235,0.1); color: #60a5fa; }
html.dark .mobile-menu-panel a.active { background: rgba(37,99,235,0.15); color: #60a5fa; }

/* --- Active nav item helper --- */
.nav-active-marker { position: relative; }
.nav-active-marker::after {
    content: '';
    position: absolute;
    bottom: -6px;
    left: 0;
    height: 2px;
    width: 100%;
    background: #2563eb;
    border-radius: 2px;
}

/* --- Animated counter --- */
[data-count] { display: inline-block; font-variant-numeric: tabular-nums; }

/* --- Reduce motion --- */
@media (prefers-reduced-motion: reduce) {
    .scroll-progress, .back-to-top, .mobile-menu-panel, .mega-menu { transition: none !important; }
}
