/* ============================================================
   Broker Tracker – CSS
   Estetyka: financial dark / industrial-refined
   + jasny motyw przez [data-theme="light"]
   ============================================================ */

:root {
    /* ── Motyw ciemny (domyślny) ── */
    --bg-base:       #0d1117;
    --bg-surface:    #161b22;
    --bg-card:       #1c2128;
    --bg-input:      #21262d;
    --border:        #30363d;
    --border-light:  #21262d;

    --text-primary:  #e6edf3;
    --text-muted:    #7d8590;
    --text-dim:      #484f58;

    --accent:        #00d4aa;
    --accent-dim:    rgba(0, 212, 170, 0.12);
    --accent-glow:   rgba(0, 212, 170, 0.3);

    --green:         #2dc653;
    --green-dim:     rgba(45, 198, 83, 0.12);
    --red:           #f85149;
    --red-dim:       rgba(248, 81, 73, 0.12);
    --yellow:        #d29922;
    --blue:          #58a6ff;

    --sidebar-w:     240px;
    --topbar-h:      56px;
    --radius:        8px;
    --radius-lg:     12px;

    --font-main:     'Syne', sans-serif;
    --font-mono:     'DM Mono', monospace;

    /* Cień dla kart (ciemny) */
    --card-shadow:   none;
}

/* ── Motyw jasny ── */
[data-theme="light"] {
    --bg-base:       #f4f6f9;
    --bg-surface:    #ffffff;
    --bg-card:       #ffffff;
    --bg-input:      #f0f2f5;
    --border:        #dde1e7;
    --border-light:  #eaecf0;

    --text-primary:  #1a1f2e;
    --text-muted:    #6b7280;
    --text-dim:      #9ca3af;

    --accent:        #009a7a;
    --accent-dim:    rgba(0, 154, 122, 0.10);
    --accent-glow:   rgba(0, 154, 122, 0.25);

    --green:         #16a34a;
    --green-dim:     rgba(22, 163, 74, 0.10);
    --red:           #dc2626;
    --red-dim:       rgba(220, 38, 38, 0.10);
    --yellow:        #b45309;
    --blue:          #2563eb;

    --card-shadow:   0 1px 4px rgba(0,0,0,0.07);
}

/* Płynne przejście między motywami */
*, *::before, *::after {
    transition: background-color 0.2s ease, border-color 0.2s ease, color 0.15s ease;
}

/* Wyłącz tranzycję dla elementów gdzie szkodzi (animacje chart.js itp.) */
canvas, .chart-container * { transition: none !important; }

/* ── Reset & Base ── */
*, *::before, *::after { box-sizing: border-box; }

body {
    font-family: var(--font-main);
    background: var(--bg-base);
    color: var(--text-primary);
    margin: 0;
    font-size: 14px;
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
}

/* ── Layout ── */
.app-wrapper {
    display: flex;
    min-height: 100vh;
}

/* ── Sidebar ── */
.sidebar {
    width: var(--sidebar-w);
    min-height: 100vh;
    background: var(--bg-surface);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0; left: 0;
    z-index: 1000;
    transition: transform 0.25s ease;
}

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 20px 20px 16px;
    border-bottom: 1px solid var(--border);
    font-weight: 800;
    font-size: 16px;
    letter-spacing: -0.3px;
    color: var(--text-primary);
}

.brand-icon {
    width: 32px; height: 32px;
    background: var(--accent);
    color: var(--bg-base);
    border-radius: 8px;
    display: flex; align-items: center; justify-content: center;
    font-size: 16px;
    flex-shrink: 0;
}

.sidebar-nav {
    list-style: none;
    padding: 12px 10px;
    margin: 0;
    flex: 1;
}

.nav-item { margin: 2px 0; }

.nav-divider {
    height: 1px;
    background: var(--border);
    margin: 10px 0;
}

.sidebar .nav-link {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 12px;
    border-radius: var(--radius);
    color: var(--text-muted);
    text-decoration: none;
    font-weight: 600;
    font-size: 13.5px;
    transition: all 0.15s ease;
}

.sidebar .nav-link:hover {
    background: var(--bg-card);
    color: var(--text-primary);
}

.sidebar .nav-link.active {
    background: var(--accent-dim);
    color: var(--accent);
    border: 1px solid var(--accent-glow);
}

.sidebar .nav-link i {
    font-size: 16px;
    width: 18px;
    text-align: center;
}

.sidebar-footer {
    padding: 12px 10px 20px;
    border-top: 1px solid var(--border);
}

