:root {
    --primary: #00f2ff;
    --primary-glow: rgba(0, 242, 255, 0.6);
    --secondary: #7000ff;
    --secondary-glow: rgba(112, 0, 255, 0.4);
    --accent: #ff00c8;
    --bg-deep: #02020a;
    --bg-card: rgba(10, 10, 25, 0.7);
    --bg-nav: rgba(5, 5, 12, 0.9);
    --text-white: #ffffff;
    --text-dim: #8493a8;
    --success: #00ffa3;
    --danger: #ff2d55;
    --border: rgba(255, 255, 255, 0.08);
    --glass: rgba(255, 255, 255, 0.03);
    --font-heading: 'Outfit', sans-serif;
    --font-ui: 'Inter', sans-serif;
    --font-mono: 'JetBrains Mono', monospace;
    --card-shadow: 0 20px 50px rgba(0, 0, 0, 0.5);
}

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

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

body {
    background-color: var(--bg-deep);
    color: var(--text-white);
    font-family: var(--font-ui);
    overflow-x: hidden;
    overflow-y: auto;
    width: 100%;
    margin: 0;
}

/* Luxury Layout */
.app-container {
    display: grid;
    grid-template-columns: 280px 1fr;
    height: 100vh;
    width: 100%;
    max-width: 100vw;
    overflow: hidden;
}

.mobile-menu-toggle {
    display: none !important;
}

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

/* Sidebar Navigation */
.sidebar {
    background: var(--bg-deep);
    border-right: 1px solid var(--border);
    padding: 2rem 1.5rem;
    display: flex;
    flex-direction: column;
    z-index: 1000;
    transition: transform 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

.brand {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-bottom: 3rem;
    text-decoration: none;
}

.brand-icon {
    width: 42px;
    height: 42px;
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    box-shadow: 0 0 20px var(--primary-glow);
}

.brand-name {
    font-family: var(--font-heading);
    font-size: 1.5rem;
    font-weight: 800;
    letter-spacing: -1px;
    color: white;
}

.nav-menu {
    list-style: none;
    flex-grow: 1;
}

.nav-item {
    margin-bottom: 0.5rem;
}

.nav-link {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1rem;
    border-radius: 1rem;
    color: var(--text-dim);
    text-decoration: none;
    font-weight: 500;
    transition: all 0.3s ease;
}

.nav-link i {
    font-size: 1.25rem;
}

.nav-link:hover, .nav-link.active {
    background: var(--glass);
    color: var(--primary);
    box-shadow: inset 0 0 10px rgba(0, 242, 255, 0.05);
}

.nav-link.active {
    border-left: 3px solid var(--primary);
}

/* Main Content Area */
.main-content {
    background: radial-gradient(circle at top right, rgba(112, 0, 255, 0.05), transparent 600px),
                radial-gradient(circle at bottom left, rgba(0, 242, 255, 0.05), transparent 600px);
    overflow-y: auto;
    overflow-x: hidden;
    padding: 2rem;
    position: relative;
    width: 100%;
    min-width: 0;
}

/* Global Header Bar */
.top-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
    padding: 0.5rem 0;
}

.page-title {
    font-family: var(--font-heading);
    font-size: 2rem;
    font-weight: 800;
}

.search-field {
    background: var(--bg-card);
    border: 1px solid var(--border);
    padding: 0.75rem 1.5rem;
    border-radius: 9999px;
    display: flex;
    align-items: center;
    gap: 1rem;
    width: 400px;
}

.search-field input {
    background: transparent;
    border: none;
    color: white;
    outline: none;
    font-size: 1rem;
    width: 100%;
}

/* Dashboard Grid */
.dashboard-grid {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 2rem;
    align-items: start;
    width: 100%;
}

/* Responsive Utilities */
.grid-2 {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 2rem;
}

@media (max-width: 992px) {
    .grid-2 {
        grid-template-columns: 1fr;
        gap: 1.5rem;
    }
}

.table-responsive {
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    margin-bottom: 1rem;
}

.table-responsive::-webkit-scrollbar {
    height: 4px;
}

