@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;600;800&display=swap');

:root {
  --bg-base: #030305;
  --glass-bg: rgba(255, 255, 255, 0.02);
  --glass-border: rgba(255, 255, 255, 0.06);
  --accent-cyan: #00f0ff;
  --accent-purple: #8a2be2;
  --text-main: #ffffff;
  --text-muted: #888899;
  --positive: #00ff9d;
  --negative: #ff3366;
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  font-family: 'Inter', sans-serif;
}

body {
  background-color: var(--bg-base);
  color: var(--text-main);
  height: 100vh;
  overflow: hidden;
  position: relative;
}

body::before {
  content: '';
  position: absolute;
  top: -50%;
  left: -50%;
  width: 200%;
  height: 200%;
  background: radial-gradient(circle at 50% 50%, rgba(138, 43, 226, 0.12), transparent 40%), radial-gradient(circle at 80% 20%, rgba(0, 240, 255, 0.08), transparent 30%);
  z-index: -1;
  filter: blur(80px);
  animation: drift 25s infinite alternate ease-in-out;
}

@keyframes drift {
  0% { transform: rotate(0deg) scale(1); }
  100% { transform: rotate(15deg) scale(1.1); }
}

.glass-panel {
  background: var(--glass-bg);
  backdrop-filter: blur(32px);
  -webkit-backdrop-filter: blur(32px);
  border: 1px solid var(--glass-border);
  border-radius: 28px;
  padding: 24px;
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.4);
  transition: border-color 0.3s ease;
}

.glass-panel:hover {
  border-color: rgba(255, 255, 255, 0.12);
}

.app-container {
  display: flex;
  height: 100vh;
  padding: 24px;
  gap: 24px;
  flex-direction: row;
}

/* Sidebar Styling */
.sidebar {
  width: 280px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  z-index: 250;
  transition: left 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}

