/* Gamma Scalper V2 Dashboard Styles */

:root {
    --bg-primary: #0a0e17;
    --bg-secondary: #111827;
    --bg-card: #1a2234;
    --bg-input: #0d1321;
    --border: #2a3548;
    --text-primary: #e5e7eb;
    --text-secondary: #9ca3af;
    --text-muted: #6b7280;
    --accent: #3b82f6;
    --accent-hover: #2563eb;
    --green: #10b981;
    --red: #ef4444;
    --orange: #f59e0b;
    --purple: #8b5cf6;
}

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

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

header {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 16px 24px;
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border);
}

header h1 {
    font-size: 1.4rem;
    font-weight: 700;
}

.badge {
    padding: 4px 10px;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.badge-live {
    background: var(--red);
    color: white;
    animation: pulse 2s infinite;
}

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

#btc-price-header {
    margin-left: auto;
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 14px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 6px;
    font-family: 'JetBrains Mono', 'SF Mono', 'Fira Code', monospace;
}

.btc-label {
    font-size: 0.8rem;
    font-weight: 700;
    color: var(--orange);
    letter-spacing: 0.5px;
}

.btc-price {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--text-primary);
    min-width: 90px;
    text-align: right;
}

.btc-change {
    font-size: 0.75rem;
    font-weight: 600;
    min-width: 40px;
}

.btc-change.up { color: var(--green); }
.btc-change.down { color: var(--red); }
.btc-change.flat { color: var(--text-muted); }

/* Flash animation on price update */
@keyframes price-flash-up {
    0% { color: var(--green); text-shadow: 0 0 8px rgba(16, 185, 129, 0.4); }
    100% { color: var(--text-primary); text-shadow: none; }
}
@keyframes price-flash-down {
    0% { color: var(--red); text-shadow: 0 0 8px rgba(239, 68, 68, 0.4); }
    100% { color: var(--text-primary); text-shadow: none; }
}
.btc-price.flash-up { animation: price-flash-up 0.6s ease-out; }
.btc-price.flash-down { animation: price-flash-down 0.6s ease-out; }

#stream-status-bar {
    margin-left: 12px;
    display: flex;
    gap: 8px;
    font-size: 0.8rem;
}

.stream-dot {
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.stream-dot::before {
    content: '';
    width: 8px;
    height: 8px;
    border-radius: 50%;
    display: inline-block;
}

.stream-dot.connected::before { background: var(--green); }
.stream-dot.disconnected::before { background: var(--red); }
.stream-dot.reconnecting::before { background: var(--orange); }

/* Sections */
section {
    margin: 20px 24px;
    padding: 20px;
    background: var(--bg-secondary);
    border-radius: 8px;
    border: 1px solid var(--border);
}

section h2 {
    font-size: 1.1rem;
    margin-bottom: 16px;
    color: var(--text-primary);
}

.section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

/* Form */
.form-row {
    display: flex;
    gap: 16px;
    margin-bottom: 12px;
    flex-wrap: wrap;
}

.form-group {
    flex: 1;
    min-width: 140px;
}

.form-group label {
    display: block;
    font-size: 0.8rem;
    color: var(--text-secondary);
    margin-bottom: 4px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.form-group input,
.form-group select {
    width: 100%;
    padding: 10px 12px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: 6px;
    color: var(--text-primary);
    font-size: 0.95rem;
}

.form-group input:focus,
.form-group select:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.2);
}

.input-group {
    display: flex;
    gap: 8px;
}

.input-group input { flex: 1; }

.form-group-action {
    display: flex;
    align-items: flex-end;
}

/* Buttons */
button {
    cursor: pointer;
    border: none;
    border-radius: 6px;
    font-size: 0.9rem;
    font-weight: 600;
    padding: 10px 16px;
    transition: all 0.15s;
}

.btn-primary {
    background: var(--accent);
    color: white;
}
.btn-primary:hover { background: var(--accent-hover); }

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

