/* Modern Toggle Switch */
.mode-switch-container {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-right: 20px;
    background: rgba(255, 255, 255, 0.05);
    padding: 5px 12px;
    border-radius: 20px;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.mode-label {
    font-size: 0.8rem;
    color: var(--text-secondary);
    font-weight: 600;
    transition: color 0.3s;
}

.mode-label.active {
    color: #fff;
}

#label-turbo.active {
    color: #ffd700;
    /* Gold for Turbo */
    text-shadow: 0 0 10px rgba(255, 215, 0, 0.5);
}

.switch {
    position: relative;
    display: inline-block;
    width: 36px;
    height: 20px;
}

.switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: #2d3748;
    -webkit-transition: .4s;
    transition: .4s;
}

.slider:before {
    position: absolute;
    content: "";
    height: 14px;
    width: 14px;
    left: 3px;
    bottom: 3px;
    background-color: white;
    -webkit-transition: .4s;
    transition: .4s;
}

input:checked+.slider {
    background-color: #eab308;
    /* Gold/Amber */
}

input:focus+.slider {
    box-shadow: 0 0 1px #eab308;
}

input:checked+.slider:before {
    -webkit-transform: translateX(16px);
    -ms-transform: translateX(16px);
    transform: translateX(16px);
}

.slider.round {
    border-radius: 34px;
}

.slider.round:before {
    border-radius: 50%;
}

:root {
    --bg-dark: #020617;
    /* Slate 950 */
    --bg-card: rgba(15, 23, 42, 0.6);
    /* Slate 900 Glass */
    --text-primary: #f1f5f9;
    --text-secondary: #94a3b8;
    --accent-green: #10b981;
    /* Emerald 500 */
    --accent-red: #ef4444;
    /* Red 500 */
    --accent-blue: #3b82f6;
    /* Blue 500 */
    --accent-gold: #f59e0b;
    /* Amber 500 */
    --border-color: rgba(148, 163, 184, 0.08);
    --glass-border: 1px solid rgba(255, 255, 255, 0.05);
}

body {
    background-color: var(--bg-dark);
    background-image:
        radial-gradient(circle at 15% 50%, rgba(59, 130, 246, 0.08), transparent 25%),
        radial-gradient(circle at 85% 30%, rgba(16, 185, 129, 0.08), transparent 25%);
    background-attachment: fixed;
    color: var(--text-primary);
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
    margin: 0;
    padding: 24px;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
}

header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    /* Allow wrapping on small screens */
    gap: 15px;
    /* Space between wrapped items */
    margin-bottom: 20px;
    padding-bottom: 10px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    /* Visual separation */
}

.controls {
    display: flex;
    align-items: center;
    gap: 8px;
    /* Reduced from 15px */
    flex-wrap: nowrap;
    /* Force single line if possible */
}

.nav-link {
    color: var(--text-secondary);
    text-decoration: none;
    font-weight: 600;
    padding: 8px 16px;
    border-radius: 12px;
    transition: all 0.2s;
}

.nav-link:hover {
    color: #fff;
    background: rgba(255, 255, 255, 0.05);
}

.nav-link.active {
    color: #fff;
    background: var(--bg-card);
    border: 1px solid rgba(255, 255, 255, 0.1);
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
}

h1 {
    font-size: 1.8rem;
    font-weight: 800;
    margin: 0;
    background: linear-gradient(135deg, var(--accent-blue), var(--accent-green));
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    letter-spacing: -0.02em;
}



/* Nav Tabs */
.nav-tabs {
    display: flex;
    background: rgba(30, 41, 59, 0.5);
    padding: 4px;
    border-radius: 12px;
    gap: 4px;
    border: 1px solid var(--border-color);
}

.nav-tab {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    padding: 8px 24px;
    border-radius: 8px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    font-size: 0.95rem;
}

.nav-tab:hover {
    color: var(--text-primary);
    background: rgba(255, 255, 255, 0.05);
}

.nav-tab.active {
    background: var(--accent-blue);
    color: #fff;
    box-shadow: 0 4px 6px -1px rgba(96, 165, 250, 0.3);
}

.controls {
    display: flex;
    gap: 10px;
}

.btn {
    border: none;
    padding: 8px 16px;
    border-radius: 8px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    font-size: 0.9rem;
}

#btn-pause {
    background: rgba(96, 165, 250, 0.2);
    color: var(--accent-blue);
    border: 1px solid rgba(96, 165, 250, 0.3);
}

#btn-pause:hover {
    background: rgba(96, 165, 250, 0.3);
}

