/**
 * NewEx User Panel Styles
 * Dark theme with brand colors
 */

:root {
    --primary: #FF9B00;
    --accent: #FFE100;
    --charts: #FFC900;
    --highlight: #EBE389;
    --bg-dark: #0D1117;
    --bg-card: #161B22;
    --bg-input: #21262D;
    --border: #30363D;
    --text: #E6EDF3;
    --text-muted: #8B949E;
    --success: #3FB950;
    --error: #F85149;
    --warning: #D29922;
    --info: #58A6FF;
}

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

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--bg-dark);
    color: var(--text);
    min-height: 100vh;
}

/* App Layout */
.app-layout {
    display: flex !important;
    min-height: 100vh;
}

/* Sidebar */
.sidebar {
    width: 240px;
    background: var(--bg-card);
    border-right: 1px solid var(--border);
    display: flex !important;
    flex-direction: column;
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    z-index: 100;
}

.sidebar-header {
    padding: 20px;
    border-bottom: 1px solid var(--border);
}

.sidebar-header .logo {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--text);
    text-decoration: none;
    background: linear-gradient(135deg, var(--primary), var(--accent));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.sidebar-nav {
    flex: 1;
    padding: 16px 12px;
    overflow-y: auto;
    scrollbar-width: none;
    /* Firefox */
    -ms-overflow-style: none;
    /* IE/Edge */
}

/* Hide scrollbar for sidebar and all its children */
.sidebar,
.sidebar * {
    scrollbar-width: none;
    /* Firefox */
    -ms-overflow-style: none;
    /* IE/Edge */
}

.sidebar::-webkit-scrollbar,
.sidebar *::-webkit-scrollbar {
    display: none;
    /* Chrome/Safari/Opera */
}

.nav-item {
    display: flex !important;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    color: var(--text-muted);
    text-decoration: none;
    border-radius: 10px;
    margin-bottom: 4px;
    transition: all 0.2s;
}

.nav-item:hover {
    color: var(--text);
    background: var(--bg-input);
}

.nav-item.active {
    color: var(--primary);
    background: rgba(255, 155, 0, 0.1);
}

.nav-item .icon {
    font-size: 1.1rem;
}

.sidebar-footer {
    padding: 16px;
    border-top: 1px solid var(--border);
}

.user-info {
    display: flex !important;
    flex-direction: column;
    margin-bottom: 12px;
}

.user-name {
    font-weight: 600;
    color: var(--text);
}

.user-email {
    font-size: 0.8rem;
    color: var(--text-muted);
    overflow: hidden;
    text-overflow: ellipsis;
}

.logout-btn {
    display: block;
    text-align: center;
    padding: 10px;
    background: rgba(248, 81, 73, 0.1);
    color: var(--error);
    text-decoration: none;
    border-radius: 8px;
    font-size: 0.9rem;
    transition: all 0.2s;
}

.logout-btn:hover {
    background: var(--error);
    color: white;
}

/* Main Content */
.main-content {
    flex: 1;
    margin-left: 240px;
    padding: 24px;
}

/* Header */
.content-header {
    display: flex !important;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
}

.content-header h1 {
    font-size: 1.75rem;
    font-weight: 700;
}

.welcome-text {
    color: var(--text-muted);
    margin-top: 4px;
}

.header-actions {
    display: flex !important;
    gap: 12px;
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 12px 20px;
    border-radius: 10px;
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    border: none;
    text-decoration: none;
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary), var(--accent));
    color: var(--bg-dark);
}

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

.btn-secondary {
    background: var(--bg-input);
    color: var(--text);
    border: 1px solid var(--border);
}

.btn-secondary:hover {
    background: var(--border);
}

.btn-sm {
    padding: 8px 14px;
    font-size: 0.85rem;
}

/* Balance Section */
.balance-section {
    margin-bottom: 24px;
}

.balance-card {
    background: linear-gradient(135deg, var(--bg-card), var(--bg-input));
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 24px;
    margin-bottom: 16px;
}

