/* =========================================================
   TradePulse — Custom Theme
   Layered on top of Bootstrap 5.3 (data-bs-theme="dark")
   ========================================================= */

:root {
    --accent: #00d9a3;
    --accent-rgb: 0, 217, 163;
    --accent-2: #0ea5e9;

    --bg-black: #05070a;
    --bg-dark: #0a0e14;
    --bg-surface: #0d1219;
    --bg-card: #10151d;

    --border-subtle: rgba(255, 255, 255, 0.08);
    --border-subtle-strong: rgba(255, 255, 255, 0.14);

    --text-muted-2: #7d8a9c;
}

html, body {
    background-color: var(--bg-dark);
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    font-size: 0.975rem;
}

code, .font-mono {
    font-family: 'JetBrains Mono', 'Courier New', monospace;
}

::selection {
    background: rgba(var(--accent-rgb), 0.35);
    color: #fff;
}

/* Scrollbar */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: var(--bg-dark); }
::-webkit-scrollbar-thumb { background: #232b38; border-radius: 6px; }
::-webkit-scrollbar-thumb:hover { background: #2e3847; }

/* ---------------------------------------------------------
   Utility helpers
   --------------------------------------------------------- */
.text-accent { color: var(--accent) !important; }
.bg-accent {
    /* No standalone --bs-bg-opacity declaration here on purpose:
       this file loads after Bootstrap's own CSS (including its
       .bg-opacity-* utilities), so declaring the variable here would
       always win the cascade and silently override bg-opacity-10
       etc. Using it only as a var() fallback lets Bootstrap's own
       utility classes set it normally when present. */
    background-color: rgba(var(--accent-rgb), var(--bs-bg-opacity, 1)) !important;
    color: #04150f;
}
.border-accent { border-color: rgba(var(--accent-rgb), var(--bs-border-opacity, 1)) !important; }

.btn-accent {
    background: var(--accent);
    border: 1px solid var(--accent);
    color: #04150f;
    font-weight: 600;
    transition: filter .15s ease, transform .15s ease;
}
.btn-accent:hover, .btn-accent:focus {
    filter: brightness(1.1);
    color: #04150f;
    transform: translateY(-1px);
}

.btn-outline-accent {
    border: 1px solid rgba(var(--accent-rgb), 0.55);
    color: var(--accent);
    background: transparent;
    font-weight: 500;
    transition: background .15s ease, color .15s ease;
}
.btn-outline-accent:hover {
    background: var(--accent);
    color: #04150f;
}

.hover-accent { transition: color .15s ease; }
.hover-accent:hover { color: var(--accent) !important; }

.fs-7 { font-size: 0.75rem; }
.max-w-lg { max-width: 560px; }
.max-w-md { max-width: 540px; }
.min-vh-50 { min-height: 50vh; }

.rounded-4 { border-radius: 1rem !important; }

/* ---------------------------------------------------------
   Backgrounds / surfaces
   --------------------------------------------------------- */
.bg-dark-glass {
    /* No backdrop-filter: on a sticky/fixed element it forces the
       browser to re-blur everything scrolling underneath it on every
       single frame — one of the more expensive things CSS can do
       during scroll. A solid near-opaque background gives a very
       similar look for effectively zero ongoing cost. */
    background: rgba(8, 11, 16, 0.94);
}

.bg-dark-surface { background-color: var(--bg-surface) !important; }
.bg-dark-card { background-color: var(--bg-card) !important; }

.card-glass,
.market-card,
.about-card,
.hero-chart-card,
.contact-card,
.cta-box {
    background: var(--bg-card);
    border: 1px solid var(--border-subtle);
    border-radius: 1rem;
    padding: 1.25rem;
    transition: border-color .2s ease, transform .2s ease;
}

.market-card:hover,
.about-card:hover {
    border-color: var(--border-subtle-strong);
    transform: translateY(-2px);
}

.cta-box {
    background: linear-gradient(135deg, rgba(var(--accent-rgb), 0.12), rgba(14, 165, 233, 0.08));
    border: 1px solid rgba(var(--accent-rgb), 0.2);
}

.spin { animation: spin 1s linear infinite; display: inline-block; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------------------------------------------------------
   Navbar / brand
   --------------------------------------------------------- */
.navbar {
    padding-top: 0.85rem;
    padding-bottom: 0.85rem;
    border-bottom: 1px solid var(--border-subtle);
}

.brand-icon {
    width: 42px;
    height: 42px;
    border-radius: 12px;
    background: linear-gradient(135deg, var(--accent), var(--accent-2));
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    color: #04150f;
    flex-shrink: 0;
}
.brand-icon.sm { width: 32px; height: 32px; font-size: 1rem; border-radius: 9px; }

.nav-link {
    font-size: 0.9rem;
    font-weight: 500;
    color: #b9c2cf !important;
    position: relative;
}
.nav-link.active, .nav-link:hover { color: #fff !important; }
.nav-link.active::after {
    content: '';
    position: absolute;
    left: 0.5rem; right: 0.5rem; bottom: -2px;
    height: 2px;
    background: var(--accent);
    border-radius: 2px;
}

/* ---------------------------------------------------------
   Hero
   --------------------------------------------------------- */
.hero-section { padding-top: 1.5rem; }

.hero-bg {
    position: absolute;
    inset: -10% -10% auto -10%;
    height: 130%;
    background:
        radial-gradient(600px 400px at 15% 10%, rgba(var(--accent-rgb), 0.16), transparent 60%),
        radial-gradient(500px 350px at 85% 30%, rgba(14, 165, 233, 0.14), transparent 60%);
    z-index: 0;
    pointer-events: none;
}

.hero-title { letter-spacing: -0.02em; line-height: 1.1; }

.text-gradient {
    background: linear-gradient(90deg, var(--accent), var(--accent-2));
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

.hero-chart-card { padding: 1.5rem; box-shadow: 0 20px 60px -20px rgba(0, 0, 0, 0.6); }

.sparkline, .mini-sparkline { width: 100%; height: 56px; display: block; }
.mini-sparkline { height: 40px; margin-top: 0.5rem; }
.sparkline svg, .mini-sparkline svg { width: 100%; height: 100%; overflow: visible; }

/* ---------------------------------------------------------
   Market cards
   --------------------------------------------------------- */
.coin-icon { width: 30px; height: 30px; border-radius: 50%; flex-shrink: 0; }

/* ---------------------------------------------------------
   Icon boxes
   --------------------------------------------------------- */
.icon-box {
    width: 46px;
    height: 46px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    flex-shrink: 0;
}
.icon-box.lg { width: 66px; height: 66px; font-size: 1.75rem; border-radius: 16px; }

/* ---------------------------------------------------------
   News cards
   --------------------------------------------------------- */
.news-card {
    background: var(--bg-card);
    border: 1px solid var(--border-subtle);
    border-radius: 1rem;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    transition: border-color .2s ease, transform .2s ease;
}
.news-card:hover { border-color: var(--border-subtle-strong); transform: translateY(-3px); }

.news-image-wrapper {
    position: relative;
    height: 180px;
    overflow: hidden;
    background: #0a0d12;
}
.news-image {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform .35s ease;
}
.news-card:hover .news-image { transform: scale(1.06); }

.news-badge {
    position: absolute;
    top: 0.75rem;
    left: 0.75rem;
    background: var(--accent);
    color: #04150f;
    padding: 0.25rem 0.65rem;
    border-radius: 999px;
    font-size: 0.68rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.line-clamp-2 {
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}
.line-clamp-3 {
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* ---------------------------------------------------------
   Filter chips (news / markets)
   --------------------------------------------------------- */
.chip-filter {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.4rem 0.9rem;
    border-radius: 999px;
    border: 1px solid var(--border-subtle);
    color: #b9c2cf;
    background: transparent;
    font-size: 0.85rem;
    text-decoration: none;
    transition: all .15s ease;
}
.chip-filter:hover { border-color: rgba(var(--accent-rgb), 0.5); color: #fff; }
.chip-filter.active {
    background: rgba(var(--accent-rgb), 0.12);
    border-color: rgba(var(--accent-rgb), 0.5);
    color: var(--accent);
    font-weight: 600;
}

/* ---------------------------------------------------------
   Markets table
   --------------------------------------------------------- */
.market-table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
}
.market-table thead th {
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--text-muted-2);
    border-bottom: 1px solid var(--border-subtle);
    padding: 0.75rem 1rem;
    font-weight: 600;
}
.market-table tbody td {
    padding: 0.85rem 1rem;
    border-bottom: 1px solid var(--border-subtle);
    vertical-align: middle;
}
.market-table tbody tr { transition: background .15s ease; }
.market-table tbody tr:hover { background: rgba(255, 255, 255, 0.02); }
.market-table tbody tr:last-child td { border-bottom: none; }

.change-pill {
    display: inline-flex;
    align-items: center;
    gap: 0.2rem;
    padding: 0.2rem 0.55rem;
    border-radius: 999px;
    font-size: 0.8rem;
    font-weight: 600;
}
.change-pill.up { background: rgba(34, 197, 94, 0.14); color: #22c55e; }
.change-pill.down { background: rgba(239, 68, 68, 0.14); color: #ef4444; }

/* ---------------------------------------------------------
   Pagination
   --------------------------------------------------------- */
.pagination .page-link {
    background: var(--bg-card);
    border: 1px solid var(--border-subtle);
    color: #c8d0dc;
}
.pagination .page-item.active .page-link {
    background: var(--accent);
    border-color: var(--accent);
    color: #04150f;
    font-weight: 600;
}
.pagination .page-link:hover { background: #161c26; color: #fff; }

/* ---------------------------------------------------------
   Forms (Contact page, Search modal, Newsletter)
   --------------------------------------------------------- */
.form-control, .form-select {
    background-color: #0b0f16;
    border: 1px solid var(--border-subtle-strong);
    color: #e6eaef;
}
.form-control:focus, .form-select:focus {
    background-color: #0b0f16;
    border-color: rgba(var(--accent-rgb), 0.55);
    box-shadow: 0 0 0 0.2rem rgba(var(--accent-rgb), 0.15);
    color: #fff;
}
.form-control::placeholder { color: #5b6675; }
.form-label { font-size: 0.85rem; font-weight: 500; color: #c8d0dc; }

.was-validated .form-control:invalid, .form-control.is-invalid {
    border-color: #ef4444;
}
.was-validated .form-control:valid, .form-control.is-valid {
    border-color: #22c55e;
}

/* ---------------------------------------------------------
   Footer
   --------------------------------------------------------- */
footer a { transition: color .15s ease; }

/* ---------------------------------------------------------
   Force-dark widget embeds
   For third-party widgets whose own dark-theme parameter isn't
   reliably honored. Requests the widget's known-good LIGHT theme
   explicitly (reliable, well-tested), then inverts the whole iframe
   and rotates the hue back — flips white/black while keeping colors
   close to their original hue. Deliberately no contrast/brightness
   stacked on top: those distort anti-aliased text into a blurry,
   lower-contrast result on an already-filtered iframe.
   --------------------------------------------------------- */
.force-dark-widget iframe {
    filter: invert(1) hue-rotate(180deg);
}

/* ---------------------------------------------------------
   Misc animations
   --------------------------------------------------------- */
.fade-in-up {
    animation: fadeInUp .5s ease both;
}
@keyframes fadeInUp {
    from { opacity: 0; transform: translateY(12px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* ---------------------------------------------------------
   Responsive tweaks
   --------------------------------------------------------- */
@media (max-width: 991.98px) {
    .hero-title { font-size: 2.5rem; }
}

@media (max-width: 575.98px) {
    .display-3 { font-size: 2.25rem; }
    .market-table { font-size: 0.85rem; }
}
