/*
  shotdetectgraph/static/shotdetectgraph/css/graph.css
  
  Стили для графика ShotDetect на uPlot.
*/

:root {
    --graph-bg: #0b0c0f;
    --graph-bg2: #0e0f13;
    --graph-panel: #121318;
    --graph-border: rgba(255, 255, 255, 0.08);
    --graph-border2: rgba(255, 255, 255, 0.06);
    --graph-text: rgba(255, 255, 255, 0.92);
    --graph-muted: rgba(255, 255, 255, 0.60);
    --graph-up: #22c55e;
    --graph-down: #ef4444;
    --graph-radius: 12px;
    --graph-shadow: 0 18px 50px rgba(0, 0, 0, 0.55);
    /* Основной шрифт */
    --graph-sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    /* Шрифт для осей графика (используется и в JS) */
    --graph-axis-font: 400 12px system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

/* ============================================================================
   Контентная область
   ============================================================================ */

.app__content {
    background:
        radial-gradient(900px 520px at 10% 5%, rgba(34, 197, 94, 0.08), transparent 60%),
        radial-gradient(900px 520px at 90% 10%, rgba(239, 68, 68, 0.06), transparent 60%),
        linear-gradient(180deg, var(--graph-bg2), var(--graph-bg));
    overflow: hidden;
}

/* ============================================================================
   Верхняя панель
   ============================================================================ */

.graph-topbar {
    flex-shrink: 0;
    z-index: 10;
    display: flex;
    align-items: stretch;
    justify-content: space-between;
    gap: 12px;
    padding: 6px 14px;
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.05), rgba(255, 255, 255, 0.02));
    border-bottom: 1px solid var(--graph-border);
    backdrop-filter: blur(6px);
    min-height: 53px;
}

.graph-topbar__left {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
}

.graph-topbar__right {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    justify-content: flex-end;
    gap: 2px;
    flex: 1;
    min-width: 0;
}

/* ============================================================================
   Мета информация о сегменте
   ============================================================================ */

.graph-meta {
    font-size: 14px;
    color: var(--graph-muted);
    font-family: var(--graph-sans);
    display: flex;
    flex-wrap: wrap;
    gap: 4px 12px;
    justify-content: flex-start;
    align-items: center;
    line-height: 1.4;
}

.graph-meta-item {
    display: inline-flex;
    align-items: center;
    gap: 3px;
    white-space: nowrap;
}

.graph-meta-strong {
    color: var(--graph-text);
    font-weight: 600;
}

.graph-meta-up {
    color: var(--graph-up);
}

.graph-meta-down {
    color: var(--graph-down);
}

.graph-meta-muted {
    color: var(--graph-muted);
    opacity: 0.7;
}

.graph-meta-value {
    color: var(--graph-text);
}

/* Иконка триггера (галочка/крестик) перед символом */
.graph-meta-trig {
    margin-right: 6px;
}

.graph-meta-trig-icon {
    font-size: 1.1em;
}

/* ============================================================================
   Метрики
   ============================================================================ */

.graph-metrics {
    display: flex;
    align-items: center;
    gap: 12px;
}

.graph-metric {
    font-size: 13px;
    color: var(--graph-muted);
    font-family: var(--graph-sans);
}

.graph-metric.error {
    color: var(--graph-down);
}

/* ============================================================================
   Блок ошибки
   ============================================================================ */

.graph-error {
    margin: 10px 14px;
    padding: 10px 14px;
    border-radius: var(--graph-radius);
    background: rgba(239, 68, 68, 0.12);
    border: 1px solid rgba(239, 68, 68, 0.35);
    color: var(--graph-text);
    font-size: 13px;
    flex-shrink: 0;
}

/* ============================================================================
   Контейнер графиков
   ============================================================================ */

.graph-charts {
    position: relative;
    display: flex;
    flex-direction: column;
    flex: 1;
    min-height: 0;
    margin: 0;
    padding: 0;
    background: var(--graph-bg);
    overflow: hidden;
}

/* Отдельный график */
.graph-chart {
    position: relative;
    flex-shrink: 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.15);
    overflow: hidden;
}

.graph-chart:last-child {
    border-bottom: none;
}

/* Высоты графиков: 50%, 16%, 34% */
.graph-chart--price {
    flex: 50 0 0;
}

.graph-chart--volume {
    flex: 16 0 0;
}

.graph-chart--ticks {
    flex: 34 0 0;
}

/* Панель контролов на верхнем графике */
.graph-chart-controls {
    position: absolute;
    top: 6px;
    right: 6px;
    z-index: 100;
    display: flex;
    align-items: center;
    gap: 8px;
}

/* ============================================================================
   Масштаб (Scale)
   ============================================================================ */