.balance-card.main {
    background: linear-gradient(135deg, rgba(255, 155, 0, 0.1), rgba(255, 225, 0, 0.05));
    border-color: rgba(255, 155, 0, 0.3);
}

.balance-header {
    display: flex !important;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
}

.balance-label {
    color: var(--text-muted);
    font-size: 0.9rem;
}

.balance-currency {
    background: var(--primary);
    color: var(--bg-dark);
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 600;
}

.balance-amount {
    font-size: 2.25rem;
    font-weight: 700;
    margin-bottom: 8px;
}

.balance-change {
    font-size: 0.9rem;
    color: var(--text-muted);
}

.balance-change.positive span {
    color: var(--success);
}

.balance-change.negative span {
    color: var(--error);
}

/* Quick Stats Row */
.quick-stats-row {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 16px;
}

.quick-stat-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 16px;
    display: flex !important;
    align-items: center;
    gap: 12px;
}

.quick-stat-card .qs-icon {
    font-size: 1.5rem;
}

.quick-stat-card .qs-content {
    display: flex !important;
    flex-direction: column;
}

.quick-stat-card .qs-value {
    font-size: 1.25rem;
    font-weight: 700;
}

.quick-stat-card .qs-label {
    font-size: 0.8rem;
    color: var(--text-muted);
}

/* Dashboard Grid */
.dashboard-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 24px;
    margin-bottom: 24px;
}

/* Cards */
.card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 14px;
    overflow: hidden;
}

.card.full-width {
    grid-column: 1 / -1;
}

.card-header {
    display: flex !important;
    justify-content: space-between;
    align-items: center;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
}

.card-header h3 {
    font-size: 1rem;
    font-weight: 600;
}

.view-all {
    color: var(--primary);
    text-decoration: none;
    font-size: 0.85rem;
}

.view-all:hover {
    text-decoration: underline;
}

.card-body {
    padding: 16px 20px;
}

/* Assets List */
.assets-list {
    display: flex !important;
    flex-direction: column;
    gap: 12px;
}

.asset-item {
    display: flex !important;
    justify-content: space-between;
    align-items: center;
    padding: 12px;
    background: var(--bg-input);
    border-radius: 10px;
}

.asset-info {
    display: flex !important;
    flex-direction: column;
}

.asset-symbol {
    font-weight: 600;
    font-size: 1rem;
}

.asset-name {
    font-size: 0.8rem;
    color: var(--text-muted);
}

.asset-balance {
    text-align: right;
}

.balance-value {
    display: block;
    font-weight: 600;
}

.balance-usd {
    font-size: 0.8rem;
    color: var(--text-muted);
}

/* Empty State */
.empty-state {
    text-align: center;
    padding: 32px 20px;
    color: var(--text-muted);
}

.empty-state p {
    margin-bottom: 16px;
}

/* Tables */
.data-table {
    width: 100%;
    border-collapse: collapse;
}

.data-table th,
.data-table td {
    padding: 12px 8px;
    text-align: left;
}

.data-table th {
    color: var(--text-muted);
    font-weight: 500;
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border-bottom: 1px solid var(--border);
}

.data-table td {
    font-size: 0.9rem;
    border-bottom: 1px solid var(--border);
}

.data-table tr:last-child td {
    border-bottom: none;
}

.data-table tr {
    cursor: pointer;
    transition: background 0.2s;
}

.data-table tbody tr:hover {
    background: var(--bg-input);
}

.pair-cell strong {
    color: var(--text);
}

.pair-cell span {
    color: var(--text-muted);
}

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

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

/* Referral Banner */
.referral-banner {
    background: linear-gradient(135deg, rgba(255, 155, 0, 0.15), rgba(255, 225, 0, 0.1));
    border: 1px solid rgba(255, 155, 0, 0.3);
    border-radius: 14px;
    padding: 24px;
    display: flex !important;
    justify-content: space-between;
    align-items: center;
    gap: 24px;
}

