/* Trading Dashboard Styles */

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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background: linear-gradient(135deg, #0f0f1e 0%, #1a1a2e 100%);
    color: #e0e0e0;
    line-height: 1.6;
}

.container {
    max-width: 1600px;
    margin: 0 auto;
    padding: 20px;
}

/* ─────────────────────────────────────────────────────────────────────────── */
/* HEADER */
/* ─────────────────────────────────────────────────────────────────────────── */

.header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 30px;
    padding: 20px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 12px;
    backdrop-filter: blur(10px);
}

.header h1 {
    font-size: 32px;
    font-weight: 700;
    margin-bottom: 5px;
    background: linear-gradient(135deg, #00d4ff, #7c3aed);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.subtitle {
    font-size: 14px;
    color: #888;
    font-weight: 400;
}

.header-right {
    display: flex;
    align-items: center;
    gap: 20px;
}

.timestamp {
    font-size: 13px;
    color: #888;
    font-family: 'Courier New', monospace;
}

.btn-refresh {
    padding: 10px 20px;
    background: linear-gradient(135deg, #00d4ff, #7c3aed);
    color: white;
    border: none;
    border-radius: 8px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    font-size: 14px;
}

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

.btn-refresh:active {
    transform: translateY(0);
}

/* ─────────────────────────────────────────────────────────────────────────── */
/* SUMMARY SECTION */
/* ─────────────────────────────────────────────────────────────────────────── */

.summary-section {
    margin-bottom: 40px;
}

.summary-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 20px;
}

.summary-card {
    padding: 20px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 12px;
    backdrop-filter: blur(10px);
    transition: all 0.3s ease;
}

.summary-card:hover {
    background: rgba(255, 255, 255, 0.08);
    border-color: rgba(0, 212, 255, 0.3);
    transform: translateY(-2px);
}

.summary-label {
    font-size: 13px;
    color: #888;
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: 10px;
    font-weight: 600;
}

.summary-value {
    font-size: 28px;
    font-weight: 700;
    margin-bottom: 5px;
    background: linear-gradient(135deg, #00d4ff, #7c3aed);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.summary-sub {
    font-size: 12px;
    color: #666;
}

/* ─────────────────────────────────────────────────────────────────────────── */
/* BOTS SECTION */
/* ─────────────────────────────────────────────────────────────────────────── */

.bots-section {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(100%, 1fr));
    gap: 25px;
}

.bot-panel {
    padding: 25px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 12px;
    backdrop-filter: blur(10px);
}

.bot-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    padding-bottom: 15px;
    border-bottom: 2px solid rgba(255, 255, 255, 0.1);
}

.bot-header h2 {
    font-size: 22px;
    font-weight: 700;
    color: #e0e0e0;
}

.status-badge {
    padding: 6px 14px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.status-running {
    background: rgba(46, 204, 113, 0.2);
    color: #2ecc71;
    border: 1px solid rgba(46, 204, 113, 0.4);
}

.status-stopped {
    background: rgba(231, 76, 60, 0.2);
    color: #e74c3c;
    border: 1px solid rgba(231, 76, 60, 0.4);
}

.bot-info {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 15px;
    margin-bottom: 20px;
}

.info-item {
    display: flex;
    justify-content: space-between;
    padding: 10px;
    background: rgba(0, 212, 255, 0.05);
    border-radius: 8px;
    border-left: 3px solid rgba(0, 212, 255, 0.3);
}

.info-item .label {
    color: #888;
    font-size: 12px;
    font-weight: 600;
}

.info-item .value {
    color: #00d4ff;
    font-weight: 700;
}

/* ─────────────────────────────────────────────────────────────────────────── */
/* POSITIONS */
/* ─────────────────────────────────────────────────────────────────────────── */

.positions-section {
    margin: 20px 0;
}

.positions-section h3 {
    font-size: 16px;
    font-weight: 700;
    margin-bottom: 15px;
    color: #e0e0e0;
}

.positions-table {
    background: rgba(0, 0, 0, 0.3);
    border-radius: 8px;
    overflow: hidden;
}

.position-row {
    display: grid;
    grid-template-columns: 100px 1fr 120px 120px 120px;
    gap: 15px;
    padding: 15px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    align-items: center;
    transition: all 0.3s ease;
}

.position-row:last-child {
    border-bottom: none;
}

.position-row:hover {
    background: rgba(0, 212, 255, 0.05);
}

.position-symbol {
    font-weight: 700;
    color: #00d4ff;
}

.position-details {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    font-size: 12px;
    color: #888;
}

.position-detail {
    display: flex;
    justify-content: space-between;
}

.position-price {
    text-align: right;
    font-family: 'Courier New', monospace;
}

.position-pnl {
    text-align: right;
    font-weight: 700;
}

.pnl-positive {
    color: #2ecc71;
}

.pnl-negative {
    color: #e74c3c;
}

.loading {
    padding: 20px;
    text-align: center;
    color: #666;
    font-size: 14px;
}

/* ─────────────────────────────────────────────────────────────────────────── */
/* BITGET BOTS */
/* ─────────────────────────────────────────────────────────────────────────── */

.bitget-bots {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-bottom: 20px;
}

.bitget-bot-card {
    padding: 16px 20px;
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 10px;
    transition: border-color 0.2s;
}

.bitget-bot-card:hover {
    border-color: rgba(0, 212, 255, 0.25);
}

.bitget-symbol {
    font-weight: 700;
    color: #00d4ff;
    font-size: 15px;
}

.bitget-detail {
    display: flex;
    justify-content: space-between;
    font-size: 13px;
    padding: 5px 0;
    color: #ccc;
}

.bitget-detail .label {
    color: #888;
}

/* ─────────────────────────────────────────────────────────────────────────── */
/* BOT STATS */
/* ─────────────────────────────────────────────────────────────────────────── */

.bot-stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 15px;
    margin-top: 20px;
    padding-top: 20px;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.stat {
    padding: 15px;
    background: rgba(0, 212, 255, 0.05);
    border-radius: 8px;
    border-left: 3px solid rgba(0, 212, 255, 0.3);
    display: flex;
    justify-content: space-between;
    font-size: 13px;
}

.stat span:first-child {
    color: #888;
    font-weight: 600;
}

.stat span:last-child {
    color: #00d4ff;
    font-weight: 700;
}

/* ─────────────────────────────────────────────────────────────────────────── */
/* RESPONSIVE */
/* ─────────────────────────────────────────────────────────────────────────── */

@media (max-width: 1024px) {
    .header {
        flex-direction: column;
        gap: 15px;
        text-align: center;
    }

    .header-right {
        width: 100%;
        justify-content: center;
    }

    .position-row {
        grid-template-columns: 1fr;
        gap: 8px;
    }

    .position-details {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 768px) {
    .container {
        padding: 10px;
    }

    .header h1 {
        font-size: 24px;
    }

    .summary-grid {
        grid-template-columns: 1fr;
    }

    .bot-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 10px;
    }

    .bitget-bots {
        grid-template-columns: 1fr;
    }

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

/* ─────────────────────────────────────────────────────────────────────────── */
/* ANIMATIONS */
/* ─────────────────────────────────────────────────────────────────────────── */

@keyframes pulse {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0.7;
    }
}

.loading {
    animation: pulse 1.5s ease-in-out infinite;
}

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

.position-row {
    animation: fadeIn 0.3s ease;
}

/* ─────────────────────────────────────────────────────────────────────────── */
/* SCROLLBAR */
/* ─────────────────────────────────────────────────────────────────────────── */

::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.1);
}