.graph-scale-container {
    position: relative;
    display: flex;
    align-items: center;
}

.graph-scale-value {
    height: 28px;
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 12px;
    font-family: var(--graph-sans);
    color: var(--graph-muted);
    background: rgba(0, 0, 0, 0.6);
    padding: 0 10px;
    border-radius: 4px;
    border: 1px solid var(--graph-border);
    cursor: default;
    white-space: nowrap;
    backdrop-filter: blur(4px);
}

.graph-scale-label {
    color: var(--graph-muted);
}

.graph-scale-up {
    color: var(--graph-up);
}

.graph-scale-down {
    color: var(--graph-down);
}

.graph-scale-separator {
    color: var(--graph-muted);
    opacity: 0.6;
}

/* ============================================================================
   Тултип масштаба
   ============================================================================ */

.graph-scale-tooltip {
    position: absolute;
    top: 100%;
    right: 0;
    margin-top: 8px;
    min-width: 260px;
    max-width: 320px;
    padding: 12px 14px;
    background: rgba(18, 19, 24, 0.97);
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 8px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5);
    font-family: var(--graph-sans);
    font-size: 12px;
    color: var(--graph-text);
    opacity: 0;
    visibility: hidden;
    transform: translateY(-4px);
    transition: opacity 0.15s ease, transform 0.15s ease, visibility 0.15s;
    z-index: 200;
    pointer-events: none;
}

.graph-scale-container:hover .graph-scale-tooltip {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
    pointer-events: auto;
}

.graph-scale-tooltip-section {
    margin-bottom: 4px;
}

.graph-scale-tooltip-title {
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--graph-muted);
    margin-bottom: 6px;
}

.graph-scale-tooltip-row {
    display: flex;
    justify-content: space-between;
    margin-bottom: 4px;
}

.graph-scale-tooltip-row:last-child {
    margin-bottom: 0;
}

.graph-scale-tooltip-label {
    color: var(--graph-muted);
}

.graph-scale-tooltip-value {
    color: var(--graph-text);
    font-weight: 500;
}

.graph-scale-tooltip-divider {
    height: 1px;
    background: rgba(255, 255, 255, 0.08);
    margin: 10px 0;
}

.graph-scale-tooltip-desc {
    font-size: 11px;
    color: var(--graph-muted);
    line-height: 1.5;
    margin-top: 10px;
    padding-top: 10px;
    border-top: 1px solid rgba(255, 255, 255, 0.06);
}

/* ============================================================================
   Тултипы кнопок управления
   ============================================================================ */

.graph-btn-container {
    position: relative;
    display: flex;
    align-items: center;
}

.graph-btn-tooltip {
    position: absolute;
    top: 100%;
    left: 50%;
    transform: translateX(-50%) translateY(-4px);
    margin-top: 8px;
    min-width: 200px;
    max-width: 260px;
    padding: 10px 12px;
    background: rgba(18, 19, 24, 0.97);
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 8px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5);
    font-family: var(--graph-sans);
    font-size: 12px;
    color: var(--graph-text);
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.15s ease, transform 0.15s ease, visibility 0.15s;
    z-index: 200;
    pointer-events: none;
    white-space: normal;
}

.graph-btn-container:hover .graph-btn-tooltip {
    opacity: 1;
    visibility: visible;
    transform: translateX(-50%) translateY(0);
    pointer-events: auto;
}

.graph-btn-tooltip-title {
    font-size: 12px;
    font-weight: 600;
    color: var(--graph-text);
    margin-bottom: 6px;
}

.graph-btn-tooltip-desc {
    font-size: 11px;
    color: var(--graph-muted);
    line-height: 1.5;
    margin-bottom: 8px;
}

.graph-btn-tooltip-hotkey {
    font-size: 11px;
    color: var(--graph-muted);
    padding-top: 8px;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
}

.graph-btn-tooltip-hotkey kbd {
    display: inline-block;
    padding: 2px 6px;
    font-family: var(--graph-sans);
    font-size: 10px;
    font-weight: 500;
    color: var(--graph-text);
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 4px;
}

/* ============================================================================
   Кнопки управления
   ============================================================================ */

.graph-reset-btn {
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1px solid var(--graph-border);
    border-radius: 4px;
    background: rgba(255, 255, 255, 0.06);
    color: var(--graph-muted);
    cursor: pointer;
    transition: all 0.15s ease;
    backdrop-filter: blur(4px);
}

.graph-reset-btn:hover {
    background: rgba(255, 255, 255, 0.12);
    color: var(--graph-text);
    border-color: rgba(255, 255, 255, 0.15);
}

.graph-reset-btn.active {
    background: rgba(34, 197, 94, 0.2);
    color: #22c55e;
    border-color: rgba(34, 197, 94, 0.3);
}

