/* ============================================================
   GLOBAL HACKER TERMINAL THEME – Imran DeepCipher Trade Terminal
   ============================================================ */

/* Import better hacker font */
@import url('https://fonts.googleapis.com/css2?family=Fira+Code:wght@400;500;600;700&display=swap');

body {
    background: radial-gradient(circle at top left, #111827 0, #020617 45%, #000000 100%) !important;
    color: #e5e7eb !important;
    font-family: "Fira Code", Menlo, Monaco, Consolas, "Courier New", monospace;
    overflow-x: hidden;
}

/* Scrollbars */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}
::-webkit-scrollbar-track {
    background: #020617;
}
::-webkit-scrollbar-thumb {
    background: #16a34a;
    border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
    background: #22c55e;
}

/* Center layout on large displays */
.container-fluid {
    max-width: 1800px;
    margin: 0 auto;
    padding-left: 12px;
    padding-right: 12px;
}

/* ============================
   HEADER
   ============================ */

h1 {
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: #22c55e !important;
    text-shadow: 0 0 8px rgba(34, 197, 94, 0.85);
}

#last-update-time {
    font-family: "Fira Code", monospace;
    font-size: 0.8rem;
    color: #9ca3af !important;
}

/* ============================
   KPI CARDS
   ============================ */

.card {
    background: radial-gradient(circle at top left, #020617 0, #030712 50%, #020617 100%);
    border: 1px solid rgba(148, 163, 184, 0.25);
    box-shadow: 0 0 18px rgba(15, 23, 42, 0.9);
    border-radius: 12px;
    transition: transform 0.12s ease-out, box-shadow 0.12s ease-out, border 0.12s ease-out;
}

.card:hover {
    transform: translateY(-2px);
    border-color: rgba(34, 197, 94, 0.8);
    box-shadow: 0 0 26px rgba(34, 197, 94, 0.35);
}

.card-title {
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.12em;
    color: #9ca3af !important;
}

.card-text {
    font-family: "Fira Code", monospace;
    font-weight: 600;
}

/* Main KPI big numbers */
#total-equity-pnl-card,
#realized-pnl-card,
#win-rate-card,
#total-trades-card {
    font-size: 1.6rem;
}

/* ============================
   TABS
   ============================ */

.nav-tabs {
    border-bottom: 1px solid rgba(55, 65, 81, 0.7);
}

.nav-tabs .nav-link {
    color: #9ca3af;
    font-family: "Fira Code", monospace;
    text-transform: uppercase;
    font-size: 0.75rem;
    letter-spacing: 0.12em;
    border: none;
    padding: 0.65rem 1.2rem;
}

.nav-tabs .nav-link:hover {
    color: #e5e7eb;
    border-bottom: 2px solid rgba(148, 163, 184, 0.6);
}

.nav-tabs .nav-link.active {
    color: #22c55e !important;
    background-color: transparent !important;
    border-bottom: 2px solid #22c55e;
}

/* ============================
   PLOTLY GRAPHS
   ============================ */

.js-plotly-plot .plotly,
.js-plotly-plot .main-svg {
    border-radius: 12px !important;
}

/* ============================
   TABLES
   ============================ */

table {
    font-family: "Fira Code", monospace;
    font-size: 0.78rem;
    color: #e5e7eb;
}

.table {
    margin-bottom: 0;
    border-collapse: separate !important;
    border-spacing: 0 4px;
}

.table thead tr {
    background: rgba(15, 23, 42, 0.95);
    text-transform: uppercase;
    letter-spacing: 0.08em;
    font-size: 0.7rem;
}

.table thead th {
    border: none !important;
    color: #9ca3af;
}

.table tbody tr {
    background: rgba(15, 23, 42, 0.8);
    border-radius: 8px;
}

.table tbody tr:hover {
    background: rgba(34, 197, 94, 0.08);
}

.table tbody td {
    border-top: 1px solid rgba(31, 41, 55, 0.8) !important;
}

/* ============================
   ALERTS
   ============================ */

.alert-info {
    background-color: rgba(15, 23, 42, 0.9);
    border-color: rgba(148, 163, 184, 0.4);
    color: #e5e7eb;
    font-family: "Fira Code", monospace;
}

/* ============================
   DROPDOWN
   ============================ */

.Select-control,
.Select-menu-outer {
    background-color: #020617 !important;
    border-color: rgba(148, 163, 184, 0.7) !important;
}

.Select-value-label {
    color: #e5e7eb !important;
    font-family: "Fira Code", monospace;
}

.Select-option {
    background-color: #020617 !important;
    color: #e5e7eb !important;
}

.Select-option.is-focused {
    background-color: rgba(34, 197, 94, 0.2) !important;
}

/* ============================
   HEADERS INSIDE TABS
   ============================ */

h3, h4, h5 {
    color: #e5e7eb;
    text-shadow: 0 0 6px rgba(15, 23, 42, 0.8);
}

h4::before {
    content: "> ";
    color: #22c55e;
    font-family: "Fira Code", monospace;
    font-weight: 700;
}

/* ============================
   CUSTOM LOADING SPINNER
   ============================ */

@keyframes terminal-spin {
    0%   { transform: translate(-50%, -50%) rotate(0deg);   box-shadow: 0 0 8px rgba(34,197,94,0.7); }
    50%  { transform: translate(-50%, -50%) rotate(180deg); box-shadow: 0 0 16px rgba(14,165,233,0.9); }
    100% { transform: translate(-50%, -50%) rotate(360deg); box-shadow: 0 0 8px rgba(168,85,247,0.7); }
}

