:root {
    --bg-darker: #05060a;
    --bg-dark: #0b0c15;
    --bg-card: #151621;
    --bg-hover: #1e2030;
    --primary: #ff007f;
    --success: #10b981;
    --danger: #ef4444;
    --text-main: #ffffff;
    --text-muted: #9ca3af;
    --border: rgba(255, 255, 255, 0.1);
}

body {
    background-color: var(--bg-darker);
    overflow: hidden; /* App-like feel */
    font-family: 'Inter', sans-serif;
    color: var(--text-main);
    margin: 0;
}

/* Auth Modal Overlay */
.auth-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(5px);
    z-index: 1000;
    display: flex;
    justify-content: center;
    align-items: center;
}

.auth-card {
    background: var(--bg-card);
    padding: 40px;
    border-radius: 16px;
    border: 1px solid var(--border);
    width: 100%;
    max-width: 400px;
    box-shadow: 0 20px 50px rgba(0,0,0,0.5);
}

.auth-tabs {
    display: flex;
    margin-bottom: 20px;
    border-bottom: 1px solid var(--border);
}

.auth-tab {
    flex: 1;
    padding: 10px;
    text-align: center;
    cursor: pointer;
    color: var(--text-muted);
    transition: 0.3s;
}

.auth-tab.active {
    color: var(--primary);
    border-bottom: 2px solid var(--primary);
}

.form-group {
    margin-bottom: 15px;
}

.form-group label {
    display: block;
    color: var(--text-muted);
    margin-bottom: 5px;
    font-size: 0.9rem;
}

.form-control {
    width: 100%;
    padding: 12px;
    background: var(--bg-dark);
    border: 1px solid var(--border);
    border-radius: 8px;
    color: white;
    font-family: 'Inter', sans-serif;
}

.form-control:focus {
    outline: none;
    border-color: var(--primary);
}

/* Dashboard Layout */
.app-container {
    display: flex;
    height: 100vh;
}

.sidebar {
    width: 250px;
    background: var(--bg-dark);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
}

.sidebar-logo {
    padding: 20px;
    font-size: 1.2rem;
    font-weight: 700;
    color: white;
    border-bottom: 1px solid var(--border);
}

.nav-item {
    padding: 15px 20px;
    color: var(--text-muted);
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 10px;
    transition: 0.2s;
}

.nav-item:hover, .nav-item.active {
    background: var(--bg-hover);
    color: white;
    border-left: 3px solid var(--primary);
}

.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.top-bar {
    height: 60px;
    background: var(--bg-dark);
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 20px;
}

.user-profile {
    display: flex;
    align-items: center;
    gap: 15px;
}

.wallet-badge {
    background: rgba(16, 185, 129, 0.1);
    color: var(--success);
    padding: 5px 12px;
    border-radius: 20px;
    font-size: 0.9rem;
    border: 1px solid rgba(16, 185, 129, 0.2);
}

/* Trading Grid */
.trading-grid {
    display: grid;
    grid-template-columns: 300px 1fr 300px;
    grid-template-rows: 60% 40%;
    gap: 5px;
    padding: 5px;
    height: calc(100vh - 60px);
    background: var(--bg-darker);
}

.panel {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 4px;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.panel-header {
    padding: 10px 15px;
    border-bottom: 1px solid var(--border);
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-muted);
    display: flex;
    justify-content: space-between;
}

/* Market Pairs */
.market-row {
    display: flex;
    justify-content: space-between;
    padding: 10px 15px;
    cursor: pointer;
    border-bottom: 1px solid rgba(255,255,255,0.05);
}
.market-row:hover { background: var(--bg-hover); }

/* Order Book */
.order-row {
    display: flex;
    justify-content: space-between;
    padding: 4px 15px;
    font-size: 0.85rem;
    font-family: monospace;
}
.text-green { color: var(--success); }
.text-red { color: var(--danger); }

/* Trade Form */
.trade-form { padding: 20px; }
.trade-tabs { display: flex; margin-bottom: 15px; background: var(--bg-dark); border-radius: 8px; padding: 2px; }
.trade-tab { flex: 1; text-align: center; padding: 8px; cursor: pointer; border-radius: 6px; font-size: 0.9rem; }
.trade-tab.active-buy { background: var(--success); color: white; }
.trade-tab.active-sell { background: var(--danger); color: white; }