/* Кнопка линейки в активном состоянии (indigo) */
.graph-ruler-btn.active {
    background: linear-gradient(135deg, rgba(99, 102, 241, 0.25), rgba(99, 102, 241, 0.10));
    border-color: rgba(99, 102, 241, 0.5);
    color: #6366f1;
}

/* Кнопка сегмента в активном состоянии (amber) */
.graph-segment-btn.active {
    background: linear-gradient(135deg, rgba(251, 191, 36, 0.25), rgba(251, 191, 36, 0.10));
    border-color: rgba(251, 191, 36, 0.5);
    color: #fbbf24;
}

/* Кнопка переключения графиков в активном состоянии (red) */
.graph-toggle-btn.active {
    background: linear-gradient(135deg, rgba(239, 68, 68, 0.25), rgba(239, 68, 68, 0.10));
    border-color: rgba(239, 68, 68, 0.5);
    color: #ef4444;
}

/* ============================================================================
   Скрытие графиков объёма и трейдов
   ============================================================================ */

.graph-chart--volume.hidden,
.graph-chart--ticks.hidden {
    display: none;
    border: none;
}

/* Растягивание верхнего графика когда нижние скрыты */
.graph-charts.has-hidden-charts .graph-chart--price {
    flex: 1 1 100%;
    border-bottom: none;
}

/* ============================================================================
   uPlot переопределения
   ============================================================================ */

.graph-chart .uplot {
    width: 100% !important;
    height: 100% !important;
}

.graph-chart .u-wrap {
    background: transparent !important;
}

.graph-chart .u-axis {
    font-family: var(--graph-sans) !important;
    font-size: 10px !important;
}

.graph-chart .u-grid {
    stroke: rgba(255, 255, 255, 0.06) !important;
}

.graph-chart .u-values {
    color: var(--graph-muted) !important;
}

/* ============================================================================
   Crosshair стили
   ============================================================================ */

.u-cursor-x {
    border-left: 0.5px dashed rgba(255, 255, 255, 0.5) !important;
    border-right: none !important;
    width: 0 !important;
}

.u-cursor-y {
    border-top: 0.5px dashed rgba(255, 255, 255, 0.5) !important;
    border-bottom: none !important;
    height: 0 !important;
}

/* Скрываем горизонтальную линию на неактивных графиках */
.uplot:not(:hover) .u-cursor-y {
    display: none !important;
}

.u-cursor-pt {
    display: block !important;
}

/* ============================================================================
   Axis Labels стили
   ============================================================================ */

.u-axis-label {
    position: absolute;
    background: #1f2937;
    color: #f3f4f6;
    padding: 2px 6px;
    border-radius: 4px;
    font: var(--graph-axis-font);
    pointer-events: none;
    z-index: 100;
    white-space: nowrap;
    border: 1px solid rgba(255, 255, 255, 0.15);
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
    line-height: 1.2;
}

.u-axis-label-x {
    transform: translate(-50%, 0);
    margin-top: 2px;
}

.u-axis-label-y {
    transform: translate(0, -50%);
    margin-left: 2px;
}

/* ============================================================================
   Мобильная адаптация
   ============================================================================ */

@media (max-width: 768px) {
    .graph-topbar {
        flex-direction: column;
        align-items: flex-start;
        gap: 6px;
        padding: 6px 10px;
    }

    .graph-topbar__right {
        align-items: flex-start;
        width: 100%;
    }

    .graph-meta {
        font-size: 12px;
    }

    .graph-metrics {
        flex-wrap: wrap;
        gap: 8px;
    }

    .graph-reset-btn {
        width: 32px;
        height: 32px;
    }
}

@media (max-width: 480px) {
    .graph-metric {
        font-size: 11px;
    }

    .graph-meta {
        font-size: 11px;
    }
}

/* ============================================================================
   Loading Overlay
   ============================================================================ */

.graph-loading-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 1000;
    background: rgba(11, 12, 15, 0.65);
    backdrop-filter: blur(8px);
    display: none;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.graph-loading-overlay.active {
    opacity: 1;
}

.graph-loader-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
    padding: 32px;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 16px;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.5);
    min-width: 280px;
}

.graph-loader-spinner {
    width: 40px;
    height: 40px;
    border: 3px solid rgba(34, 197, 94, 0.15);
    border-top-color: #22c55e;
    border-radius: 50%;
    animation: graph-spin 1s linear infinite;
}

@keyframes graph-spin {
    to {
        transform: rotate(360deg);
    }
}

.graph-loader-status {
    font-size: 14px;
    color: var(--graph-text);
    font-weight: 500;
    letter-spacing: 0.3px;
    text-align: center;
}

.graph-loader-progress {
    width: 100%;
    height: 4px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 2px;
    overflow: hidden;
    position: relative;
}