.luxury-card {
    background: var(--bg-card);
    backdrop-filter: blur(30px) saturate(180%);
    border: 1px solid var(--border);
    border-radius: 2.5rem;
    padding: 2.5rem;
    position: relative;
    overflow: hidden;
    box-shadow: var(--card-shadow);
    transition: transform 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    width: 100%;
    min-width: 0;
}

.luxury-card::after {
    content: '';
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: radial-gradient(circle at center, rgba(0, 242, 255, 0.03) 0%, transparent 70%);
    pointer-events: none;
}

.luxury-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 1px;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.1), transparent);
}

/* Binance Table Style */
.crypto-list {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0 0.75rem;
}

.crypto-list th {
    text-align: left;
    color: var(--text-dim);
    font-weight: 500;
    padding: 1rem;
    font-size: 0.85rem;
    text-transform: uppercase;
}

.crypto-row {
    background: rgba(255, 255, 255, 0.02);
    border-radius: 1.5rem;
    cursor: pointer;
    transition: all 0.3s ease;
}

.crypto-row:hover {
    background: rgba(255, 255, 255, 0.05);
    transform: scale(1.01);
}

.crypto-row td {
    padding: 1.25rem 1rem;
}

.crypto-row td:first-child { border-radius: 1.5rem 0 0 1.5rem; }
.crypto-row td:last-child { border-radius: 0 1.5rem 1.5rem 0; }

.coin-box {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.coin-icon-wrapper {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--bg-deep);
    padding: 8px;
    border: 1px solid var(--border);
}

.coin-icon-wrapper img {
    width: 100%;
    height: 100%;
}

.price-box {
    font-family: var(--font-mono);
    font-weight: 500;
}

.change-badge {
    padding: 0.25rem 0.75rem;
    border-radius: 0.75rem;
    font-size: 0.85rem;
    font-weight: 700;
}

.change-up { background: rgba(0, 255, 157, 0.1); color: var(--success); }
.change-down { background: rgba(255, 51, 102, 0.1); color: var(--danger); }

/* Chart Overlay / Modal / New Page Elements */
#modalOverlay {
    animation: modalSlide 0.5s cubic-bezier(0.19, 1, 0.22, 1);
}

@keyframes modalSlide {
    from { opacity: 0; transform: scale(1.05); filter: blur(20px); }
    to { opacity: 1; transform: scale(1); filter: blur(0); }
}

.luxury-side-panel .luxury-card {
    transition: 0.3s ease;
}

.luxury-side-panel .luxury-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 30px 60px rgba(0,0,0,0.8);
    border-color: var(--primary-glow);
}

#modalConvInput {
    transition: 0.3s;
}

#modalConvInput:focus {
    border-color: var(--primary);
    filter: drop-shadow(0 0 10px var(--primary-glow));
}

.time-ranges {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1.5rem;
}

.range-btn {
    background: var(--glass);
    border: 1px solid var(--border);
    color: var(--text-dim);
    padding: 0.5rem 1rem;
    border-radius: 0.75rem;
    cursor: pointer;
    font-weight: 600;
    transition: 0.3s;
}

.range-btn.active, .range-btn:hover {
    background: var(--primary);
    color: var(--bg-deep);
}

/* Animations */
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

.animate {
    animation: fadeIn 0.8s ease forwards;
}

/* Scrollbar Customization */
::-webkit-scrollbar {
    width: 6px;
}
::-webkit-scrollbar-track {
    background: transparent;
}
::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 10px;
}
::-webkit-scrollbar-thumb:hover {
    background: var(--primary-glow);
}

/* Media Queries */
@media screen and (min-width: 1201px) {
    .app-container {
        grid-template-columns: 280px 1fr;
    }
}

@media screen and (max-width: 1200px) and (min-width: 769px) {
    .app-container {
        grid-template-columns: 80px 1fr;
    }
    .sidebar {
        width: 80px;
        padding: 2rem 0.5rem;
        align-items: center;
    }
    .brand-name, .nav-item span, .sidebar-footer {
        display: none;
    }
    .brand { margin-bottom: 2rem; justify-content: center; }
    .nav-link { justify-content: center; padding: 1rem; }
    .search-field { width: 300px; }
}