.logo {
  font-size: 28px;
  font-weight: 800;
  letter-spacing: -1px;
  margin-bottom: 48px;
  background: linear-gradient(90deg, #fff, var(--text-muted));
  -webkit-background-clip: text;
  background-clip: text; 
  -webkit-text-fill-color: transparent;
  color: transparent; 
}

.nav-links {
  list-style: none;
}

.nav-links li {
  padding: 16px 20px;
  margin-bottom: 8px;
  border-radius: 16px;
  cursor: pointer;
  color: var(--text-muted);
  font-weight: 600;
  transition: all 0.3s ease;
  position: relative;
  overflow: hidden;
}

.nav-links li:hover {
  color: var(--text-main);
  background: rgba(255, 255, 255, 0.05);
  transform: translateX(4px);
}

/* Replace the existing .nav-links li.active block with this */
.nav-links li.active {
  color: var(--text-main); /* Keeps text white */
  background: rgba(0, 240, 255, 0.08); /* Very subtle cyan background */
  border-left: 4px solid var(--accent-cyan); /* A nice teal accent line on the left */
  box-shadow: inset 15px 0 20px -15px rgba(0, 240, 255, 0.2); /* Soft inner glow */
  border-radius: 4px 16px 16px 4px; /* Squares off the left edge to match the border */
}

/* Optional: Make the hover effect slightly more noticeable to match */
.nav-links li:hover {
  color: var(--text-main);
  background: rgba(255, 255, 255, 0.08);
  transform: translateX(6px);
}

/* RESTORED: Locked AI Menu Link */
.locked-nav {
  opacity: 0.5;
  cursor: not-allowed !important;
  pointer-events: auto; /* Allows clicking to trigger the upgrade modal */
}
.locked-nav:hover {
  background: transparent !important;
  transform: none !important;
  color: var(--text-muted) !important;
  box-shadow: none !important;
}

.pro-badge {
  background: var(--accent-purple);
  color: #fff;
  font-size: 10px;
  padding: 4px 8px;
  border-radius: 8px;
  margin-left: 8px;
  vertical-align: middle;
  text-transform: uppercase;
  font-weight: 800;
  letter-spacing: 1px;
}

.pro-upsell {
  background: rgba(138, 43, 226, 0.1);
  border: 1px solid rgba(138, 43, 226, 0.3);
  padding: 20px;
  border-radius: 20px;
  text-align: center;
}

.pro-upsell p {
  font-size: 14px;
  color: var(--text-muted);
  margin: 12px 0;
}

.pro-upsell button {
  width: 100%;
  padding: 12px;
  border-radius: 12px;
  border: none;
  background: var(--accent-purple);
  color: #fff;
  font-weight: 600;
  cursor: pointer;
  transition: 0.3s;
}

.pro-upsell button:hover {
  background: #9d4edd;
  box-shadow: 0 0 15px rgba(138, 43, 226, 0.4);
}

/* Main Content Area */
.main-content {
  flex-grow: 1;
  position: relative;
  overflow-y: auto;
  overflow-x: hidden;
  display: flex;
  flex-direction: column;
}

.view {
  display: flex;
  flex-direction: column;
  gap: 24px;
  height: 100%;
  min-height: 0;
  opacity: 1;
  transition: opacity 0.3s ease;
}

.hidden-view {
  display: none !important;
  opacity: 0;
}

/* Dashboard Header Widgets */
.header-row {
  display: flex;
  gap: 24px;
  flex-direction: column;
}

.balance-container {
  flex: 1;
}

.pnl-widget {
  flex: 1.5;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

.pnl-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}

.pnl-timeframes {
  display: flex;
  background: rgba(0,0,0,0.3);
  padding: 4px;
  border-radius: 12px;
}

.pnl-tf-btn {
  background: transparent;
  border: none;
  color: var(--text-muted);
  padding: 6px 12px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 12px;
  font-weight: 600;
  transition: 0.2s;
}

.pnl-tf-btn.active, .pnl-tf-btn:hover {
  background: rgba(255,255,255,0.1);
  color: #fff;
}

.label {
  font-size: 14px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 1px;
  font-weight: 600;
}

.balance {
  font-size: 48px;
  font-weight: 800;
  margin: 8px 0;
  letter-spacing: -1px;
}

.change {
  font-size: 16px;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.positive { color: var(--positive); }
.negative { color: var(--negative); }

.pnl-value { font-size: 32px; font-weight: 800; margin-bottom: 4px;}
.pnl-perc { font-size: 16px; font-weight: 600; }

/* Dashboard Grid */
.dashboard-grid {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 24px;
  flex-grow: 1;
  min-height: 0; 
}

/* Chart Area */
.chart-container {
  display: flex;
  flex-direction: column;
}

.chart-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 24px;
}

.timeframe-selector {
  display: flex;
  gap: 8px;
  background: rgba(0, 0, 0, 0.2);
  padding: 6px;
  border-radius: 16px;
}

.tf-btn {
  background: transparent;
  border: none;
  color: var(--text-muted);
  padding: 8px 16px;
  border-radius: 12px;
  cursor: pointer;
  font-weight: 600;
  transition: all 0.2s ease;
}

.tf-btn:hover, .tf-btn.active {
  background: var(--glass-border);
  color: var(--text-main);
}

/* Assets List */
.assets-container {
  display: flex;
  flex-direction: column;
  overflow: hidden; 
}

.assets-container h2 {
  margin-bottom: 20px;
  flex-shrink: 0;
}

.asset-list {
  list-style: none;
  overflow-y: auto; 
  padding-right: 8px;
  flex-grow: 1;
}

.asset-list::-webkit-scrollbar { width: 6px; }
.asset-list::-webkit-scrollbar-track { background: rgba(0,0,0,0.1); border-radius: 10px; }
.asset-list::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.1); border-radius: 10px; }
.asset-list::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,0.2); }

.asset-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px;
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid rgba(255, 255, 255, 0.03);
  border-radius: 16px;
  margin-bottom: 12px;
  transition: transform 0.2s ease, background 0.2s ease;
}

.asset-item:hover {
  transform: translateY(-2px);
  background: rgba(255, 255, 255, 0.05);
}

.asset-info { display: flex; flex-direction: column; }
.asset-symbol { font-weight: 800; font-size: 18px; }
.asset-name { color: var(--text-muted); font-size: 14px; margin-top: 4px; }
.asset-values { text-align: right; }
.asset-price { font-weight: 600; font-size: 16px; }

/* Tables */
.data-table { width: 100%; border-collapse: collapse; }
.data-table th { text-align: left; color: var(--text-muted); padding: 16px; border-bottom: 1px solid var(--glass-border); font-weight: 600; }
.data-table td { padding: 16px; border-bottom: 1px solid rgba(255,255,255,0.02); }

.tx-type { font-weight: 800; }
.tx-type.buy { color: var(--positive); }
.tx-type.sell { color: var(--negative); }