/* Hide built-in content while loading */
[data-dash-is-loading="true"] {
    position: relative;
    color: transparent !important;
}

/* Show our neon spinner */
[data-dash-is-loading="true"]::after {
    content: "";
    position: absolute;
    top: 50%;
    left: 50%;
    width: 42px;
    height: 42px;
    border-radius: 50%;
    border: 2px solid rgba(31, 41, 55, 0.9);
    border-top: 3px solid #22c55e;
    border-right: 3px solid #0ea5e9;
    border-bottom: 3px solid #a855f7;
    animation: terminal-spin 0.9s linear infinite;
    z-index: 999;
}

/* Hint text under spinner on graphs */
.js-plotly-plot[data-dash-is-loading="true"]::before {
    content: "calculating edge...";
    position: absolute;
    top: calc(50% + 34px);
    left: 50%;
    transform: translateX(-50%);
    font-size: 0.7rem;
    color: #9ca3af;
    font-family: "Fira Code", monospace;
}

/* ============================
   FULL-SCREEN HTML SPLASH (splash-overlay)
   ============================ */

.terminal-splash-overlay {
    position: fixed;
    inset: 0;
    z-index: 9999;
    background: radial-gradient(circle at top left, #020617 0, #000000 55%, #020617 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
}

.terminal-splash-text {
    max-width: 1100px;
    width: 100%;
    max-height: 90vh;
    overflow-y: auto;
    background: rgba(0, 0, 0, 0.92);
    border: 1px solid rgba(34, 197, 94, 0.6);
    box-shadow: 0 0 24px rgba(34, 197, 94, 0.35);
    border-radius: 10px;
    padding: 16px 20px;
    color: #22c55e;
    font-family: "Fira Code", Menlo, Monaco, Consolas, "Courier New", monospace;
    font-size: 0.78rem;
    line-height: 1.35;
    text-shadow: 0 0 6px rgba(22, 163, 74, 0.7);
    white-space: pre-wrap;
}

/* small fade-in */
.terminal-splash-overlay {
    animation: splash-fade-in 0.3s ease-out;
}

@keyframes splash-fade-in {
    from { opacity: 0; transform: scale(0.98); }
    to   { opacity: 1; transform: scale(1); }
}

/* ============================================================
   RESPONSIVE DESIGN
   ============================================================ */

/* ===== 4K Ultra-wide (>= 2560px) ===== */
@media screen and (min-width: 2560px) {
    body { font-size: 18px; }
    h1 { font-size: 2.8rem; }
    h3 { font-size: 1.6rem; }
    h4 { font-size: 1.3rem; }

    .card-body { padding: 1.6rem 1.8rem; }
    .card-title { font-size: 0.9rem; }
    .card-text { font-size: 1.8rem; }

    #total-equity-pnl-card,
    #realized-pnl-card,
    #win-rate-card,
    #total-trades-card {
        font-size: 2rem;
    }

    #cumulative-pnl-chart,
    #daily-pnl-chart,
    #main-price-chart,
    #macd-chart,
    #rsi-chart {
        height: 520px !important;
    }

    #main-price-chart {
        height: 720px !important;
    }

    table { font-size: 0.9rem; }
}

/* ===== Standard Desktop (1080p–1440p) ===== */
@media screen and (min-width: 1400px) and (max-width: 2559px) {
    body { font-size: 16px; }
    h1 { font-size: 2.2rem; }
    h4 { font-size: 1.1rem; }

    .card-body { padding: 1.2rem 1.4rem; }
    .card-text { font-size: 1.4rem; }

    #cumulative-pnl-chart,
    #daily-pnl-chart {
        height: 420px !important;
    }

    #main-price-chart {
        height: 620px !important;
    }

    #macd-chart,
    #rsi-chart {
        height: 260px !important;
    }
}

/* ===== Mobile / Tablet (<= 768px) ===== */
@media screen and (max-width: 768px) {
    body {
        font-size: 13px;
        padding: 0;
    }

    .container-fluid {
        padding-left: 6px;
        padding-right: 6px;
    }

    h1 {
        font-size: 1.4rem;
        text-align: center;
        line-height: 1.3;
    }

    #last-update-time {
        text-align: center !important;
        margin-top: 4px;
        font-size: 0.7rem;
    }

    .row > [class*="col-"] {
        margin-bottom: 0.6rem;
    }

    .card-body {
        padding: 0.8rem 0.9rem;
    }

    .card-title {
        font-size: 0.65rem;
    }

    .card-text {
        font-size: 1.1rem;
    }

    .nav-tabs .nav-link {
        padding: 0.45rem 0.6rem;
        font-size: 0.65rem;
        letter-spacing: 0.08em;
    }

    #cumulative-pnl-chart,
    #daily-pnl-chart {
        height: 280px !important;
    }

    #main-price-chart {
        height: 420px !important;
    }

    #macd-chart,
    #rsi-chart {
        height: 220px !important;
    }

    /* Scrollable tables */
    #trade-history-table,
    #live-positions-table,
    #ai-decisions-table,
    #ml-signals-table {
        overflow-x: auto;
        display: block;
    }

    table {
        font-size: 0.7rem;
        min-width: 600px;
    }

    .my-4 {
        margin-top: 1rem !important;
        margin-bottom: 1rem !important;
    }

    .mb-4 {
        margin-bottom: 1rem !important;
    }

    .mb-3 {
        margin-bottom: 0.8rem !important;
    }
}