.graph-loader-progress-bar {
    height: 100%;
    background: #22c55e;
    width: 0%;
    transition: width 0.1s linear;
    box-shadow: 0 0 10px rgba(34, 197, 94, 0.5);
}

.graph-loader-progress-value {
    font-size: 11px;
    color: var(--graph-muted);
    font-family: var(--graph-sans);
    margin-top: -8px;
}

/* ============================================================================
   Скриншот Button & Modal
   ============================================================================ */

/* Кнопка скриншота при наведении/активности */
.graph-screenshot-btn:hover {
    background: rgba(255, 255, 255, 0.12);
    color: var(--graph-text);
}

.graph-screenshot-btn.active {
    background: rgba(255, 255, 255, 0.2);
    color: #ffffff;
    border-color: rgba(255, 255, 255, 0.3);
}

/* Модальное окно (Overlay) */
.graph-modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.75);
    backdrop-filter: blur(5px);
    z-index: 2000;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 1;
    /* Если нужна анимация, можно добавить transition */
}

.graph-modal-content {
    background: #18191d;
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 12px;
    padding: 24px;
    width: 90%;
    max-width: 500px;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.6);
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.graph-modal-title {
    margin: 0;
    font-size: 18px;
    font-weight: 600;
    color: var(--graph-text);
    text-align: center;
}

.graph-modal-preview {
    display: flex;
    justify-content: center;
    align-items: center;
    background: rgba(0, 0, 0, 0.2);
    border-radius: 8px;
    padding: 10px;
    min-height: 150px;
}

.graph-modal-actions {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

/* Кнопки в модалке */
.graph-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 16px;
    border-radius: 6px;
    font-family: var(--graph-sans);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    border: 1px solid transparent;
}

/* Primary (Copy) */
.graph-btn--primary {
    background: #22c55e;
    /* Green */
    color: #fff;
    border: 1px solid #16a34a;
}

.graph-btn--primary:hover {
    background: #16a34a;
}

.graph-btn--primary.success {
    background: #15803d;
    cursor: default;
}

/* Secondary (Download) */
.graph-btn--secondary {
    background: rgba(255, 255, 255, 0.08);
    color: var(--graph-text);
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.graph-btn--secondary:hover {
    background: rgba(255, 255, 255, 0.12);
    border-color: rgba(255, 255, 255, 0.2);
}

/* ============================================================================
   Стили для Info Renderer
   ============================================================================ */

.graph-info-section {
    margin-bottom: 24px;
}

.graph-info-title {
    font-size: 16px;
    font-weight: 600;
    color: var(--graph-text);
    margin: 0 0 12px 0;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--graph-border2);
}

.graph-info-content {
    font-size: 14px;
    color: var(--graph-muted);
    line-height: 1.6;
}

.graph-info-content p {
    margin: 0 0 12px 0;
}

.graph-info-list {
    margin: 0 0 16px 0;
    padding-left: 20px;
}

.graph-info-list li {
    margin-bottom: 8px;
}

.graph-info-sublist {
    margin: 8px 0 8px 0;
    padding-left: 20px;
    list-style-type: circle;
}

.graph-info-note {
    margin-top: 6px;
    font-size: 13px;
    color: #fbbf24;
    /* Amber for note */
    background: rgba(251, 191, 36, 0.1);
    padding: 6px 10px;
    border-radius: 4px;
}

.graph-info-divider {
    height: 1px;
    background: var(--graph-border2);
    margin: 24px 0;
}

/* Info Table */
.graph-info-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 12px;
}

.graph-info-table th {
    text-align: left;
    padding: 8px 12px;
    color: var(--graph-text);
    font-weight: 600;
    border-bottom: 1px solid var(--graph-border);
    font-size: 13px;
}

.graph-info-table td {
    padding: 10px 12px;
    border-bottom: 1px solid var(--graph-border2);
    vertical-align: middle;
}

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

.graph-info-icon-cell {
    text-align: center;
    padding-left: 4px;
    padding-right: 4px;
}

.graph-info-icon {
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    background: rgba(255, 255, 255, 0.1);
    color: var(--graph-text);
}

.graph-info-icon svg {
    width: 16px;
    height: 16px;
}

/* Keyboard keys */
kbd {
    display: inline-block;
    padding: 2px 6px;
    font-family: var(--graph-sans);
    font-size: 11px;
    font-weight: 500;
    color: var(--graph-text);
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 4px;
    box-shadow: 0 2px 0 rgba(0, 0, 0, 0.2);
}

/* Text (Cancel) */
.graph-btn--text {
    background: transparent;
    color: var(--graph-muted);
}

.graph-btn--text:hover {
    color: var(--graph-text);
}