/* ============================================================
   DeltaGuard — Analytics Modal Styles
   Premium floating modal with glassmorphism and gradient accents
   ============================================================ */

/* ── Analytics Modal Overlay ─────────────────────────────────── */
#analytics-modal {
    position: fixed;
    inset: 0;
    z-index: 10000;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(2, 6, 12, 0.85);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    animation: analyticsOverlayIn 0.2s ease;
}

#analytics-modal.hidden {
    display: none !important;
}

@keyframes analyticsOverlayIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

/* ── Modal Box ─────────────────────────────────────────────────── */
.am-box {
    width: 95%;
    max-width: 960px;
    max-height: 92vh;
    background: linear-gradient(180deg, #0b1622 0%, #081018 100%);
    border: 1px solid #1e3550;
    border-radius: 20px;
    box-shadow:
        0 32px 64px rgba(0, 0, 0, 0.6),
        0 0 0 1px rgba(30, 53, 80, 0.3),
        inset 0 1px 0 rgba(255, 255, 255, 0.03);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    animation: analyticsSlideIn 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes analyticsSlideIn {
    from {
        opacity: 0;
        transform: translateY(24px) scale(0.97);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

/* ── Modal Header ──────────────────────────────────────────────── */
.am-header {
    padding: 1.25rem 1.5rem;
    border-bottom: 1px solid #1e3550;
    background: rgba(5, 11, 20, 0.9);
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-shrink: 0;
}

.am-header-left {
    display: flex;
    align-items: center;
    gap: 14px;
}

.am-header-icon {
    width: 48px;
    height: 48px;
    border-radius: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    background: rgba(30, 53, 80, 0.5);
    border: 1px solid #2a5082;
}

.am-header-info h2 {
    font-size: 1.1rem;
    font-weight: 800;
    color: #fff;
    letter-spacing: -0.02em;
}

.am-header-info p {
    font-size: 0.72rem;
    color: #6b8aaa;
    margin-top: 2px;
}

.am-status-badge {
    display: inline-flex;
    align-items: center;
    padding: 0.2rem 0.6rem;
    border-radius: 20px;
    font-size: 0.65rem;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    border: 1px solid;
    margin-left: 8px;
}

.am-close-btn {
    width: 36px;
    height: 36px;
    border-radius: 10px;
    border: 1px solid #1e3550;
    background: rgba(13, 24, 39, 0.6);
    color: #6b8aaa;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.15s;
}

.am-close-btn:hover {
    background: rgba(239, 68, 68, 0.15);
    border-color: rgba(239, 68, 68, 0.3);
    color: #f87171;
}

/* ── Pool Selector "Neon-Pulse" (DELTA-72) ─────────────────────── */
/* [Fix Unificación] Ahora es un grupo flex dentro de .am-timeframe-bar,
   alineado a la izquierda mientras el grupo de temporalidades queda a
   la derecha (controles "One-Line"). */
.am-pool-selector-bar {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 6px;
}

/* [UI Mimetismo] Los botones de pool usan exactamente las mismas clases
   que los de Periodo (am-tf-btn / am-tf-active). El halo neon-pulse se
   aplica solo al am-tf-active DENTRO del selector de pools, para que el
   boton "TODO" de Periodo conserve su estilo normal sin pulso. */
#am-pool-selector-bar .am-tf-btn.am-tf-active {
    /* [Feature Selector Multi-Pool] --neon-color es inyectado por JS con el
       color del bot activo (BOT_CONFIG[botType].color); #00ffae es el fallback. */
    color: var(--neon-color, #00ffae);
    border-color: var(--neon-color, #00ffae);
    background: color-mix(in srgb, var(--neon-color, #00ffae) 8%, transparent);
    animation: pulse-neon 1.6s ease-in-out infinite;
}

@keyframes pulse-neon {
    0%, 100% {
        box-shadow: 0 0 4px color-mix(in srgb, var(--neon-color, #00ffae) 35%, transparent),
                    inset 0 0 6px color-mix(in srgb, var(--neon-color, #00ffae) 5%, transparent);
        text-shadow: 0 0 4px color-mix(in srgb, var(--neon-color, #00ffae) 60%, transparent);
    }
    50% {
        box-shadow: 0 0 14px color-mix(in srgb, var(--neon-color, #00ffae) 90%, transparent),
                    0 0 28px color-mix(in srgb, var(--neon-color, #00ffae) 35%, transparent),
                    inset 0 0 10px color-mix(in srgb, var(--neon-color, #00ffae) 15%, transparent);
        text-shadow: 0 0 10px color-mix(in srgb, var(--neon-color, #00ffae) 100%, transparent),
                     0 0 20px color-mix(in srgb, var(--neon-color, #00ffae) 60%, transparent);
    }
}

/* ── Timeframe Selector ────────────────────────────────────────── */
/* [Fix Unificación] Fila unica "One-Line Control": el selector de Pools
   (am-pool-selector-bar) a la izquierda y el grupo de temporalidades
   (am-tf-group) a la derecha. */
.am-timeframe-bar {
    padding: 0.75rem 1.5rem;
    min-height: 50px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 6px;
    border-bottom: 1px solid rgba(30, 53, 80, 0.5);
    background: rgba(5, 11, 20, 0.6);
    flex-shrink: 0;
}

.am-tf-group {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 6px;
}

.am-tf-btn {
    padding: 0.4rem 0.85rem;
    border-radius: 8px;
    font-size: 0.72rem;
    font-weight: 700;
    font-family: 'JetBrains Mono', monospace;
    color: #a0bcd8;
    background: #0d1827;
    border: 1px solid #1e3550;
    cursor: pointer;
    transition: all 0.15s;
    letter-spacing: 0.03em;
}

.am-tf-btn:hover {
    color: #a0bcd8;
    background: rgba(30, 53, 80, 0.4);
}

.am-tf-btn.am-tf-active {
    color: #00d4ff;
    background: rgba(0, 212, 255, 0.1);
    border-color: rgba(0, 212, 255, 0.3);
    box-shadow: 0 0 12px rgba(0, 212, 255, 0.08);
}

/* ── Pool Selector Trigger "Neon Pulse" (Dashboard Global) ─────────── */
/* Se aplica al boton #wad-pool-selector-btn cuando _wadPoolFilter != null. */
.am-tf-btn.neon-pulse-active {
    color: #00d4ff;
    border-color: #00d4ff;
    background: rgba(0, 212, 255, 0.08);
    animation: pulse-neon 1.6s ease-in-out infinite;
    --neon-color: #00d4ff;
}

/* ── Galeria "Selector de Pools Operativos" (UI.showModal) ─────────── */
.wad-pool-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 10px;
    max-height: 60vh;
    overflow-y: auto;
    padding: 4px;
}

.wad-pool-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    padding: 14px 10px;
    border-radius: 10px;
    border: 1px solid #1e3550;
    background: rgba(13, 24, 39, 0.6);
    cursor: pointer;
    transition: all 0.15s;
    text-align: center;
}

.wad-pool-card:hover {
    border-color: #00d4ff;
    box-shadow: 0 0 12px rgba(0, 212, 255, 0.2);
    transform: translateY(-2px);
}

.wad-pool-card.wad-pool-active {
    border-color: #00d4ff;
    background: rgba(0, 212, 255, 0.08);
    box-shadow: 0 0 15px rgba(0, 212, 255, 0.3);
}

.wad-pool-card-icon {
    font-size: 1.6rem;
}

.wad-pool-card-id {
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.7rem;
    color: #a0bcd8;
    font-weight: 700;
}

/* ── Bot Breakdown Cards (clic = filtrar Rendimiento Global) ──────── */
.wad-bf-card {
    transition: background 0.15s, box-shadow 0.15s;
}

.wad-bf-card:hover {
    background: rgba(30, 53, 80, 0.3);
}

.wad-bf-card.wad-bf-active {
    background: rgba(0, 212, 255, 0.08);
    box-shadow: inset 0 0 0 1px rgba(0, 212, 255, 0.3);
}

/* ── Filas nuevas del scroll infinito de Rendimiento Global ───────── */
@keyframes wadRowEnter {
    from { opacity: 0; transform: translateY(6px); }
    to   { opacity: 1; transform: translateY(0); }
}

.wad-row-enter {
    animation: wadRowEnter 0.25s ease-out;
}

/* ── Scrollable Body ───────────────────────────────────────────── */
.am-body {
    padding: 1.25rem 1.5rem;
    overflow-y: auto;
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
}

/* ── Metrics Grid ──────────────────────────────────────────────── */
.am-metrics-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 12px;
}

.am-metric-card {
    padding: 1rem;
    border-radius: 14px;
    border: 1px solid #1e3550;
    background: rgba(5, 11, 20, 0.6);
    display: flex;
    flex-direction: column;
    gap: 6px;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.am-metric-card:hover {
    border-color: #2a5082;
    box-shadow: 0 0 20px rgba(0, 150, 255, 0.04);
}

.am-metric-label {
    font-size: 0.62rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: #3d607a;
}

.am-metric-value {
    font-size: 1.3rem;
    font-weight: 800;
    font-family: 'JetBrains Mono', monospace;
    letter-spacing: -0.02em;
}

/* ── Chart Container ───────────────────────────────────────────── */
.am-chart-container {
    border-radius: 14px;
    border: 1px solid #1e3550;
    background: rgba(5, 11, 20, 0.6);
    padding: 1rem;
    position: relative;
}

.am-chart-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.75rem;
}

.am-chart-title {
    font-size: 0.75rem;
    font-weight: 700;
    color: #6b8aaa;
    text-transform: uppercase;
    letter-spacing: 0.08em;
}

.am-chart-canvas {
    width: 100%;
    height: 260px;
}

/* ── Stats Summary Row ─────────────────────────────────────────── */
.am-stats-row {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 10px;
}

.am-stat-item {
    padding: 0.65rem 0.85rem;
    border-radius: 10px;
    border: 1px solid rgba(30, 53, 80, 0.5);
    background: rgba(13, 24, 39, 0.4);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.am-stat-label {
    font-size: 0.65rem;
    color: #4a7096;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.am-stat-value {
    font-size: 0.82rem;
    font-family: 'JetBrains Mono', monospace;
    font-weight: 600;
    color: #e2eaf5;
}

/* ── Breakdown Cards (Global View) ─────────────────────────────── */
/* [DELTA-66] Rejilla mas aireada: mas espacio entre tarjetas y mas
   padding interno para que el PnL y el ROI% no queden apretados. */
#am-breakdown {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 16px;
}

.am-breakdown-card {
    padding: 1.1rem 1.2rem;
    border-radius: 12px;
    border: 1px solid;
    background: rgba(5, 11, 20, 0.5);
    transition: border-color 0.2s;
}

.am-breakdown-card:hover {
    border-color: rgba(0, 180, 230, 0.3);
}

/* ── Trade History Container ───────────────────────────────────── */
.am-trades-section {
    border-radius: 14px;
    border: 1px solid #1e3550;
    background: rgba(5, 11, 20, 0.6);
    min-height: 120px;
}

.am-trades-header {
    padding: 0.75rem 1rem;
    border-bottom: 1px solid rgba(30, 53, 80, 0.5);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.am-trades-title {
    font-size: 0.75rem;
    font-weight: 700;
    color: #6b8aaa;
    text-transform: uppercase;
    letter-spacing: 0.08em;
}

.am-trades-body {
    max-height: 300px;
    overflow-y: auto;
}

/* ── Analytics Trigger Buttons (per-bot) ───────────────────────── */
.am-trigger-btn {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 0.4rem 0.75rem;
    border-radius: 8px;
    font-size: 0.72rem;
    font-weight: 600;
    color: #6b8aaa;
    background: rgba(13, 24, 39, 0.5);
    border: 1px solid #1e3550;
    cursor: pointer;
    transition: all 0.15s;
}

.am-trigger-btn:hover {
    color: #00d4ff;
    border-color: rgba(0, 212, 255, 0.3);
    background: rgba(0, 212, 255, 0.08);
    box-shadow: 0 0 12px rgba(0, 212, 255, 0.1);
}

.am-trigger-btn svg {
    width: 14px;
    height: 14px;
}

/* ── Responsive ────────────────────────────────────────────────── */
@media (max-width: 768px) {
    .am-metrics-grid,
    .am-stats-row,
    #am-breakdown {
        grid-template-columns: repeat(2, 1fr);
    }

    .am-box {
        max-height: 96vh;
        border-radius: 14px;
    }

    .am-metric-value {
        font-size: 1rem;
    }
}

@media (max-width: 480px) {
    .am-metrics-grid,
    .am-stats-row {
        grid-template-columns: 1fr;
    }
}

/* ── Selector de Temporalidad estilo Exchange ("Más ▾") ────────────── */
.wad-tf-dropdown {
    z-index: 99998;
    width: 280px;
    max-height: 80vh;
    overflow-y: auto;
    background: linear-gradient(180deg, #0b1622 0%, #081018 100%);
    border: 1px solid #1e3550;
    border-radius: 12px;
    box-shadow: 0 16px 40px rgba(0, 0, 0, 0.55);
    padding: 12px;
}

.wad-tf-dd-title {
    font-size: 0.6rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: #3d607a;
    margin-bottom: 6px;
}

.wad-tf-dd-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 6px;
}

.wad-tf-dd-divider {
    border-top: 1px solid #1e3550;
    margin: 10px 0;
}

.wad-tf-dd-add-btn {
    width: 100%;
    padding: 0.5rem 0.6rem;
    border-radius: 8px;
    font-size: 0.7rem;
    font-weight: 700;
    color: #00d4ff;
    background: rgba(0, 212, 255, 0.08);
    border: 1px dashed rgba(0, 212, 255, 0.3);
    cursor: pointer;
    transition: all 0.15s;
}

.wad-tf-dd-add-btn:hover {
    background: rgba(0, 212, 255, 0.14);
}

.wad-tf-dd-custom-form {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-top: 8px;
}

.wad-tf-dd-label {
    display: block;
    font-size: 0.6rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: #4a7096;
    margin-bottom: 4px;
}

.wad-tf-dd-select,
.wad-tf-dd-input {
    width: 100%;
    background: #0d1827;
    border: 1px solid #1e3550;
    color: #e2eaf5;
    border-radius: 8px;
    padding: 0.4rem 0.6rem;
    font-size: 0.75rem;
    font-family: 'JetBrains Mono', monospace;
}