/* Common UI Elements */
.primary-btn {
  background: var(--text-main);
  color: #000;
  border: none;
  padding: 16px 24px;
  border-radius: 12px;
  font-weight: 800;
  font-size: 16px;
  cursor: pointer;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
  width: 100%;
}

.primary-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 20px rgba(255,255,255,0.2);
}



/* Toggle Switch */
.switch { position: relative; display: inline-block; width: 50px; height: 28px; }
.switch input { opacity: 0; width: 0; height: 0; }
.slider { position: absolute; cursor: pointer; top: 0; left: 0; right: 0; bottom: 0; background-color: rgba(255,255,255,0.1); transition: .4s; border-radius: 34px; }
.slider:before { position: absolute; content: ""; height: 20px; width: 20px; left: 4px; bottom: 4px; background-color: white; transition: .4s; border-radius: 50%; }
input:checked + .slider { background-color: var(--accent-cyan); }
input:checked + .slider:before { transform: translateX(22px); background-color: #000;}

/* Drawer & Modal Styling */
.modal-overlay, .drawer-overlay {
  position: fixed; top: 0; left: 0; width: 100%; height: 100%;
  background: rgba(0,0,0,0.6); backdrop-filter: blur(8px);
  z-index: 1000; display: flex; justify-content: center; align-items: center;
}

.hidden { display: none !important; }

/* RESTORED: Connect Wallet & Quick Trade Modal Backgrounds */
.modal {
  background: rgba(10, 10, 15, 0.98) !important; 
  border: 1px solid var(--glass-border);
  box-shadow: 0 24px 50px rgba(0, 0, 0, 0.8);
  border-radius: 24px;
  padding: 32px;
  width: 100%; 
  max-width: 420px;
  transform: translateY(0); 
  transition: transform 0.3s ease;
}

.modal-header, .drawer-header {
  display: flex; justify-content: space-between; align-items: center; margin-bottom: 24px;
}

/* RESTORED: Modal Close Buttons (✕) */
.icon-btn {
  background: rgba(255, 255, 255, 0.05) !important;
  border: 1px solid var(--glass-border) !important;
  border-radius: 50%;
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
}
.icon-btn:hover {
  background: rgba(255, 255, 255, 0.1) !important;
  color: #fff !important;
  transform: scale(1.05);
}

.side-drawer {
  position: fixed; top: 0; height: 100%; width: 320px;
  z-index: 1001; transition: right 0.4s ease;
  background: rgba(3,3,5,0.95); padding: 32px;
  border-left: 1px solid var(--glass-border);
}

.right-drawer { right: -350px; border-radius: 28px 0 0 28px; }
.right-drawer.open { right: 0; }

.setting-item { display: flex; justify-content: space-between; align-items: center; padding: 16px 0; border-bottom: 1px solid rgba(255,255,255,0.05); }

/* Forms & Selects */
.glass-select {
  background: rgba(0,0,0,0.3); border: 1px solid var(--glass-border); color: #fff;
  padding: 10px; border-radius: 8px; width: 100%; outline: none; font-family: inherit;
}
.glass-select option { background: var(--bg-base); color: #fff; }

/* AI Title Animation */
.ai-title {
  background: linear-gradient(90deg, var(--accent-purple), var(--accent-cyan));
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  color: transparent; 
  animation: pulseColor 4s infinite alternate;
}
@keyframes pulseColor {
  0% { filter: hue-rotate(0deg); }
  100% { filter: hue-rotate(30deg); }
}

/* Pair Buttons (Charts view) */
.page-title {
  font-size: 28px;
  font-weight: 800;
  letter-spacing: -0.5px;
  margin-bottom: 4px;
}

.pair-btn {
  background: transparent; border: 1px solid var(--glass-border); color: var(--text-muted);
  padding: 8px 16px; border-radius: 8px; cursor: pointer; white-space: nowrap; transition: 0.2s;
}
.pair-btn.active, .pair-btn:hover { background: rgba(255,255,255,0.1); color: #fff; }

/* ==========================================
   AI Market Sentiment Dashboard
========================================== */
.ai-dashboard-top {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 24px;
    margin-bottom: 32px;
    align-items: stretch;
}

#view-ai {
    position: relative;
    height: auto;
}

.ai-content.ai-blurred {
    filter: blur(6px);
    pointer-events: none;
    user-select: none;
}

.ai-paywall-overlay {
    display: none;
    position: absolute;
    top: 110px;
    left: 0;
    right: 0;
    bottom: 0;
    align-items: center;
    justify-content: center;
    z-index: 10;
    padding: 24px;
}

.ai-paywall-overlay.visible {
    display: flex;
}

.gauge-container {
    position: relative;
    width: 160px; 
    height: 80px; 
    margin: 0 auto;
}
.gauge-svg { width: 100%; height: 100%; overflow: visible; }
.gauge-bg { fill: none; stroke: var(--glass-border); stroke-width: 12; stroke-linecap: round; }
.gauge-fill { 
    fill: none; 
    stroke: var(--accent-cyan); 
    stroke-width: 12; 
    stroke-linecap: round; 
}
.gauge-value-text {
    position: absolute;
    bottom: -10px;
    left: 50%;
    transform: translateX(-50%);
    font-size: 32px;
    font-weight: 800;
}

.narrative-box {
    margin-top: 24px;
    padding: 16px;
    background: rgba(0, 240, 255, 0.05);
    border-left: 4px solid var(--accent-cyan);
    border-radius: 8px;
    font-size: 14px;
    line-height: 1.6;
    color: #e0e0e0;
}

.signal-grid {
    display: flex;
    flex-direction: column;
    gap: 12px;
}
.signal-pill {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: rgba(255,255,255,0.03);
    padding: 14px 16px;
    border-radius: 12px;
    border: 1px solid var(--glass-border);
}

.signal-pill-left {
    display: flex;
    align-items: center;
    gap: 12px;
}

.status-circle {
    width: 12px;
    height: 12px;
    border-radius: 50%;
}

.signal-pill .indicator { font-weight: 600; color: var(--text-muted); font-size: 14px;}
.signal-pill .value { font-weight: 800; font-size: 14px;}

.signal-pill.bullish .status-circle { background-color: var(--positive); box-shadow: 0 0 8px var(--positive); }
.signal-pill.bullish .value { color: var(--positive); }

.signal-pill.bearish .status-circle { background-color: var(--negative); box-shadow: 0 0 8px var(--negative); }
.signal-pill.bearish .value { color: var(--negative); }

.signal-pill.neutral .status-circle { background-color: #f39c12; box-shadow: 0 0 8px #f39c12; }
.signal-pill.neutral .value { color: #f39c12; }

.trade-section.hidden { display: none; }

/* RESTORED: Quick Trade Modal Tabs */
.trade-tab {
    transition: background 0.2s ease, color 0.2s ease;
}
.trade-tab:hover {
    background: rgba(255, 255, 255, 0.05) !important;
    color: #fff !important;
}
.trade-tab.active { background: rgba(255,255,255,0.1) !important; color: #fff !important; }

/* Ensure CEX and Modal buttons match the "Upgrade" style */
.cex-btn {
    background: var(--accent-purple) !important;
    color: #ffffff !important; /* Forces white text */
    border: none !important;
    font-weight: 800;
}

.cex-btn:hover {
    background: #9d4edd !important;
    box-shadow: 0 0 20px rgba(138, 43, 226, 0.4);
}

/* Unified Modal Style */
.modal.glass-panel {
    background: rgba(10, 10, 15, 0.98) !important;
    border: 1px solid rgba(255, 255, 255, 0.1) !important;
    box-shadow: 0 24px 80px rgba(0, 0, 0, 0.9);
}

/* Pro modal gets the purple border specifically */
#proModal .modal.glass-panel {
    border: 1px solid rgba(138, 43, 226, 0.4) !important;
}

.modal h2 {
    background: linear-gradient(90deg, #fff, var(--accent-purple));
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    color: transparent;
}



/* =========================================
   DESKTOP & GLOBAL OVERRIDES
   (These apply to large screens)
   ========================================= */
html {
    height: 100%;
}

body {
    overflow: hidden; /* Keep locked on desktop — main-content scrolls internally */
    overflow-x: hidden;
}

.app-container {
    display: flex !important;
    flex-direction: row !important; /* Forces desktop to side-by-side */
    height: 100vh;
}

.header-widgets {
    justify-content: space-between !important;
    align-items: center;
    flex-direction: row !important;
}

/* Ensure Desktop Chart Header & Timeframes remain horizontal */
.chart-header {
    display: flex !important;
    flex-direction: row !important;
    justify-content: space-between !important;
    align-items: center !important;
}

.timeframe-selector {
    display: flex !important;
    flex-direction: row !important;
    overflow: visible !important;
}

.hide-desktop {
    display: none !important;
}

/* =========================================
   MOBILE VIEW ONLY (Max Width 768px)
   ========================================= */
@media screen and (max-width: 768px) {

    /* 0. Allow page scrolling on mobile */
    html, body {
        height: auto !important;
        min-height: 100% !important;
        overflow: visible !important;
        overflow-y: auto !important;
    }

    /* 1. Unlock layout constraints for mobile scrolling */
    .app-container, .main-content {
        height: auto !important;
        min-height: 100% !important;
        overflow: visible !important;
        display: flex !important;
        flex-direction: column !important;
        justify-content: flex-start !important;
        padding: 0 !important;
        gap: 16px !important;
    }

    .app-container {
        padding: 12px !important;
    }

    /* 🚨 CRITICAL FIX: Hide inactive views completely so they leave ZERO empty space 🚨 */
    .view {
        height: auto !important;
        overflow: visible !important;
        flex-direction: column !important;
        justify-content: flex-start !important;
        gap: 16px !important;
        padding: 0 !important;
    }

    .view.hidden-view {
        display: none !important;
    }

    .view:not(.hidden-view) {
        display: flex !important;
    }

    #mobileMenuBtn {
        display: none !important;
    }

    /* 2. Top-mounted Menu */
    .sidebar {
        position: relative !important;
        left: 0 !important;
        width: 100% !important;
        height: auto !important;
        min-height: auto !important;
        margin-bottom: 20px;
        padding: 20px !important;
        display: block !important;
        box-sizing: border-box;
        order: -1;
    }

    .sidebar .logo {
        display: block !important;
        text-align: center;
        margin-bottom: 20px;
        font-size: 22px;
    }

    .pro-upsell {
        display: block !important;
        margin-top: 24px;
        width: 100%;
        text-align: center;
    }

    /* 3. Main Dashboard Header & PnL */
    .header-row {
        flex-direction: column !important;
        align-items: flex-start !important;
        margin-bottom: 24px;
    }

    .header-widgets {
        flex-direction: column !important;
        width: 100% !important;
        align-items: stretch !important;
        gap: 16px !important;
    }

    .balance-container, .pnl-widget {
        width: 100% !important;
        margin-right: 0 !important;
    }

    /* 4. Dashboard Chart & Assets */
    .dashboard-grid {
        display: flex !important;
        flex-direction: column !important;
        gap: 16px !important;
    }

    .bento-large {
        min-height: 480px !important;
        width: 100% !important;
        padding: 15px !important;
        box-sizing: border-box;
    }

    .chart-container {
        height: 400px !important;
        min-height: 400px !important;
        width: 100% !important;
    }

    .chart-header {
        flex-direction: column !important;
        align-items: flex-start !important;
        gap: 12px !important;
    }

    .timeframe-selector {
        width: 100% !important;
        overflow-x: auto !important;
        justify-content: space-between !important;
        padding: 4px !important;
    }

    .tf-btn {
        padding: 6px 10px !important;
        font-size: 13px !important;
        flex: 1;
        text-align: center;
    }

    .assets-container, .asset-list {
        height: auto !important;
        max-height: none !important;
        overflow: visible !important;
    }

    .bento-medium {
        width: 100% !important;
        height: auto !important;
        min-height: auto !important;
    }

    /* =========================================
       PAGE-SPECIFIC MOBILE FIXES
       ========================================= */

    /* AI Insights Page Fixes */
    .ai-dashboard-top {
        display: flex !important;
        flex-direction: column !important;
        gap: 16px !important;
        margin-bottom: 16px !important;
    }
    
    .ai-title {
        font-size: 24px !important;
        line-height: 1.2 !important;
    }

    .gauge-container, .whale-flow-bars, .trade-section {
        width: 100% !important;
        box-sizing: border-box !important;
    }

    /* Market Charts Page Fixes */
    #view-charts .glass-panel {
        width: 100% !important;
        box-sizing: border-box !important;
    }
    
    #view-charts .glass-panel[style*="flex-grow"] {
        height: 600px !important; /* Increased by 1/3 for taller mobile chart */
        min-height: 600px !important;
    }

    /* Transactions Page Fixes */
    .data-table {
        display: block !important;
        width: 100% !important;
        overflow-x: auto !important;
        white-space: nowrap !important;
    }

    .hide-mobile {
        display: none !important;
    }
}