/* Banken-Stil Dark Mode Finanze-Dashboard */
:root {
    --bg-color: #0c1421;
    --panel-bg: #152238;
    --text-main: #f0f2f5;
    --text-muted: #8b9bb4;
    --border-color: #2a3b5c;
    --accent-blue: #2962ff;
    --accent-hover: #1e45b5;
    --green-profit: #00c853;
    --red-loss: #d50000;
    --yellow-warn: #ffd600;
    --white: #ffffff;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

body {
    background-color: var(--bg-color);
    color: var(--text-main);
    overflow-x: hidden;
}

/* Layering für UIManager */
/* ------------------------------------------------------------------
 * 🛑 WINDOW ARCHITECTURE & Z-INDEX LOCK 🛑
 * 1. The base Dashboard (.ui-window#main_dash) runs at z-index 1.
 * 2. TradingView Charts (.chart-container) are restricted to z-index 1.
 * 3. All active Modals / Popups (UIManager creates them) MUST use z-index 9999.
 * ------------------------------------------------------------------ */

#window-layer {
    position: absolute;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    pointer-events: none;
    /* Let clicks pass through empty space */
    z-index: 9998;
    /* Base layer for Windows, just below the active ones */
}

#hud-layer {
    position: absolute;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    pointer-events: none;
    z-index: 9000;
}

/* Panels (Erstellt durch UIManager) */
.ui-window {
    position: absolute;
    background-color: var(--panel-bg);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
    pointer-events: auto;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    z-index: 9999;
    /* STRIKT: Immer über den LightweightCharts */
}

/* Ensure the background dashboard frame stays below popups */
#main_dash {
    z-index: 1 !important;
}

.ui-window-header {
    background-color: rgba(255, 255, 255, 0.05);
    padding: 12px 16px;
    border-bottom: 1px solid var(--border-color);
    font-weight: 600;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.ui-window-body {
    padding: 16px;
    flex-grow: 1;
    overflow-y: auto;
}

/* Smart Buttons */
.smart-button {
    background-color: var(--accent-blue);
    color: var(--white);
    border: none;
    padding: 8px 16px;
    border-radius: 4px;
    cursor: pointer;
    font-weight: 500;
    transition: background-color 0.2s, transform 0.1s;
    pointer-events: auto;
}

.smart-button:hover {
    background-color: var(--accent-hover);
}

.smart-button:active {
    transform: scale(0.98);
}

/* Auth View / Login (Wird als UI Window gerendert) */
.login-form {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.login-form input {
    background-color: var(--bg-color);
    border: 1px solid var(--border-color);
    color: var(--text-main);
    padding: 10px;
    border-radius: 4px;
}

.login-form input:focus {
    outline: none;
    border-color: var(--accent-blue);
}

/* Dashboard Grid */
.dashboard-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(380px, 1fr));
    gap: 20px;
    width: 100%;
    height: 100%;
}

/* Agent Card */
.agent-card {
    background: var(--panel-bg);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.agent-header {
    display: flex;
    justify-content: space-between;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 8px;
}

.agent-name {
    font-size: 1.2rem;
    font-weight: bold;
    color: var(--white);
}

.agent-budget {
    font-size: 1.2rem;
    color: var(--green-profit);
    /* Ggf. via JS faerben */
}

/* Trade Status Indicators */
.trade-status {
    display: flex;
    gap: 8px;
    font-size: 0.9rem;
}

.trade-pill {
    padding: 4px 8px;
    border-radius: 4px;
    background: rgba(255, 255, 255, 0.1);
}

.trade-pill.profit {
    color: var(--green-profit);
    border: 1px solid var(--green-profit);
}

.trade-pill.loss {
    color: var(--red-loss);
    border: 1px solid var(--red-loss);
}

.trade-pill.open {
    color: var(--yellow-warn);
    border: 1px solid var(--yellow-warn);
}

.chart-container {
    width: 100%;
    height: 200px;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    overflow: hidden;
    position: relative;
    z-index: 1;
    /* Keep canvas constrained to the background */
}

.justification-box {
    background-color: var(--bg-color);
    border-left: 3px solid var(--accent-blue);
    padding: 8px 12px;
    font-size: 0.85rem;
    color: var(--text-muted);
    font-style: italic;
    max-height: 80px;
    overflow-y: auto;
}

/* Header Navbar via UIManager */
.navbar {
    display: flex;
    gap: 15px;
    align-items: center;
}