#btn-panic {
    background: rgba(248, 113, 113, 0.2);
    color: var(--accent-red);
    border: 1px solid rgba(248, 113, 113, 0.3);
}

#btn-panic:hover {
    background: rgba(248, 113, 113, 0.3);
}

.card {
    background: var(--bg-card);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border-radius: 20px;
    padding: 24px;
    border: var(--glass-border);
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.2), 0 2px 4px -1px rgba(0, 0, 0, 0.1);
    transition: transform 0.2s, box-shadow 0.2s;
}

.card:hover {
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.3);
    border-color: rgba(255, 255, 255, 0.1);
}

.text-gold {
    color: var(--accent-gold) !important;
}

.stat-label-vip {
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.15em;
    color: var(--accent-gold);
    margin-bottom: 4px;
    opacity: 0.8;
}

/* Stats Grid */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 20px;
    margin-bottom: 30px;
}

.stat-card .value {
    font-size: 2.5rem;
    font-weight: 700;
    letter-spacing: -0.05em;
    margin: 10px 0;
}

.stat-card h3 {
    text-transform: uppercase;
    font-size: 0.75rem;
    letter-spacing: 0.1em;
    color: var(--text-secondary);
}

/* Main Grid */
.main-grid {
    display: grid;
    grid-template-columns: 1fr 350px;
    /* Layout asimetrico: Tabla + Logs */
    gap: 24px;
}

@media (max-width: 900px) {
    .main-grid {
        grid-template-columns: 1fr;
    }
}

h2 {
    font-size: 1.25rem;
    margin-top: 0;
    margin-bottom: 20px;
    display: flex;
    align-items: center;
    gap: 10px;
}

/* Pairs Grid */
.pairs-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}

.pair-card {
    padding: 16px;
    display: flex;
    flex-direction: column;
}

.pair-header {
    display: flex;
    justify-content: space-between;
    margin-bottom: 10px;
}

.pair-symbol {
    font-weight: 700;
    font-size: 0.95rem;
}

.pair-price {
    font-family: 'Roboto Mono', monospace;
    font-size: 0.9rem;
    color: var(--text-secondary);
}

.sparkline-container {
    height: 40px;
    width: 100%;
}

/* Logs */
.logs-list {
    list-style: none;
    padding: 0;
    margin: 0;
    max-height: 400px;
    overflow-y: auto;
    font-family: 'Roboto Mono', monospace;
    font-size: 0.85rem;
}

.logs-list li {
    padding: 8px 0;
    border-bottom: 1px solid var(--border-color);
    color: var(--text-secondary);
    display: flex;
    gap: 10px;
}

.logs-list li span.time {
    color: #64748b;
}

.logs-list li:first-child {
    color: var(--text-primary);
}

/* Table */
.positions-table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0 8px;
    /* Espacio entre filas */
    margin-top: -8px;
}

.positions-table th {
    text-align: left;
    color: var(--text-secondary);
    font-weight: 600;
    font-size: 0.85rem;
    padding: 0 16px;
}

.positions-table td {
    background: rgba(255, 255, 255, 0.03);
    padding: 16px;
}

.positions-table tr td:first-child {
    border-top-left-radius: 8px;
    border-bottom-left-radius: 8px;
}

.positions-table tr td:last-child {
    border-top-right-radius: 8px;
    border-bottom-right-radius: 8px;
}

.pos-pnl.positive {
    color: var(--accent-green);
    font-weight: 600;
}

.pos-pnl.negative {
    color: var(--accent-red);
    font-weight: 600;
}

.full-col {
    grid-column: 1 / -1;
}

/* Modal */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(5px);
    z-index: 1000;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.modal.show {
    display: flex;
    opacity: 1;
}

.modal-content {
    background: var(--bg-dark);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    width: 90%;
    max-width: 900px;
    padding: 24px;
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
    transform: scale(0.95);
    transition: transform 0.3s ease;
}