.logout-link {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 12px;
    border-radius: var(--radius);
    color: var(--text-muted);
    text-decoration: none;
    font-weight: 600;
    font-size: 13.5px;
    transition: all 0.15s ease;
}

.logout-link:hover {
    background: var(--red-dim);
    color: var(--red);
}

/* ── Main Content ── */
.main-content {
    flex: 1;
    margin-left: var(--sidebar-w);
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

/* ── Topbar ── */
.topbar {
    height: var(--topbar-h);
    background: var(--bg-surface);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    padding: 0 24px;
    gap: 16px;
    position: sticky;
    top: 0;
    z-index: 100;
}

.sidebar-toggle {
    display: none;
    background: none;
    border: 1px solid var(--border);
    color: var(--text-muted);
    border-radius: var(--radius);
    padding: 6px 10px;
    cursor: pointer;
    font-size: 18px;
}

.topbar-title {
    font-size: 15px;
    font-weight: 700;
    color: var(--text-primary);
    flex: 1;
}

.topbar-right {
    display: flex; align-items: center; gap: 16px;
}

.topbar-date {
    font-family: var(--font-mono);
    font-size: 12px;
    color: var(--text-muted);
}

/* ── Przełącznik motywu ── */
.theme-toggle {
    width: 34px;
    height: 34px;
    border-radius: var(--radius);
    background: var(--bg-input);
    border: 1px solid var(--border);
    color: var(--text-muted);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 15px;
    flex-shrink: 0;
    transition: background 0.15s, color 0.15s, border-color 0.15s;
}

.theme-toggle:hover {
    background: var(--accent-dim);
    color: var(--accent);
    border-color: var(--accent-glow);
}

[data-theme="light"] .theme-toggle .bi-sun-fill { display: none; }
[data-theme="dark"]  .theme-toggle .bi-moon-fill { display: none; }

/* ── Page Content ── */
.page-content {
    padding: 24px;
    flex: 1;
}

/* ── Cards ── */
.card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--card-shadow);
}

.card-header {
    background: transparent;
    border-bottom: 1px solid var(--border);
    padding: 16px 20px;
    display: flex;
    align-items: center;
    gap: 10px;
    font-weight: 700;
    font-size: 14px;
    color: var(--text-primary);
}

.card-body { padding: 20px; }

/* ── Stat Cards ── */
.stat-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 20px;
    position: relative;
    overflow: hidden;
    transition: border-color 0.2s;
}

.stat-card:hover { border-color: var(--border-light); }

.stat-card.accent   { border-left: 3px solid var(--accent); }
.stat-card.green    { border-left: 3px solid var(--green); }
.stat-card.red      { border-left: 3px solid var(--red); }
.stat-card.blue     { border-left: 3px solid var(--blue); }

.stat-label {
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.8px;
    text-transform: uppercase;
    color: var(--text-muted);
    margin-bottom: 8px;
}

.stat-value {
    font-family: var(--font-mono);
    font-size: 24px;
    font-weight: 500;
    color: var(--text-primary);
    line-height: 1;
}

.stat-value.positive { color: var(--green); }
.stat-value.negative { color: var(--red); }

.stat-sub {
    font-size: 12px;
    color: var(--text-muted);
    margin-top: 6px;
}

.stat-icon {
    position: absolute;
    top: 16px; right: 16px;
    font-size: 28px;
    opacity: 0.08;
}

/* ── Tables ── */
.table {
    color: var(--text-primary);
    margin: 0;
}

.table thead th {
    background: var(--bg-surface);
    border-bottom: 1px solid var(--border);
    color: var(--text-muted);
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.8px;
    text-transform: uppercase;
    padding: 12px 16px;
    white-space: nowrap;
}

.table tbody td {
    border-bottom: 1px solid var(--border-light);
    padding: 11px 16px;
    vertical-align: middle;
    font-size: 13.5px;
}

.table tbody tr:hover td {
    background: var(--accent-dim);
}

.table tbody tr:last-child td { border-bottom: none; }

.font-mono {
    font-family: var(--font-mono);
}

/* ── Badges & Tags ── */
.badge-type {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 3px 10px;
    border-radius: 20px;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.3px;
}

.badge-odczyt  { background: rgba(88,166,255,0.12); color: var(--blue); }
.badge-wplata  { background: var(--green-dim); color: var(--green); }
.badge-wyplata { background: var(--red-dim);   color: var(--red); }

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

.broker-dot {
    width: 8px; height: 8px;
    border-radius: 50%;
    display: inline-block;
    flex-shrink: 0;
}