.banner-content h3 {
    font-size: 1.1rem;
    margin-bottom: 4px;
}

.banner-content p {
    color: var(--text-muted);
    font-size: 0.9rem;
}

.referral-link {
    display: flex !important;
    background: var(--bg-card);
    border-radius: 10px;
    overflow: hidden;
    border: 1px solid var(--border);
}

.referral-link input {
    width: 300px;
    padding: 12px 16px;
    background: transparent;
    border: none;
    color: var(--text);
    font-size: 0.9rem;
}

.referral-link input:focus {
    outline: none;
}

.copy-btn {
    padding: 12px 20px;
    background: var(--primary);
    color: var(--bg-dark);
    border: none;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.copy-btn:hover {
    background: var(--accent);
}

/* Forms */
.form-group {
    margin-bottom: 20px;
}

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

.form-control {
    width: 100%;
    padding: 12px 16px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: 10px;
    color: var(--text);
    font-size: 0.95rem;
    transition: all 0.2s;
}

.form-control:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(255, 155, 0, 0.15);
}

/* Page Header */
.page-header {
    margin-bottom: 24px;
}

.page-header h1 {
    font-size: 1.75rem;
    font-weight: 700;
    margin-bottom: 4px;
}

.page-header p {
    color: var(--text-muted);
}

/* Wallet Page */
.wallet-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 16px;
}

.wallet-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 20px;
    transition: all 0.2s;
}

.wallet-card:hover {
    border-color: var(--primary);
    transform: translateY(-2px);
}

.wallet-coin {
    display: flex !important;
    align-items: center;
    gap: 12px;
    margin-bottom: 16px;
}

.wallet-coin .coin-icon {
    width: 40px;
    height: 40px;
    background: var(--bg-input);
    border-radius: 50%;
    display: flex !important;
    align-items: center;
    justify-content: center;
    font-size: 1.25rem;
}

.wallet-coin .coin-info h4 {
    font-size: 1rem;
    margin-bottom: 2px;
}

.wallet-coin .coin-info span {
    font-size: 0.8rem;
    color: var(--text-muted);
}

.wallet-balance {
    margin-bottom: 16px;
}

.wallet-balance .available {
    font-size: 1.5rem;
    font-weight: 700;
    margin-bottom: 4px;
}

.wallet-balance .locked {
    font-size: 0.85rem;
    color: var(--text-muted);
}

.wallet-actions {
    display: flex !important;
    gap: 8px;
}

.wallet-actions .btn {
    flex: 1;
    justify-content: center;
}

/* Responsive */
@media (max-width: 1024px) {
    .dashboard-grid {
        grid-template-columns: 1fr;
    }

    .quick-stats-row {
        grid-template-columns: 1fr;
    }

    .referral-banner {
        flex-direction: column;
        text-align: center;
    }

    .referral-link {
        width: 100%;
    }

    .referral-link input {
        flex: 1;
        width: auto;
    }
}

