/* ============================================================
   Futures Demo — Global Stylesheet
   ============================================================ */

/* ---------- Reset ---------- */
*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }

/* ---------- Base ---------- */
body {
    background: #0a0c12;
    color: #eef2ff;
    font-family: system-ui, -apple-system, sans-serif;
    padding: 16px;
    padding-bottom: 80px;
    min-height: 100vh;
}

/* ---------- Top Bar ---------- */
.top-bar {
    position: fixed;
    top: 0; left: 0; right: 0;
    height: 52px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 14px;
    background: #0a0f1e;
    border-bottom: 1px solid #2a2e45;
    z-index: 900;
}
.top-bar .app-title { font-size: 1rem; font-weight: 700; color: #e2e8f0; flex: 1; text-align: center; }
.page-content { padding-top: 66px; padding-bottom: 80px; padding-left: 16px; padding-right: 16px; }
.hamburger { font-size: 28px; background: none; border: none; color: white; cursor: pointer; margin-right: 16px; line-height: 1; padding: 4px; }
.app-title { font-size: 1.2rem; font-weight: 600; color: #3b82f6; white-space: nowrap; }

/* ---------- Drawer ---------- */
.drawer { position: fixed; top: 0; left: -280px; width: 260px; height: 100%; background: #131625; border-right: 1px solid #2a2e45; transition: left 0.3s ease; z-index: 1000; padding-top: 60px; box-shadow: 2px 0 12px rgba(0,0,0,0.5); }
.drawer.open { left: 0; }
.drawer-item { padding: 16px 24px; color: #e2e8f0; font-size: 1rem; font-weight: 500; border-bottom: 1px solid #2a2e45; cursor: pointer; transition: background 0.15s; }
.drawer-item:hover { background: #1e293b; }
.drawer-item.logout { color: #ef4444; }
.drawer-item.active { background: #1e293b; border-left: 3px solid #3b82f6; }
.overlay { position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: rgba(0,0,0,0.5); z-index: 999; display: none; }
.overlay.show { display: block; }

/* ---------- Cards ---------- */
.card { background: #131625; border-radius: 24px; padding: 18px; margin-bottom: 16px; border: 1px solid #2a2e45; }
.card-title { font-size: 1.1rem; font-weight: 700; color: #38bdf8; margin-bottom: 16px; }
.balance-card { background: linear-gradient(135deg, #1e293b, #0f172a); border-radius: 28px; padding: 20px; margin-bottom: 20px; text-align: center; }
.balance-amount { font-size: 2.2rem; font-weight: 800; color: #3b82f6; }
.pnl { font-size: 1rem; margin-top: 8px; }

/* ---------- Form Elements ---------- */
input, select { width: 100%; padding: 12px 14px; background: #0a0f1e; border: 1px solid #1e293b; border-radius: 14px; color: #e2e8f0; font-size: 1rem; margin-bottom: 12px; transition: border-color 0.2s; }
input:focus, select:focus { outline: none; border-color: #3b82f6; }

/* ---------- Buttons ---------- */
.btn { padding: 14px; border-radius: 50px; font-weight: 800; border: none; cursor: pointer; transition: opacity 0.15s, transform 0.1s; }
.btn:active { transform: scale(0.97); }
.btn:disabled { opacity: 0.6; cursor: not-allowed; }
.btn-long  { background: linear-gradient(135deg, #059669, #10b981); color: #fff; }
.btn-short { background: linear-gradient(135deg, #dc2626, #ef4444); color: #fff; }
.btn-close { background: #475569; color: white; }
.btn-primary { background: #3b82f6; color: white; }
.btn-secondary { background: #334155; color: white; }
.btn-danger { background: #ef4444; color: white; }
.buttonsetting { background: #3b82f6; color: white; border: none; padding: 12px; border-radius: 40px; font-weight: bold; font-size: 0.95rem; cursor: pointer; width: 100%; margin-top: 8px; transition: opacity 0.15s; }
.buttonsetting:hover { opacity: 0.9; }
.buttonsetting.btn-secondary { background: #334155; }
.buttonsetting.btn-danger    { background: #ef4444; }

/* ---------- Footer ---------- */
.bottom-footer { position: fixed; bottom: 0; left: 0; right: 0; background: #0f1222; padding: 12px; display: flex; gap: 12px; border-top: 1px solid #2a2e45; z-index: 100; }
.footer-btn { flex: 1; background: #2563eb; border: none; padding: 12px; border-radius: 40px; color: white; font-weight: bold; text-align: center; cursor: pointer; transition: background 0.15s; }
.footer-btn.active { background: #3b82f6; box-shadow: 0 0 0 2px #60a5fa; }

/* ---------- Mode Toggle ---------- */
.mode-toggle { display: flex; gap: 12px; margin-bottom: 20px; }
.mode-btn { flex: 1; background: #1e293b; border: none; padding: 10px; border-radius: 40px; color: white; font-weight: bold; cursor: pointer; transition: background 0.15s; }
.mode-btn.active { background: #3b82f6; }

/* ---------- Fields ---------- */
.field { margin-bottom: 14px; }
.field label { display: block; font-size: 0.75rem; color: #64748b; margin-bottom: 6px; text-transform: uppercase; letter-spacing: 0.05em; }
.field input, .field select { margin-bottom: 0; }
.lev-row { display: flex; align-items: center; gap: 12px; }
.lev-row input[type="range"] { flex: 1; height: 4px; accent-color: #3b82f6; }
.lev-badge { background: #0c2233; color: #38bdf8; font-weight: 700; padding: 6px 14px; border-radius: 30px; white-space: nowrap; min-width: 48px; text-align: center; }

/* ---------- Preview Grid ---------- */
.preview-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 12px; }
.pv-item { text-align: center; background: #0a0f1e; padding: 8px; border-radius: 12px; }
.pv-label { font-size: 0.7rem; color: #64748b; }
.pv-value { font-size: 1rem; font-weight: 700; color: #38bdf8; }
.action-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 12px; }

/* ---------- Position Cards ---------- */
.pos-card { background: #0a0f1e; border-radius: 18px; padding: 14px; margin-bottom: 12px; border: 1px solid #1e293b; }
.pos-header { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 8px; }
.pos-type { font-weight: 800; padding: 4px 12px; border-radius: 20px; font-size: 0.8rem; }
.long  { background: #0f3b2c; color: #10b981; }
.short { background: #3b1e1e; color: #ef4444; }
.close-btn { background: #ef4444; border: none; padding: 6px 14px; border-radius: 30px; color: white; font-weight: bold; cursor: pointer; font-size: 0.85rem; transition: opacity 0.15s; }
.close-btn:hover { opacity: 0.85; }
.edit-icon, .graph-icon { background: none; border: none; color: #38bdf8; font-size: 1.1rem; cursor: pointer; margin-left: 6px; padding: 2px 4px; border-radius: 6px; transition: background 0.15s; }
.edit-icon:hover, .graph-icon:hover { background: rgba(56,189,248,0.12); }
.auto-rule { font-size: 0.7rem; margin-top: 6px; color: #f59e0b; background: #1a1a2e; padding: 4px 8px; border-radius: 20px; display: inline-block; }
.liq-info { font-size: 0.7rem; color: #f59e0b; margin-top: 6px; }
.transaction-item { padding: 8px; border-bottom: 1px solid #2a2e45; font-size: 0.85rem; }
.transaction-item:last-child { border-bottom: none; }

/* ---------- Modals ---------- */
.modal { display: none; position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: rgba(0,0,0,0.8); z-index: 2000; justify-content: center; align-items: center; padding: 16px; }
.modal.open { display: flex; }
.modal-content { background: #131625; border-radius: 28px; width: 100%; max-width: 500px; padding: 20px; border: 1px solid #3b82f6; }
.modal-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 16px; }
.modal-header h3 { color: #38bdf8; font-size: 1.1rem; }
.close-modal { background: none; border: none; color: #94a3b8; font-size: 24px; cursor: pointer; line-height: 1; padding: 2px 6px; border-radius: 8px; transition: background 0.15s; }
.close-modal:hover { background: rgba(148,163,184,0.15); }
.timeframe-buttons { display: flex; gap: 8px; margin-bottom: 16px; flex-wrap: wrap; }
.timeframe-btn { background: #1e293b; border: none; padding: 6px 14px; border-radius: 30px; color: white; cursor: pointer; font-size: 0.85rem; transition: background 0.15s; }
.timeframe-btn.active { background: #3b82f6; }

/* Chart container — fixes blank chart bug */
.chart-wrapper { position: relative; width: 100%; height: 260px; }
.chart-wrapper canvas { position: absolute; top: 0; left: 0; width: 100% !important; height: 100% !important; }

/* Confirm modal */
.confirm-modal { display: none; position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: rgba(0,0,0,0.7); z-index: 3000; justify-content: center; align-items: center; padding: 16px; }
.confirm-modal.open { display: flex; }
.confirm-modal-content { background: #131625; border-radius: 28px; width: 300px; padding: 24px; text-align: center; border: 1px solid #3b82f6; }
.confirm-buttons { display: flex; gap: 12px; margin-top: 20px; }
.confirm-buttons button { flex: 1; padding: 10px; border-radius: 40px; border: none; font-weight: bold; cursor: pointer; transition: opacity 0.15s; }
.confirm-yes { background: #ef4444; color: white; }
.confirm-no  { background: #334155; color: white; }

/* Advanced toggle */
.advance-toggle { background: #1e293b; border: none; color: #38bdf8; cursor: pointer; margin-bottom: 16px; text-align: left; width: 100%; padding: 8px 12px; border-radius: 20px; font-size: 0.9rem; transition: background 0.15s; }
.advance-toggle:hover { background: #263448; }
.auto-close-row { display: flex; gap: 12px; margin-bottom: 12px; align-items: center; }
.auto-close-row label { flex: 1; color: #cbd5e1; font-size: 0.85rem; }
.auto-close-row input { flex: 2; margin: 0; }

/* ---------- Notifications ---------- */
.notification { position: fixed; bottom: 80px; left: 16px; right: 16px; background: #1e293b; border-left: 4px solid #3b82f6; padding: 12px 16px; border-radius: 12px; z-index: 1100; animation: fadeInUp 0.3s ease; font-size: 0.9rem; }
.notification.error   { border-left-color: #ef4444; background: #2a1e1e; }
.notification.success { border-left-color: #10b981; background: #0f2a1e; }
@keyframes fadeInUp { from { opacity: 0; transform: translateY(20px); } to { opacity: 1; transform: translateY(0); } }

/* ---------- Login page ---------- */
body.login-page { display: flex; justify-content: center; align-items: center; padding: 20px; padding-bottom: 20px; }
.login-card { background: #1e1f33; border-radius: 32px; padding: 32px 24px; width: 100%; max-width: 400px; box-shadow: 0 8px 24px rgba(0,0,0,0.4); }
.login-card h1 { font-size: 1.8rem; margin-bottom: 24px; text-align: center; color: #3b82f6; }
.step { display: none; }
.step.active { display: block; }
.pin-inputs { display: flex; gap: 10px; justify-content: center; margin: 16px 0; }
.pin-input { width: 50px; height: 60px; text-align: center; font-size: 1.8rem; background: #0f1222; border: 1px solid #2a2e45; border-radius: 12px; color: #fff; margin-bottom: 0; transition: border-color 0.2s; }
.pin-input:focus { border-color: #3b82f6; outline: none; }
.login-btn { width: 100%; padding: 14px; background: #3b82f6; border: none; border-radius: 40px; font-weight: bold; font-size: 1rem; margin-top: 16px; cursor: pointer; color: white; transition: opacity 0.15s; }
.login-btn:hover { opacity: 0.9; }
.link { text-align: center; margin-top: 16px; color: #94a3b8; cursor: pointer; font-size: 0.9rem; transition: color 0.15s; }
.link:hover { color: #cbd5e1; }
.error { color: #ef4444; font-size: 0.85rem; margin-top: 8px; text-align: center; min-height: 20px; }

/* ---------- Settings ---------- */
.info-row { display: flex; justify-content: space-between; margin-bottom: 12px; font-size: 0.95rem; }
.info-label { color: #94a3b8; }
.info-value { font-weight: 600; word-break: break-all; text-align: right; }
.api-key-item { background: #0a0f1e; border-radius: 16px; padding: 12px; margin-bottom: 12px; display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 8px; }
.api-key-info { flex: 2; min-width: 150px; }
.api-key-actions { display: flex; gap: 8px; }
.api-key-actions button { padding: 6px 12px; font-size: 0.8rem; margin: 0; width: auto; border-radius: 20px; border: none; font-weight: 600; cursor: pointer; }
.badge { background: #1e293b; padding: 4px 10px; border-radius: 20px; font-size: 0.7rem; display: inline-block; margin-top: 4px; }
.flex-buttons { display: flex; gap: 12px; margin-top: 16px; }
.flex-buttons button { margin-top: 0; }

/* ---------- Debug panel ---------- */
.debug-btn { position: fixed; bottom: 20px; right: 20px; background: #334155; border-radius: 30px; padding: 8px 16px; font-size: 12px; cursor: pointer; z-index: 1000; border: none; color: white; }
.debug-panel { position: fixed; bottom: 80px; right: 20px; left: 20px; max-height: 300px; background: #0f1222; border: 1px solid #3b82f6; border-radius: 16px; overflow-y: auto; z-index: 999; display: none; padding: 12px; font-family: monospace; font-size: 11px; color: #cbd5e1; }
.debug-panel.show { display: block; }
.log-entry { border-bottom: 1px solid #334155; padding: 6px; font-size: 11px; }
.log-error   { color: #f87171; }
.log-success { color: #4ade80; }

/* ---------- Utilities ---------- */
.hidden { display: none !important; }
.text-green { color: #10b981; }
.text-red   { color: #ef4444; }
/* ======================================================
   FIXED TOP BAR
   ====================================================== */
.top-bar {
    position: fixed; top: 0; left: 0; right: 0; height: 52px;
    display: flex; align-items: center; justify-content: space-between;
    padding: 0 14px;
    background: #0a0f1e;
    border-bottom: 1px solid #2a2e45;
    z-index: 900;
    max-width: 480px; margin: 0 auto;
}
.top-bar .app-title { font-size: 1rem; font-weight: 700; color: #e2e8f0; flex: 1; text-align: center; }
.page-content { padding-top: 66px; padding-bottom: 80px; padding-left: 16px; padding-right: 16px; }

/* ======================================================
   DEMO / REAL PILL  (right side of header — links to real.html)
   ====================================================== */
.mode-pill {
    display: flex; align-items: center; gap: 6px;
    background: rgba(16,185,129,0.12);
    border: 1px solid rgba(16,185,129,0.35);
    border-radius: 30px; padding: 5px 12px;
    font-size: 0.72rem; font-weight: 800;
    color: #10b981; letter-spacing: 0.06em;
    white-space: nowrap; text-decoration: none;
    cursor: pointer; transition: background 0.2s;
}
.mode-pill:hover { background: rgba(16,185,129,0.25); }
.mode-pill-dot { width: 7px; height: 7px; border-radius: 50%; }
.mode-pill-dot.demo { background: #10b981; animation: pulseDot 2s infinite; }
@keyframes pulseDot { 0%,100%{opacity:1} 50%{opacity:0.35} }

/* ======================================================
   PAIR COMBO — click to open, search inside, highlight
   ====================================================== */
.pair-combo { position: relative; }

.pair-selected {
    display: flex; align-items: center; justify-content: space-between;
    background: #1e293b; border: 1px solid #334155; border-radius: 14px;
    padding: 12px 16px; cursor: pointer;
    font-size: 1rem; font-weight: 700; color: #e2e8f0;
    transition: border-color 0.15s;
    user-select: none;
}
.pair-selected:hover { border-color: #3b82f6; }
.pair-chevron { color: #64748b; font-size: 0.7rem; margin-left: 8px; }

.pair-dropdown {
    display: none; position: absolute;
    top: calc(100% + 6px); left: 0; right: 0;
    background: #131625; border: 1px solid #3b82f6; border-radius: 16px;
    z-index: 700; box-shadow: 0 16px 40px rgba(0,0,0,0.65); overflow: hidden;
}
.pair-dropdown.open { display: block; }

.pair-search-wrap { padding: 10px 12px; border-bottom: 1px solid #1e293b; }
.pair-search-wrap input {
    width: 100%; background: #0a0f1e; border: 1px solid #334155;
    border-radius: 10px; padding: 9px 12px; color: #e2e8f0;
    font-size: 0.9rem; margin: 0; box-sizing: border-box;
}
.pair-search-wrap input:focus { border-color: #3b82f6; outline: none; }

.pair-list { max-height: 230px; overflow-y: auto; }

.pair-opt {
    display: flex; align-items: center; gap: 10px;
    padding: 11px 16px; cursor: pointer;
    border-bottom: 1px solid #1a2035;
    transition: background 0.1s;
}
.pair-opt:last-child { border-bottom: none; }
.pair-opt:hover      { background: #1e293b; }
.pair-opt-active     { background: #1e2d45; }
.pair-opt-active .pair-opt-sym { color: #3b82f6; }

.pair-opt-icon { font-size: 1rem; width: 22px; text-align: center; flex-shrink: 0; }
.pair-opt-sym  { font-weight: 700; color: #e2e8f0; font-size: 0.88rem; flex: 1; }
.pair-opt-name { color: #64748b; font-size: 0.76rem; }
.pair-opt-custom .pair-opt-sym { color: #f59e0b; }

/* Highlighted text when filtering */
mark.pair-highlight {
    background: rgba(59,130,246,0.3); color: #93c5fd;
    border-radius: 3px; padding: 0 2px; font-weight: 900;
}

.pair-no-result { padding: 14px 16px; color: #64748b; font-size: 0.85rem; text-align: center; }

/* ======================================================
   CHART CLICK INFO BAR
   ====================================================== */
.chart-click-info {
    display: none; background: rgba(59,130,246,0.14);
    border: 1px solid rgba(59,130,246,0.4); border-radius: 10px;
    padding: 8px 14px; font-size: 0.82rem; color: #93c5fd;
    margin-top: 10px; text-align: center;
}
.chart-click-info.visible { display: block; }

/* ======================================================
   ORDER VALIDATION BOX
   ====================================================== */
.order-validation-box { margin: 8px 0 10px; border-radius: 12px; overflow: hidden; }
.order-validation-box:empty { margin: 0; }
.val-has-error .val-error { background: rgba(239,68,68,0.12); border-left: 3px solid #ef4444; padding: 8px 12px; font-size: 0.82rem; color: #fca5a5; }
.val-has-warn  .val-warn  { background: rgba(59,130,246,0.08); border-left: 3px solid #3b82f6; padding: 6px 12px; font-size: 0.8rem; color: #93c5fd; }

/* ======================================================
   REUSE BUTTON (closed positions)
   ====================================================== */
.pos-card-top { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 6px; }
.reuse-btn {
    background: rgba(59,130,246,0.14); border: 1px solid rgba(59,130,246,0.4);
    color: #93c5fd; border-radius: 20px; padding: 4px 12px;
    font-size: 0.75rem; font-weight: 700; cursor: pointer; white-space: nowrap;
    transition: background 0.15s;
}
.reuse-btn:hover { background: rgba(59,130,246,0.28); }