.input-group {
    position: relative;
    margin-bottom: 15px;
}
.input-suffix {
    position: absolute;
    right: 12px;
    top: 12px;
    color: var(--text-muted);
    font-size: 0.9rem;
}

.btn-trade {
    width: 100%;
    padding: 12px;
    border: none;
    border-radius: 8px;
    font-weight: 600;
    cursor: pointer;
    transition: 0.2s;
}
.btn-buy { background: var(--success); color: white; }
.btn-sell { background: var(--danger); color: white; }
.btn-buy:hover { background: #059669; }

/* History */
.history-table { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
.history-table th { text-align: left; color: var(--text-muted); padding: 10px 15px; font-weight: 400; }
.history-table td { padding: 10px 15px; border-bottom: 1px solid rgba(255,255,255,0.05); }

/* Fake Chart Overlay */
.fake-chart-container {
    position: absolute;
    top: 40px; /* Below header */
    left: 0;
    width: 100%;
    height: calc(100% - 40px);
    background: #131722; /* TradingView dark bg */
    background-image: 
        linear-gradient(rgba(255, 255, 255, 0.03) 1px, transparent 1px),
        linear-gradient(90deg, rgba(255, 255, 255, 0.03) 1px, transparent 1px);
    background-size: 50px 50px;
    z-index: 5;
    display: none; /* Hidden by default */
    flex-direction: column;
}

.tv-header {
    padding: 10px;
    display: flex;
    gap: 15px;
    font-family: -apple-system, BlinkMacSystemFont, 'Trebuchet MS', Roboto, Ubuntu, sans-serif;
    font-size: 13px;
    border-bottom: 1px solid #2a2e39;
}

.tv-symbol { font-weight: bold; font-size: 1.1em; color: white; }
.tv-data { display: flex; gap: 10px; color: #787b86; }
.tv-val { margin-left: 4px; color: #ef5350; } /* Default red */

.tv-chart-area {
    position: relative;
    flex: 1;
    overflow: hidden;
    padding: 20px 0;
}

.fake-candles {
    position: absolute;
    bottom: 30px;
    left: 0;
    width: 100%;
    height: 80%;
    display: flex;
    align-items: flex-end;
    overflow: hidden;
}

.fake-candle {
    position: absolute;
    background-color: #0ecb81; /* Green */
    transition: height 0.1s linear, bottom 0.1s linear;
    min-height: 2px;
}

/* Wick */
.fake-candle::after {
    content: '';
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
    width: 1px;
    height: 130%; /* Wick extends beyond body */
    top: -15%;
    background-color: inherit;
    z-index: -1;
    opacity: 0.8;
}

.fake-candle.red {
    background-color: #f6465d;
}

/* Volume Bars */
.fake-volumes {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 15%; /* Small strip at bottom */
    display: flex;
    align-items: flex-end;
    opacity: 0.3;
}

.fake-vol-bar {
    position: absolute;
    background-color: #0ecb81;
}

/* Market List Styles */
.market-list {
    display: flex;
    flex-direction: column;
}

.market-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px 15px; /* Increased padding for better spacing */
    border-bottom: 1px solid var(--border);
    cursor: pointer;
    transition: background 0.2s;
    height: 50px; /* Fixed height for equal spacing */
    box-sizing: border-box;
}

.market-item:hover {
    background: var(--bg-hover);
}

.market-item.active {
    background: rgba(59, 130, 246, 0.1);
    border-left: 3px solid var(--primary);
}

.market-info {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.market-symbol {
    font-weight: 600;
    color: white;
}

.badge-active {
    font-size: 0.7rem;
    padding: 2px 6px;
    border-radius: 4px;
    background: rgba(16, 185, 129, 0.2);
    color: var(--success);
    display: inline-block;
    width: fit-content;
}

.market-change {
    font-size: 0.9rem;
    font-weight: 500;
}
.market-change.positive { color: var(--success); }
.market-change.negative { color: var(--danger); }

/* Simulation Overlay */
.simulation-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.9);
    z-index: 2000;
    display: none;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    pointer-events: all;
}

.simulation-canvas {
    width: 100%;
    height: 100%;
    position: absolute;
    top: 0;
    left: 0;
}

/* Profit Modal */
.profit-modal {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) scale(0.8);
    background: linear-gradient(135deg, #1a1b26 0%, #000 100%);
    border: 2px solid var(--primary);
    box-shadow: 0 0 50px rgba(255, 0, 127, 0.5);
    padding: 40px;
    border-radius: 20px;
    text-align: center;
    z-index: 2001;
    display: none;
    opacity: 0;
    transition: all 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    color: white;
    max-width: 90%;
    width: 400px;
}

.profit-modal.show {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1);
    display: block;
}

.profit-modal h2 {
    color: var(--primary);
    font-size: 2.5rem;
    margin: 0 0 20px 0;
    text-shadow: 0 0 20px rgba(255, 0, 127, 0.5);
}

.profit-modal .profit-amount {
    font-size: 4rem;
    font-weight: 900;
    color: #10b981; /* Green */
    margin: 20px 0;
    display: block;
    text-shadow: 0 0 30px rgba(16, 185, 129, 0.6);
}

.profit-modal p {
    font-size: 1.2rem;
    color: #ccc;
    margin-bottom: 30px;
}

.profit-btn {
    background: var(--primary);
    color: white;
    border: none;
    padding: 15px 40px;
    font-size: 1.2rem;
    border-radius: 50px;
    cursor: pointer;
    box-shadow: 0 10px 20px rgba(255, 0, 127, 0.3);
    transition: transform 0.2s;
}

.profit-btn:hover {
    transform: scale(1.05);
}

/* Confetti (Simple CSS implementation) */
.confetti-piece {
    position: absolute;
    width: 10px;
    height: 10px;
    background: #ffd300;
    top: 0;
    opacity: 0;
}

/* Mobile Responsiveness */
@media (max-width: 1024px) {
    .trading-grid {
        display: flex;
        flex-direction: column;
        gap: 15px;
        height: calc(100vh - 60px); /* Fill remaining space */
        overflow-y: auto; /* Scroll internally */
        padding-bottom: 80px; /* Space for bottom nav */
    }

    /* Modal Mobile Fix */
    .profit-modal {
        width: 90%;
        max-width: 350px;
        padding: 20px;
    }
    
    .profit-modal h2 {
        font-size: 1.8rem;
    }
    
    .profit-modal .profit-amount {
        font-size: 3rem;
    }

    /* Reorder for mobile: Chart first, then Trade, then Orderbook */
    .panel:nth-child(2) { 
        order: 1; 
        height: 350px; /* Reduced slightly to show Trade panel */
        min-height: 350px; 
        margin-bottom: 10px;
        flex-shrink: 0;
    }
    
    #panel-trade { 
        order: 2; 
        margin-bottom: 10px;
        flex-shrink: 0; /* Prevent collapsing */
        background: var(--bg-card); /* Ensure background is opaque */
    }
    
    #panel-orderbook { 
        order: 3; 
        margin-bottom: 10px;
        height: 300px;
        flex-shrink: 0;
    }
    
    #panel-wallet { 
        order: 4; 
        margin-bottom: 10px;
        flex-shrink: 0;
    }

    /* Ensure history panel shows up correctly */
    .panel[style*="grid-column: span 2"] {
        order: 5;
        grid-column: auto !important;
        margin-bottom: 80px;
        flex-shrink: 0;
    }

    .sidebar {
        display: none; /* Hide sidebar on mobile */
    }

    .main-content {
        margin-left: 0;
        width: 100%;
    }

    .top-bar {
        padding: 10px;
    }

    /* Create Bottom Navigation */
    .mobile-bottom-nav {
        display: flex;
        position: fixed;
        bottom: 0;
        left: 0;
        width: 100%;
        background: var(--bg-card);
        border-top: 1px solid var(--border);
        justify-content: space-around;
        padding: 10px 0;
        z-index: 100;
    }

    .mobile-nav-item {
        color: var(--text-muted);
        text-align: center;
        font-size: 0.7rem;
        background: none;
        border: none;
        cursor: pointer;
        display: flex;
        flex-direction: column;
        align-items: center;
        gap: 4px;
    }

    .mobile-nav-item.active {
        color: var(--primary);
    }
    
    .mobile-nav-item i {
        display: block;
        font-size: 1.2rem;
    }

    /* History Panel Order */
    .panel:last-child {
        order: 5;
        min-height: 300px;
        margin-bottom: 80px; /* Extra space for bottom nav */
    }
    .btn-trade {
        padding: 18px; /* Larger touch target */
        font-size: 1.1rem;
        text-transform: uppercase;
        letter-spacing: 0.5px;
        box-shadow: 0 4px 6px rgba(0,0,0,0.2);
    }
}

@media (min-width: 1025px) {
    .mobile-bottom-nav {
        display: none;
    }
}