.btn-danger {
    background: var(--red);
    color: white;
}
.btn-danger:hover { background: #dc2626; }

.btn-small {
    padding: 6px 12px;
    font-size: 0.8rem;
    background: var(--bg-card);
    color: var(--text-primary);
    border: 1px solid var(--border);
}

/* Modal */
.modal {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.7);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.hidden { display: none !important; }

.modal-content {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 24px;
    max-width: 500px;
    width: 90%;
}

.modal-content h2 {
    margin-bottom: 16px;
    color: var(--orange);
}

.modal-actions {
    display: flex;
    gap: 12px;
    margin-top: 20px;
    justify-content: flex-end;
}

/* Confirm details */
.confirm-row {
    display: flex;
    justify-content: space-between;
    padding: 6px 0;
    border-bottom: 1px solid var(--border);
}

.confirm-row:last-child { border-bottom: none; }
.confirm-label { color: var(--text-secondary); }
.confirm-value { font-weight: 600; }

/* Run cards */
.run-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 16px;
    margin-bottom: 12px;
    cursor: pointer;
    transition: border-color 0.15s;
}

.run-card:hover { border-color: var(--accent); }

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

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

.run-card-meta {
    display: flex;
    gap: 16px;
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.run-card-pnl {
    font-size: 1.1rem;
    font-weight: 700;
}

.pnl-positive { color: var(--green); }
.pnl-negative { color: var(--red); }
.pnl-zero { color: var(--text-muted); }

/* State badges */
.state-badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
}

.state-INIT { background: var(--text-muted); color: white; }
.state-ENTERING_OPTIONS { background: var(--purple); color: white; }
.state-BUILDING_GRID { background: var(--orange); color: white; }
.state-ACTIVE_GRID { background: var(--green); color: white; }
.state-STOPPING { background: var(--red); color: white; }
.state-CLOSED { background: #374151; color: var(--text-secondary); }

/* Detail view */
.detail-header {
    display: flex;
    align-items: center;
    gap: 16px;
    margin-bottom: 16px;
}

.detail-header h2 { margin: 0; flex: 1; }

.detail-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 16px;
    margin-bottom: 16px;
}

.detail-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 16px;
}

.detail-card h3 {
    font-size: 0.9rem;
    color: var(--text-secondary);
    margin-bottom: 12px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* Grid table */
#grid-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.85rem;
}

#grid-table th {
    text-align: left;
    padding: 8px 12px;
    background: var(--bg-input);
    color: var(--text-secondary);
    font-weight: 600;
    text-transform: uppercase;
    font-size: 0.75rem;
    letter-spacing: 0.5px;
}

#grid-table td {
    padding: 8px 12px;
    border-bottom: 1px solid var(--border);
}

#grid-table tr:hover {
    background: rgba(59, 130, 246, 0.05);
}

.side-buy { color: var(--green); font-weight: 600; }
.side-sell { color: var(--red); font-weight: 600; }

.status-OPEN { color: var(--accent); }
.status-FILLED { color: var(--green); }
.status-CANCELLED { color: var(--text-muted); }
.status-REJECTED { color: var(--red); }

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

/* Filter buttons */
.filter-btn {
    padding: 4px 12px;
    font-size: 0.8rem;
    background: var(--bg-card);
    color: var(--text-secondary);
    border: 1px solid var(--border);
    border-radius: 4px;
    margin-right: 4px;
}

.filter-btn.active {
    background: var(--accent);
    color: white;
    border-color: var(--accent);
}

/* History */
#history-section { display: none; }
#history-section.visible { display: block; }

/* Footer */
footer {
    text-align: center;
    padding: 20px;
    color: var(--text-muted);
    font-size: 0.8rem;
}

/* Loading */
.loading {
    text-align: center;
    padding: 20px;
    color: var(--text-muted);
}

/* Responsive */
@media (max-width: 768px) {
    .form-row { flex-direction: column; }
    .detail-grid { grid-template-columns: 1fr; }
    header { flex-wrap: wrap; }
}
