/* styles.css VERSION_20251125_2 */

/* Базовые стили */
*,
*::before,
*::after {
    box-sizing: border-box;
}

html,
body {
    margin: 0;
    padding: 0;
    height: 100%;
    font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    background-color: #020617; /* почти чёрный */
    color: #e5e7eb;
}

body {
    line-height: 1.4;
}

/* Общий контейнер */
.layout {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* Верхний статус-бар */
.topbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 20px;
    border-bottom: 1px solid rgba(148, 163, 184, 0.25);
    background: radial-gradient(circle at top left, #1e293b 0, #020617 55%);
}

.topbar-left {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.topbar-title {
    font-size: 18px;
    font-weight: 600;
}

.topbar-subtitle {
    font-size: 12px;
    color: #9ca3af;
}

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

.metric {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.metric-label {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: #9ca3af;
}

.metric-value {
    font-size: 14px;
    font-weight: 500;
}

.logout-link {
    font-size: 13px;
    color: #f97316;
    text-decoration: none;
    padding: 6px 10px;
    border-radius: 999px;
    border: 1px solid rgba(248, 250, 252, 0.2);
    transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}

.logout-link:hover {
    background: rgba(248, 250, 252, 0.08);
    border-color: rgba(248, 250, 252, 0.4);
}

/* Основная сетка: 3 колонки */
.main-grid {
    flex: 1;
    display: grid;
    grid-template-columns: 12rem minmax(0, 1fr) 18rem;
    gap: 12px;
    padding: 12px 16px 16px;
}

/* Левая колонка — тикеры */
.sidebar {
    background: rgba(15, 23, 42, 0.96);
    border-radius: 12px;
    border: 1px solid rgba(148, 163, 184, 0.3);
    padding: 10px;
    display: flex;
    flex-direction: column;
    min-height: 0;
}

.sidebar-header {
    margin-bottom: 8px;
}

.sidebar-header h3 {
    margin: 0;
    font-size: 13px;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: #9ca3af;
}

.tickers-list {
    list-style: none;
    margin: 0;
    padding: 0;
    overflow-y: auto;
    scrollbar-width: thin;
    min-height: 0;
}

.tickers-list::-webkit-scrollbar {
    width: 6px;
}

.tickers-list::-webkit-scrollbar-thumb {
    background: rgba(148, 163, 184, 0.5);
    border-radius: 999px;
}

.ticker-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 6px 8px;
    border-radius: 8px;
    font-size: 13px;
    cursor: pointer;
    margin-bottom: 4px;
    transition: background 0.12s ease, transform 0.08s ease;
}

.ticker-item:last-child {
    margin-bottom: 0;
}

.ticker-item:hover {
    background: rgba(51, 65, 85, 0.9);
    transform: translateY(-1px);
}

.ticker-item.active {
    background: linear-gradient(135deg, #1d4ed8, #22c55e);
}

.ticker-symbol {
    font-weight: 600;
}

.ticker-price {
    font-size: 12px;
    color: #d1d5db;
}

/* Центральная колонка — график */
.chart-panel {
    background: radial-gradient(circle at top, #020617 0, #020617 55%, #000 100%);
    border-radius: 12px;
    border: 1px solid rgba(148, 163, 184, 0.4);
    padding: 12px 12px 10px;
    display: flex;
    flex-direction: column;
    min-height: 0; /* важно */
}

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

.chart-title {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.chart-title-main {
    font-size: 15px;
    font-weight: 600;
}

.chart-title-sub {
    font-size: 12px;
    color: #9ca3af;
}

/* Переключатель таймфрейма */
.timeframe-switcher {
    display: inline-flex;
    background: rgba(15, 23, 42, 0.9);
    border-radius: 999px;
    border: 1px solid rgba(148, 163, 184, 0.5);
    padding: 2px;
    gap: 2px;
}

.tf-btn {
    border: none;
    background: transparent;
    color: #e5e7eb;
    font-size: 11px;
    padding: 4px 8px;
    border-radius: 999px;
    cursor: pointer;
    min-width: 40px;
    text-align: center;
    transition: background 0.12s ease, color 0.12s ease, transform 0.08s ease;
}

.tf-btn:hover {
    background: rgba(30, 64, 175, 0.7);
    transform: translateY(-1px);
}

.tf-btn.active {
    background: linear-gradient(135deg, #1d4ed8, #22c55e);
    color: #f9fafb;
}

/* Обёртка для графика */
.chart-wrapper {
    flex: 1;
    min-height: 380px;            /* КЛЮЧЕВОЕ: даём высоту */
    position: relative;
    padding-top: 4px;
}

/* Canvas графика */
#price-chart {
    width: 100% !important;
    height: 100% !important;      /* КЛЮЧЕВОЕ: canvas растягивается */
    display: block;
}

/* Правая колонка — сигналы */
.signals-panel {
    background: rgba(15, 23, 42, 0.96);
    border-radius: 12px;
    border: 1px solid rgba(148, 163, 184, 0.3);
    padding: 10px;
    display: flex;
    flex-direction: column;
    min-height: 0;
}

.signals-header {
    margin-bottom: 8px;
}

.signals-header h3 {
    margin: 0;
    font-size: 13px;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: #9ca3af;
}

.signals-log {
    flex: 1;
    overflow-y: auto;
    font-size: 13px;
    scrollbar-width: thin;
}

.signals-log::-webkit-scrollbar {
    width: 6px;
}

.signals-log::-webkit-scrollbar-thumb {
    background: rgba(148, 163, 184, 0.5);
    border-radius: 999px;
}

.signals-empty {
    font-size: 13px;
    color: #9ca3af;
    padding: 6px 2px;
}

/* Последние сделки в правой колонке */

.trades-header {
    margin-top: 16px;
    padding: 0 16px;
    border-top: 1px solid rgba(148, 163, 184, 0.3);
}

.trades-header h3 {
    margin: 8px 0;
    font-size: 13px;
    font-weight: 600;
    color: #e5e7eb;
}

.trades-list {
    padding: 8px 16px 16px;
    font-size: 12px;
    color: #e5e7eb;
    max-height: 260px;          /* чтобы не раздувать панель */
    overflow-y: auto;
}

.trade-item {
    padding: 4px 0;
    border-bottom: 1px dashed rgba(148, 163, 184, 0.2);
}

.trade-item:last-child {
    border-bottom: none;
}

.trade-row-main {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
}

.trade-symbol {
    font-weight: 600;
    letter-spacing: 0.03em;
}

.trade-side-buy {
    color: #22c55e;
}

.trade-side-sell {
    color: #f97373;
}

.trade-pnl-pos {
    color: #22c55e;
    font-weight: 500;
}

.trade-pnl-neg {
    color: #f97373;
    font-weight: 500;
}

.trade-meta {
    margin-top: 2px;
    font-size: 11px;
    color: #9ca3af;
}

.position-row {
    padding: 8px 10px;
    border-radius: 8px;
    background: rgba(15, 23, 42, 0.9);
    margin-bottom: 8px;
    font-size: 12px;
}

.position-row-header {
    display: flex;
    justify-content: space-between;
    margin-bottom: 4px;
}

.position-symbol {
    font-weight: 600;
}

.position-side {
    font-weight: 500;
}

.side-long {
    color: #22c55e;
}

.side-short {
    color: #f97316;
}

.position-row-line {
    margin-top: 2px;
}

.pnl-positive {
    color: #22c55e;
}

.pnl-negative {
    color: #ef4444;
}

.pnl-neutral {
    color: #e5e7eb;
}

/* Контейнер графика */
.price-chart {
    width: 100%;
    height: 100%;
}

/* Область графика */
.chart-body {
    position: relative;
    flex: 1 1 auto;
    min-height: 420px;
    border-radius: 16px;
    background: #050911;
    padding: 0;
    overflow: hidden;
}

/* Инфо-бокс по наведению */
.candle-info {
    position: fixed;              /* раньше было absolute */
    z-index: 9999;
    max-height: 85px;
    padding: 6px 10px;
    border-radius: 6px;
    background: rgba(10, 15, 35, 0.95);
    color: #E5E7EB;
    font-size: 11px;
    line-height: 1.4;
    box-shadow: 0 6px 18px rgba(0, 0, 0, 0.45);
    pointer-events: none;
    display: none;                /* включаем из JS */
    border: 1px solid rgba(129, 140, 248, 0.6);
}

/* Блок сигналов */
.signals-block {
    font-size: 12px;
    line-height: 1.5;
    color: #E5E7EB;
}

.signals-title {
    font-weight: 600;
    margin-bottom: 6px;
    color: #E5E7EB;
}

.signals-list {
    margin: 0;
    padding-left: 16px;
}

.signals-list li {
    margin-bottom: 4px;
    color: #9CA3AF;
}

/* Адаптив под узкие экраны (если вдруг зайдёшь с телефона) */
@media (max-width: 960px) {
    .main-grid {
        grid-template-columns: minmax(0, 1fr);
        grid-template-rows: auto auto auto;
    }

    .sidebar,
    .chart-panel,
    .signals-panel {
        min-height: 200px;
    }

    .chart-wrapper {
        min-height: 260px;
    }
}