/* ── Forms ── */
.form-control, .form-select {
    background: var(--bg-input);
    border: 1px solid var(--border);
    color: var(--text-primary);
    border-radius: var(--radius);
    padding: 9px 14px;
    font-family: var(--font-main);
    font-size: 14px;
    transition: border-color 0.15s, box-shadow 0.15s;
}

.form-control:focus, .form-select:focus {
    background: var(--bg-input);
    border-color: var(--accent);
    color: var(--text-primary);
    box-shadow: 0 0 0 3px var(--accent-glow);
    outline: none;
}

.form-control::placeholder { color: var(--text-dim); }

.form-select option { background: var(--bg-card); }

.form-label {
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 0.5px;
    text-transform: uppercase;
    color: var(--text-muted);
    margin-bottom: 6px;
}

/* ── Buttons ── */
.btn {
    font-family: var(--font-main);
    font-weight: 700;
    border-radius: var(--radius);
    font-size: 13.5px;
    padding: 8px 18px;
    transition: all 0.15s ease;
    display: inline-flex;
    align-items: center;
    gap: 7px;
    border: none;
    cursor: pointer;
}

.btn-primary {
    background: var(--accent);
    color: var(--bg-base);
}
.btn-primary:hover {
    background: #00e8bb;
    color: var(--bg-base);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px var(--accent-glow);
}

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

.btn-danger {
    background: var(--red-dim);
    color: var(--red);
    border: 1px solid rgba(248,81,73,0.3);
}
.btn-danger:hover {
    background: var(--red);
    color: #fff;
}

.btn-sm { padding: 5px 12px; font-size: 12px; }
.btn-icon {
    padding: 6px 8px;
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text-muted);
    border-radius: var(--radius);
}
.btn-icon:hover { color: var(--text-primary); background: var(--bg-card); }

/* ── Login page ── */
.login-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-base);
    position: relative;
    overflow: hidden;
}

.login-page::before {
    content: '';
    position: absolute;
    width: 600px; height: 600px;
    background: radial-gradient(circle, rgba(0,212,170,0.06) 0%, transparent 70%);
    top: -200px; left: -200px;
}

.login-card {
    width: 100%;
    max-width: 380px;
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 40px;
    position: relative;
    z-index: 1;
}

.login-logo {
    text-align: center;
    margin-bottom: 32px;
}

.login-logo .icon {
    width: 52px; height: 52px;
    background: var(--accent);
    color: var(--bg-base);
    border-radius: 14px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    margin-bottom: 14px;
}

.login-logo h1 {
    font-size: 22px;
    font-weight: 800;
    margin: 0;
    letter-spacing: -0.5px;
}

.login-logo p {
    color: var(--text-muted);
    font-size: 13px;
    margin: 4px 0 0;
}

/* ── Alerts / Flash ── */
.flash-alert {
    border-radius: var(--radius);
    border: none;
    font-size: 14px;
    margin-bottom: 20px;
}

.alert-success {
    background: var(--green-dim);
    color: var(--green);
}

.alert-danger {
    background: var(--red-dim);
    color: var(--red);
}

/* ── Summary table extras ── */
.currency-group-header td {
    background: var(--bg-surface) !important;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.8px;
    text-transform: uppercase;
    color: var(--text-muted);
    padding: 8px 16px !important;
    border-top: 2px solid var(--border) !important;
}

.summary-total td {
    background: var(--accent-dim) !important;
    font-weight: 700;
    color: var(--accent) !important;
    border-top: 2px solid var(--accent) !important;
    font-family: var(--font-mono);
}

/* ── Chart container ── */
.chart-container {
    position: relative;
    height: 400px;
    width: 100%;
}

/* ── Pagination / empty state ── */
.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: var(--text-muted);
}

.empty-state i { font-size: 48px; opacity: 0.3; margin-bottom: 16px; }
.empty-state h5 { font-weight: 700; color: var(--text-primary); }
.empty-state p  { font-size: 13px; }

/* ── Responsive ── */
@media (max-width: 768px) {
    .sidebar {
        transform: translateX(-100%);
    }
    .sidebar.open {
        transform: translateX(0);
    }
    .main-content {
        margin-left: 0;
    }
    .sidebar-toggle {
        display: flex;
        align-items: center;
    }
    .page-content {
        padding: 16px;
    }
    .stat-value { font-size: 20px; }
    .table-responsive { font-size: 13px; }

    /* Overlay */
    .sidebar-overlay {
        display: none;
        position: fixed;
        inset: 0;
        background: rgba(0,0,0,0.5);
        z-index: 999;
    }
    .sidebar-overlay.show { display: block; }
}
