/* frontend/src/components/StrategyList.css */
.strategy-list-container {
    border: 1px solid #ccc;
    padding: 15px;
    margin-top: 20px;
    border-radius: 5px;
    background-color: #f9f9f9;
}

.strategy-list-container h3 {
    margin-top: 0;
}

.error-message {
    color: red;
    font-weight: bold;
}

.strategy-list-hint {
    font-size: 0.9em;
    color: #555;
}

.strategy-list {
    list-style-type: none;
    padding-left: 0;
}

.strategy-list-item {
    display: flex;
    justify-content: flex-start; /* evitar jitter por space-between */
    align-items: center;
    gap: 12px; /* separación estable */
    padding: 8px 12px;
    margin-bottom: 5px;
    border: 1px solid #eee;
    border-radius: 4px;
    background-color: #fff;
    cursor: pointer;
    transition: background-color 0.2s ease-in-out;
}

.strategy-list-item:hover {
    background-color: #f0f0f0;
}

.strategy-list-item.selected {
    background-color: #e0f0ff; /* Un azul claro para el seleccionado */
    border-left: 3px solid #007bff;
}

/* Elemento no seleccionable (historical en curso) */
.strategy-list-item.disabled {
    opacity: 0.6;
    cursor: not-allowed;
}
.strategy-list-item.disabled:hover {
    background-color: #fff;
}

.strategy-info {
    display: flex;
    flex-direction: column; /* Apila ID y estado */
    flex: 1 1 auto;         /* permite que encoja si es necesario */
    min-width: 0;           /* necesario para ellipsis en hijos flex */
}

.strategy-id {
    font-weight: 500;
    color: #333;
    word-break: break-all; /* Para IDs largos */
}

.strategy-created-at {
    font-size: 0.75em;
    color: #888;
}

.strategy-status {
    font-size: 0.85em;
    color: #666;
    margin-top: 2px;
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 6px;
    white-space: normal;
    /* No recortar el contenido: mostrar el progreso completo */
    font-variant-numeric: tabular-nums; /* números de ancho fijo para que no "bailen" */
}

.market-badges {
    display: inline-flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-left: 8px;
}

.market-badge {
    display: inline-flex;
    align-items: center;
    padding: 1px 8px;
    border-radius: 999px;
    border: 1px solid transparent;
    font-size: 0.78rem;
    line-height: 1.35;
    white-space: nowrap;
}

.market-badge-ok {
    color: #065f46;
    background: #d1fae5;
    border-color: #6ee7b7;
}

.market-badge-warn {
    color: #92400e;
    background: #fef3c7;
    border-color: #fbbf24;
}

.market-badge-bad {
    color: #991b1b;
    background: #fee2e2;
    border-color: #fca5a5;
}

.market-badge-muted {
    color: #374151;
    background: #f3f4f6;
    border-color: #d1d5db;
}

/* Colores para estados unificados */
.status-active { color: #228B22; } /* ForestGreen */
.status-loading-state { color: #DAA520; } /* GoldenRod (cargando estado) */
.status-queued { color: #DAA520; } /* GoldenRod */
.status-starting { color: #B8860B; } /* DarkGoldenRod */
.status-loading-data { color: #FF8C00; } /* DarkOrange */
.status-initializing { color: #8B4513; } /* SaddleBrown */
.status-running { color: #20B2AA; } /* LightSeaGreen */
.status-completed { color: #32CD32; } /* LimeGreen */
.status-stopped { color: #DC143C; } /* Crimson */
/* Cualquier error */
.strategy-status[class*="status-error"] { 
    color: #FF0000; /* Red */
    font-weight: bold;
}


.strategy-stopping-indicator {
    font-style: italic;
    color: #777;
    margin-left: 10px;
}

.stop-strategy-button {
    padding: 5px 10px;
    margin-left: auto;  /* empuja el botón al extremo derecho sin usar space-between */
    background-color: #ff4d4d;
    color: white;
    border: none;
    border-radius: 3px;
    cursor: pointer;
    white-space: nowrap; /* impedir "Cancel & Clear" en múltiples líneas */
    flex: 0 0 auto;      /* no permitir que el botón se encoja */
}

.stop-strategy-button:hover {
    background-color: #cc0000;
}

.stop-strategy-button:disabled {
    background-color: #ccc;
    cursor: not-allowed;
}
.status-dot {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
}
.status-dot.status-queued { background: #DAA520; }
.status-dot.status-starting { background: #B8860B; }
.status-dot.status-loading-data { background: #FF8C00; }
.status-dot.status-initializing { background: #8B4513; }
.status-dot.status-running { background: #20B2AA; }
.status-dot.status-completed { background: #32CD32; }
.status-dot.status-stopped { background: #DC143C; }
.status-dot.status-active { background: #228B22; }

/* Barra de progreso compacta dentro del estado */
.progress-wrap {
    position: relative;
    display: inline-block;
    width: 100px; /* un poco más ancho para mayor legibilidad */
    height: 6px;
    background: #eee;
    border-radius: 3px;
    overflow: hidden;
}
.progress-bar {
    display: block;
    height: 100%;
    background: linear-gradient(90deg, #4caf50, #8bc34a);
}

body.dark-mode .strategy-list-container {
    background-color: var(--color-surface);
    border-color: var(--color-surface-border);
    color: var(--color-text);
}

body.dark-mode .strategy-list-hint {
    color: var(--color-muted);
}

body.dark-mode .strategy-list-item {
    background-color: rgba(17, 24, 39, 0.88);
    border-color: #374151;
    color: var(--color-text);
}

body.dark-mode .strategy-list-item:hover {
    background-color: rgba(59, 130, 246, 0.12);
}

body.dark-mode .strategy-list-item.disabled:hover {
    background-color: rgba(17, 24, 39, 0.88);
}

body.dark-mode .strategy-id {
    color: #e2e8f0;
}

body.dark-mode .strategy-created-at,
body.dark-mode .strategy-status {
    color: rgba(226, 232, 240, 0.75);
}

body.dark-mode .market-badge-ok {
    color: #a7f3d0;
    background: rgba(6, 95, 70, 0.35);
    border-color: rgba(16, 185, 129, 0.55);
}

body.dark-mode .market-badge-warn {
    color: #fde68a;
    background: rgba(146, 64, 14, 0.35);
    border-color: rgba(251, 191, 36, 0.55);
}

body.dark-mode .market-badge-bad {
    color: #fca5a5;
    background: rgba(153, 27, 27, 0.35);
    border-color: rgba(248, 113, 113, 0.55);
}

body.dark-mode .market-badge-muted {
    color: #d1d5db;
    background: rgba(55, 65, 81, 0.6);
    border-color: rgba(156, 163, 175, 0.55);
}

body.dark-mode .strategy-stopping-indicator {
    color: rgba(226, 232, 240, 0.6);
}

body.dark-mode .progress-wrap {
    background: rgba(148, 163, 184, 0.25);
}