@media screen and (max-width: 768px) {
    body {
        overflow-x: hidden;
        width: 100%;
    }
    .app-container {
        display: block;
        width: 100%;
        height: auto;
        min-height: 100vh;
        overflow-x: hidden;
    }
    .mobile-menu-toggle {
        display: flex !important;
        background: var(--bg-card);
        border: 1px solid var(--border);
        color: white;
        width: 42px;
        height: 42px;
        border-radius: 12px;
        align-items: center;
        justify-content: center;
        cursor: pointer;
        font-size: 1.2rem;
    }
    .mobile-close {
        display: flex !important;
        position: absolute;
        top: 1.5rem;
        right: 1.5rem;
        background: none;
        border: none;
        color: white;
        font-size: 1.5rem;
        cursor: pointer;
    }
    .sidebar {
        position: fixed;
        left: 0;
        top: 0;
        bottom: 0;
        width: 280px;
        height: 100vh;
        transform: translateX(-100%);
        z-index: 10001;
        background: var(--bg-deep);
        padding: 2rem 1.5rem;
        box-shadow: 20px 0 50px rgba(0,0,0,0.9);
        display: flex !important;
        align-items: stretch;
    }
    .sidebar.active {
        transform: translateX(0);
    }
    .sidebar .brand-name, .sidebar .nav-item span {
        display: block !important;
    }
    .sidebar .brand { justify-content: flex-start; }
    .sidebar .nav-link { justify-content: flex-start; padding: 1.25rem; font-size: 1.1rem; }
    
    .main-content {
        padding: 1.25rem;
        width: 100%;
        margin-top: 0;
    }
    .top-bar {
        flex-direction: column;
        align-items: stretch;
        gap: 1.5rem;
        margin-bottom: 2rem;
    }
    .header-left {
        display: flex;
        justify-content: space-between;
        align-items: center;
    }
    .page-title {
        font-size: 1.75rem;
        margin: 0;
    }
    .search-field {
        width: 100%;
        max-width: none;
    }
    
    .dashboard-grid {
        display: flex;
        flex-direction: column;
        gap: 1.5rem;
    }
    .luxury-card {
        padding: 1.5rem;
        border-radius: 2rem;
    }
    
    /* Responsive Table */
    .crypto-list thead { display: none; }
    .crypto-row {
        display: flex !important;
        flex-direction: column;
        padding: 1.5rem;
        gap: 0.75rem;
        margin-bottom: 1rem;
        background: rgba(255, 255, 255, 0.03);
    }
    .crypto-row td {
        display: block !important;
        padding: 0 !important;
        width: 100%;
    }
    .col-coin { margin-bottom: 0.5rem !important; }
    .coin-box { justify-content: space-between; }
    .col-price { font-size: 1.5rem !important; font-weight: 700; color: var(--primary); }
    .col-change { display: flex; justify-content: flex-start; }
    .col-volume, .col-cap, .col-action, .col-high, .col-low { display: none !important; }

    /* Arbitrage Cards Fix */
    .dashboard-grid .luxury-card > div[style*="grid-template-columns"] {
        display: flex !important;
        flex-direction: column !important;
        gap: 2rem !important;
    }
    
    #modalOverlay > div { padding: 1rem 0.5rem; margin: 0; width: 100%; overflow-x: hidden; }
    #modalOverlay .modal-coin-info h1 { font-size: 2.2rem !important; }
    #modalOverlay .modal-coin-info { gap: 1rem !important; }
    
    /* Fix Chart & Range Buttons */
    .time-ranges {
        flex-wrap: nowrap;
        overflow-x: auto;
        padding-bottom: 0.5rem;
        width: 100%;
        -webkit-overflow-scrolling: touch;
    }
    .time-ranges::-webkit-scrollbar { display: none; }
    .range-btn {
        flex: 0 0 auto;
        font-size: 0.8rem;
        padding: 0.4rem 0.8rem;
    }
    #chartDiv { 
        height: 350px !important; 
        width: 100% !important; 
    }
    #chartDiv canvas { /* Force canvas to fit container! */
        max-width: 100%;
    }
    
    #modalOverlay div[style*="grid-template-columns"] {
        display: flex !important;
        flex-direction: column !important;
    }
    
    footer div[style*="grid-template-columns"] {
        display: flex !important;
        flex-direction: column !important;
        gap: 2.5rem !important;
    }
}