.modal.show .modal-content {
    transform: scale(1);
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.close-btn {
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 2rem;
    cursor: pointer;
    line-height: 0.5;
}

.close-btn:hover {
    color: var(--text-primary);
}

.chart-wrapper {
    height: 400px;
    width: 100%;
}

.pair-card {
    cursor: pointer;
    /* Clickable */
    transition: transform 0.2s, border-color 0.2s;
}

/* Ticker Tape */
.ticker-wrap {
    width: 100%;
    overflow: hidden;
    background-color: rgba(15, 23, 42, 0.95);
    border-bottom: 1px solid var(--border-color);
    padding-left: 100%;
    /* Start off-screen */
    box-sizing: border-box;
    white-space: nowrap;
}

.ticker {
    display: inline-block;
    padding: 10px 0;
    animation: ticker 30s linear infinite;
}

.ticker-item {
    display: inline-block;
    padding: 0 2rem;
    font-size: 0.9rem;
    color: var(--text-secondary);
}

.ticker-item strong {
    color: var(--text-primary);
}

.ticker-up {
    color: var(--accent-green);
}

.ticker-down {
    color: var(--accent-red);
}

@keyframes ticker {
    0% {
        transform: translate3d(0, 0, 0);
    }

    100% {
        transform: translate3d(-100%, 0, 0);
    }
}

/* RESTORED & IMPROVED STATUS BADGE */
.status-badge {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 12px;
    border-radius: 20px;
    font-size: 0.8rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    transition: all 0.3s ease;
}

.status-badge.online {
    background: rgba(16, 185, 129, 0.1);
    border: 1px solid rgba(16, 185, 129, 0.2);
    color: #34d399;
    box-shadow: 0 0 10px rgba(16, 185, 129, 0.1);
}

.status-badge.offline {
    background: rgba(239, 68, 68, 0.1);
    border: 1px solid rgba(239, 68, 68, 0.2);
    color: #ef4444;
}

.pulse-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background-color: currentColor;
}

.status-badge.online .pulse-dot {
    box-shadow: 0 0 0 rgba(52, 211, 153, 0.7);
    animation: status-pulse 2s infinite;
}

@keyframes status-pulse {
    0% {
        box-shadow: 0 0 0 0 rgba(52, 211, 153, 0.7);
    }

    70% {
        box-shadow: 0 0 0 6px rgba(52, 211, 153, 0);
    }

    100% {
        box-shadow: 0 0 0 0 rgba(52, 211, 153, 0);
    }
}