::-webkit-scrollbar-thumb {
    background: rgba(0, 212, 255, 0.3);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: rgba(0, 212, 255, 0.5);
}

/* ─────────────────────────────────────────────────────────────────────────── */
/* CONDITIONS BLOCK                                                             */
/* ─────────────────────────────────────────────────────────────────────────── */

.bot-card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 14px;
    flex-wrap: wrap;
    gap: 8px;
}

.bot-meta {
    display: flex;
    gap: 24px;
    font-size: 13px;
    color: #aaa;
    align-items: center;
    flex-wrap: wrap;
}

.bot-meta strong { color: #00d4ff; }

.tf-badge {
    display: inline-block;
    background: rgba(0, 212, 255, 0.15);
    color: #00d4ff;
    border-radius: 4px;
    padding: 2px 8px;
    font-size: 11px;
    font-weight: 700;
    margin-left: 6px;
    vertical-align: middle;
    letter-spacing: 0.05em;
}

/* ── Conditions wrapper ── */
.conditions-block {
    background: rgba(0,0,0,0.15);
    border: 1px solid rgba(255,255,255,0.06);
    border-radius: 8px;
    overflow: hidden;
}

.conditions-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 16px;
    background: rgba(0,0,0,0.2);
    border-bottom: 1px solid rgba(255,255,255,0.06);
}

.cond-count { font-size: 12px; color: #777; }

/* ── Single flat table: all conditions in one row-based table ── */
.cond-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}

/* Section header row (ENTRY / EXIT) */
.cond-section-row td {
    padding: 6px 16px 4px;
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: #555;
    background: rgba(0,0,0,0.1);
    border-bottom: 1px solid rgba(255,255,255,0.04);
}

/* Data rows */
.cond-row td {
    padding: 8px 16px;
    border-bottom: 1px solid rgba(255,255,255,0.04);
    vertical-align: middle;
    white-space: nowrap;
}

.cond-row:last-child td { border-bottom: none; }

/* Col 1: icon + label */
.cond-row .col-label {
    width: 40%;
    color: #bbb;
    font-size: 12.5px;
}

/* Col 2: live value (monospaced) */
.cond-row .col-value {
    width: 40%;
    font-family: 'Courier New', monospace;
    font-size: 12px;
    color: #00d4ff;
}

/* Col 3: status */
.cond-row .col-status {
    width: 20%;
    text-align: right;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.04em;
}

/* Met / unmet row styling */
.cond-row.met .col-label  { color: #ccc; }
.cond-row.unmet .col-label { color: #666; }
.cond-row.unmet .col-value { color: #555; }
.cond-row.met .col-status  { color: #2ecc71; }
.cond-row.unmet .col-status { color: #e74c3c; }

/* EXIT conditions are dimmer (only fire on position close) */
.cond-row.exit-row.met .col-status   { color: #e67e22; }
.cond-row.exit-row.unmet .col-status { color: #444; }

/* Signal badge */
.signal-badge {
    display: inline-block;
    padding: 3px 12px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.06em;
}

.badge-buy  { background: rgba(46,204,113,0.2);   color: #2ecc71; border: 1px solid rgba(46,204,113,0.4); }
.badge-sell { background: rgba(231,76,60,0.2);    color: #e74c3c; border: 1px solid rgba(231,76,60,0.4); }
.badge-hold { background: rgba(149,165,166,0.12); color: #95a5a6; border: 1px solid rgba(149,165,166,0.25); }

.cond-loading, .cond-error {
    font-size: 12px;
    color: #555;
    padding: 12px 16px;
    text-align: center;
}
.cond-error { color: #e74c3c; }