@media (max-width: 768px) {
    /* Make tables scrollable on mobile instead of stretching the screen */
    table, .market-table, .order-table {
        display: block !important;
        overflow-x: auto !important;
        white-space: nowrap !important;
        width: 100% !important;
        -webkit-overflow-scrolling: touch;
    }

    body, html { overflow-x: hidden; max-width: 100vw; }
    .main-content { overflow-x: hidden; max-width: 100vw; }
    .sidebar {
        transform: translateX(-100%);
        transition: transform 0.3s;
    }

    .sidebar.open {
        transform: translateX(0);
    }

    .main-content {
        margin-left: 0;
        padding: 16px;
    }

    .content-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 16px;
    }

    .header-actions {
        width: 100%;
    }

    .header-actions .btn {
        flex: 1;
        justify-content: center;
    }

    .balance-amount {
        font-size: 1.75rem;
    }
}
/* =========================================
   PWA & Mobile App Styles 
========================================= */
@media (max-width: 768px) {
    /* Make tables scrollable on mobile instead of stretching the screen */
    table, .market-table, .order-table {
        display: block !important;
        overflow-x: auto !important;
        white-space: nowrap !important;
        width: 100% !important;
        -webkit-overflow-scrolling: touch;
    }

    body, html { overflow-x: hidden; max-width: 100vw; }
    .main-content { overflow-x: hidden; max-width: 100vw; }
    /* Hide the old sidebar toggle if any */
    .sidebar-toggle { display: none !important; }
    
    /* Make main content full height and add padding for bottom nav */
    .app-layout { padding-bottom: 70px; }
    .main-content { padding-bottom: 80px; padding-top: 10px; }

    /* Bottom Navigation Bar */
    .mobile-bottom-nav {
        position: fixed;
        bottom: 0;
        left: 0;
        width: 100%;
        height: 65px;
        background-color: var(--bg-secondary, #1e2329);
        display: flex !important;
        justify-content: space-around;
        align-items: center;
        z-index: 1000;
        border-top: 1px solid var(--border-color, #2b3139);
        box-shadow: 0 -2px 10px rgba(0,0,0,0.3);
    }
    
    .mobile-bottom-nav .nav-item {
        display: flex !important;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        color: var(--text-muted, #848e9c);
        text-decoration: none;
        font-size: 11px;
        gap: 4px;
        width: 20%;
        cursor: pointer;
    }
    
    .mobile-bottom-nav .nav-item.active {
        color: var(--primary-color, #fcd535);
    }
    
    .mobile-bottom-nav .nav-item .icon {
        font-size: 20px;
    }

    /* Mobile Menu Drawer */
    .mobile-menu-drawer {
        position: fixed;
        top: 0;
        right: -100%;
        width: 80%;
        max-width: 300px;
        height: 100%;
        background-color: var(--bg-secondary, #1e2329);
        z-index: 1002;
        transition: right 0.3s ease-in-out;
        display: flex !important;
        flex-direction: column;
        box-shadow: -5px 0 15px rgba(0,0,0,0.5);
    }
    
    .mobile-menu-drawer.open {
        right: 0;
    }
    
    .mobile-menu-overlay {
        position: fixed;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
        background: rgba(0,0,0,0.7);
        z-index: 1001;
        display: none;
        opacity: 0;
        transition: opacity 0.3s;
    }
    
    .mobile-menu-overlay.open {
        display: block !important;
        opacity: 1;
    }
    
    .mobile-menu-header {
        padding: 20px;
        display: flex !important;
        justify-content: space-between;
        align-items: center;
        border-bottom: 1px solid var(--border-color, #2b3139);
        font-size: 18px;
        font-weight: bold;
    }
    
    .mobile-menu-header .close-btn {
        background: none;
        border: none;
        color: var(--text-primary, #fff);
        font-size: 28px;
        cursor: pointer;
    }
    
    .mobile-menu-links {
        padding: 15px 0;
        overflow-y: auto;
    }
    
    .mobile-menu-links a {
        display: block;
        padding: 15px 20px;
        color: var(--text-primary, #eaecef);
        text-decoration: none;
        font-size: 15px;
        border-bottom: 1px solid var(--border-color, #2b3139);
    }
    
    .mobile-menu-links a:active {
        background-color: var(--bg-hover, #2b3139);
    }
    
    .text-danger { color: #f6465d !important; }

    /* Fix trade page responsive stacking */
    .main-container {
        display: flex !important;
        flex-direction: column !important;
        height: auto !important;
    }
    .chart-section {
        min-height: 400px;
        max-height: 50vh;
        order: 1; /* Chart first */
    }
    .orderbook-section {
        min-height: 500px;
        order: 2; /* Order book second */
    }
    .trade-section {
        order: 3; /* Order form last */
    }
}
@media (min-width: 769px) {
    .mobile-bottom-nav, .mobile-menu-drawer, .mobile-menu-overlay {
        display: none !important;
    }
}