/* Smart Logs */
.log-item {
    display: flex;
    gap: 10px;
    padding: 8px 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.log-icon {
    font-size: 1.1rem;
}

.log-buy .log-icon {
    content: "🚀";
}

.log-sell .log-icon {
    content: "💰";
}

.log-ai .log-icon {
    content: "🤖";
}

.log-info .log-icon {
    content: "ℹ️";
}

.log-buy {
    color: var(--accent-green);
}

/* ===========================
   TURBO MODE THEME
=========================== */
body.turbo-mode {
    --bg-dark: #120909;
    /* Dark Reddish Black */
    --accent-blue: #fdba74;
    /* Orange */
    --accent-green: #fca5a5;
    /* Red/Pink ish for aggressive buys */
    /* Override Gradient */
    background: radial-gradient(circle at 50% 0%, #450a0a, #0f172a);
}

body.turbo-mode h1 {
    background: linear-gradient(135deg, #fbbf24, #ef4444);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    text-shadow: 0 0 20px rgba(251, 191, 36, 0.4);
}

body.turbo-mode .card {
    border: 1px solid rgba(251, 191, 36, 0.2);
    box-shadow: 0 0 15px rgba(251, 191, 36, 0.05);
}

body.turbo-mode .nav-tab.active {
    background: linear-gradient(135deg, #f59e0b, #ea580c);
    box-shadow: 0 4px 10px rgba(245, 158, 11, 0.4);
}

body.turbo-mode .status-dot {
    background-color: #ef4444;
    box-shadow: 0 0 0 rgba(239, 68, 68, 0.7);
    animation: turbo-pulse 0.5s infinite;
    /* Much faster pulse */
}

@keyframes turbo-pulse {
    0% {
        box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.7);
    }

    70% {
        box-shadow: 0 0 0 15px rgba(239, 68, 68, 0);
    }

    100% {
        box-shadow: 0 0 0 0 rgba(239, 68, 68, 0);
    }
}



/* ===========================
   TRADING MODE SWITCH
=========================== */
.mode-group {
    display: flex;
    background: rgba(255, 255, 255, 0.05);
    padding: 4px;
    border-radius: 8px;
    margin-right: 15px;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.btn-mode {
    background: transparent;
    border: none;
    color: #94a3b8;
    padding: 6px 10px;
    /* Reduced padding */
    border-radius: 6px;
    font-size: 0.75rem;
    /* Reduced font */
    cursor: pointer;
    font-weight: 700;
    /* Bold to maintain readability */
    transition: all 0.3s ease;
    white-space: nowrap;
    /* Prevent wrap */
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.btn-mode:hover {
    color: white;
    background: rgba(255, 255, 255, 0.05);
}

#btn-sim.active {
    background: var(--accent-green);
    color: #0f172a;
    box-shadow: 0 0 10px rgba(52, 211, 153, 0.3);
}

#btn-live.active {
    background: #ef4444;
    /* Red for Live Risk */
    color: white;
    box-shadow: 0 0 15px rgba(239, 68, 68, 0.5);
    animation: live-pulse 2s infinite;
}

@keyframes live-pulse {
    0% {
        box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.4);
    }

    70% {
        box-shadow: 0 0 0 6px rgba(239, 68, 68, 0);
    }

    100% {
        box-shadow: 0 0 0 0 rgba(239, 68, 68, 0);
    }
}

.log-ai {
    color: var(--accent-blue);
}

/* ===========================
   MOBILE OPTIMIZATIONS
   =========================== */
/* Default Brand Container (Desktop) */
.app-brand-container {
    display: flex;
    align-items: center;
    gap: 12px;
}

.app-brand-container h1 {
    color: #38bdf8;
    margin: 0;
}

/* ===========================
   MOBILE OPTIMIZATIONS
   =========================== */
@media (max-width: 768px) {
    body {
        padding: 12px;
    }

    /* HEADER: Stack Everything */
    header {
        flex-direction: column;
        align-items: center;
        gap: 15px;
        padding-bottom: 15px;
    }

    /* ROW 1: BRANDING */
    .app-brand-container {
        flex-direction: column;
        gap: 8px;
        width: 100%;
        text-align: center;
    }

    .app-brand-container h1 {
        font-size: 1.4rem;
        text-align: center;
        width: 100%;
    }

    /* Center the badges below title */
    .app-brand-container>div {
        margin: 0 auto;
    }

    /* Make subscription badge compact */
    .sub-badge {
        font-size: 0.75rem;
        padding: 4px 10px;
    }

    /* ROW 2: CONTROLS (Flex for easier stacking) */
    .controls {
        width: 100%;
        display: flex;
        flex-direction: column;
        gap: 12px;
        align-items: stretch;
    }

    .mode-group {
        margin: 0 !important;
        width: 100%;
        display: flex;
        justify-content: center;
        background: rgba(255, 255, 255, 0.03);
        padding: 8px;
    }

    .mode-switch-container {
        margin: 0;
        width: 100%;
        justify-content: center;
        background: rgba(255, 255, 255, 0.03);
    }

    /* Nav links fit in a grid of 2 cols/rows */
    .controls a {
        width: 100%;
        justify-content: center;
        display: flex;
        background: rgba(255, 255, 255, 0.05);
        font-size: 0.85rem;
    }

    /* ROW 3: ACTIONS */
    .actions {
        width: 100%;
        display: flex;
        flex-direction: column;
        gap: 10px;
    }

    .actions button {
        width: 100%;
        padding: 12px;
    }

    /* Tables (CRITICAL) */
    .positions-table {
        display: block;
        width: 100%;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        /* Smooth scroll on iOS */
        white-space: nowrap;
        border-radius: 8px;
    }

    .positions-table td,
    .positions-table th {
        padding: 12px 10px;
        font-size: 0.8rem;
    }


    /* Adjust Grid for Stats */
    .stats-grid {
        grid-template-columns: 1fr;
        gap: 12px;
    }

    .stat-card .value {
        font-size: 2rem;
    }

    .chart-wrapper {
        height: 250px;
    }
}

/* COMMERCIAL BANNER (Global) */
.upgrade-banner {
    background: linear-gradient(135deg, #2563eb, #7c3aed);
    color: white;
    padding: 15px 20px;
    border-radius: 12px;
    margin-bottom: 25px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    cursor: pointer;
    box-shadow: 0 4px 6px -1px rgba(124, 58, 237, 0.3);
    border: 1px solid rgba(255, 255, 255, 0.1);
    transition: transform 0.2s, box-shadow 0.2s;
}

.upgrade-banner:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 15px -3px rgba(124, 58, 237, 0.4);
}

.btn-upgrade {
    background: rgba(255, 255, 255, 0.2);
    border: 1px solid rgba(255, 255, 255, 0.4);
    color: white;
    padding: 8px 16px;
    border-radius: 8px;
    font-weight: 700;
    font-size: 0.85rem;
    transition: background 0.2s;
}

.upgrade-banner:hover .btn-upgrade {
    background: white;
    color: #7c3aed;
}

/* SUBSCRIPTION BADGE */
.sub-badge {
    display: flex;
    align-items: center;
    background: rgba(15, 23, 42, 0.6);
    border: 1px solid rgba(148, 163, 184, 0.2);
    padding: 6px 12px;
    border-radius: 8px;
    font-size: 0.8rem;
    color: #94a3b8;
    margin-left: 10px;
}