/**
 * STOCKFISH PANEL CSS - Estilos para Panel de Análisis
 * Ajedrez de Silicio - Tema rojo/negro/dorado
 * 
 * Panel de análisis Stockfish con diseño consistente
 */

/* ===== PANEL PRINCIPAL ===== */
.stockfish-panel {
    background: var(--theme-button-bg);
    border: 1px solid var(--theme-border);
    border-radius: 12px;
    margin-bottom: 12px;
    box-shadow: 
        0 4px 12px var(--theme-shadow),
        inset 0 1px 0 rgba(255, 255, 255, 0.05);
    overflow: hidden;
    transition: all var(--transition-normal);
}

.stockfish-panel:hover {
    border-color: var(--theme-accent-primary);
    box-shadow: 
        0 6px 20px var(--theme-shadow),
        inset 0 1px 0 rgba(255, 255, 255, 0.1);
}

/* ===== HEADER ===== */
.stockfish-header {
    background: var(--theme-bg-tertiary);
    border-bottom: 1px solid var(--theme-border);
    padding: 12px 16px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.stockfish-title {
    color: var(--theme-accent-primary);
    font-size: 0.9rem;
    font-weight: 700;
    font-family: var(--font-main);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    transition: color var(--transition-theme);
}

.stockfish-controls {
    display: flex;
    align-items: center;
    gap: 8px;
}

.line-control {
    background: var(--theme-button-hover);
    border: 1px solid var(--theme-accent-primary);
    border-radius: 6px;
    color: var(--theme-button-text-hover);
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.8rem;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition-normal);
    box-shadow: 0 2px 6px var(--theme-shadow);
}

.line-control:hover {
    background: var(--theme-button-hover);
    transform: translateY(-1px) scale(1.05);
    box-shadow: 0 4px 12px var(--theme-shadow);
}

.line-control:active {
    transform: translateY(0) scale(0.95);
}

.lines-indicator {
    color: var(--theme-accent-primary);
    font-size: 0.8rem;
    font-weight: 600;
    min-width: 16px;
    text-align: center;
    font-family: var(--font-main);
    transition: color var(--transition-theme);
}

/* ===== CONTENIDO ===== */
/* contenedor flexible con animación suave */
.stockfish-content {
    display: flex;
    flex-direction: column;
    gap: 8px;
    overflow: hidden;
    max-height: 0;                    /* parte cerrado hasta que JS mida */
    transition: max-height 220ms ease;
    will-change: max-height;
    padding: 12px 16px;                /* mantener padding actual */
}

/* ===== LÍNEAS DE ANÁLISIS ===== */
.analysis-line {
    background: var(--theme-bg-primary);
    border: 1px solid var(--theme-border);
    border-radius: 8px;
    padding: 10px 12px;
    display: flex;
    flex-wrap: nowrap;
    flex-direction: row;
    justify-content: space-between;
    align-items: center;
    gap: 8px;
    min-height: 75px;
    transition: all var(--transition-normal);
    position: relative;
    overflow: hidden;
}

/* Sólo se muestra si tiene la clase .is-visible */
.analysis-line { 
    display: none; 
}
.analysis-line.is-visible { 
    display: flex; 
}

.analysis-line::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, var(--theme-shadow-glow), transparent);
    transition: left 0.6s ease;
}

.analysis-line:hover::before {
    left: 100%;
}

.analysis-line:hover {
    border-color: var(--theme-accent-primary);
    transform: translateY(-1px);
}

/* Evaluación con número y símbolo */
.line-evaluation {
    display: inline-flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-width: 48px;
    padding: 6px 8px;
    border-radius: 8px;
    transition: all 0.3s ease;
    overflow: hidden;
    flex-shrink: 0;
    text-align: center;
}

.line-evaluation .eval-num {
    font-weight: 700;
    font-size: 14px;
    line-height: 1.0;
    font-family: 'Poppins', 'Segoe UI', sans-serif;
}

.line-evaluation .eval-sym {
    margin-top: 2px;
    font-size: 12px;
    line-height: 1.0;
    opacity: 0.85;
    font-family: 'Poppins', 'Segoe UI', sans-serif;
}

.analysis-line .line-evaluation.equal {
    background: rgba(212, 175, 55, 0.2) !important;
    color: #D4AF37 !important;
    border: 1px solid rgba(212, 175, 55, 0.3) !important;
}

.analysis-line .line-evaluation.slight-advantage-white {
    background: rgba(197, 0, 57, 0.3) !important;
    color: #FFB3C6 !important;
    border: 1px solid rgba(197, 0, 57, 0.5) !important;
}

.analysis-line .line-evaluation.advantage-white {
    background: rgba(197, 0, 57, 0.5) !important;
    color: #FF6B9D !important;
    border: 1px solid rgba(197, 0, 57, 0.7) !important;
}

.analysis-line .line-evaluation.slight-advantage-black {
    background: rgba(100, 100, 100, 0.3) !important;
    color: #CCCCCC !important;
    border: 1px solid rgba(100, 100, 100, 0.5) !important;
}

.analysis-line .line-evaluation.advantage-black {
    background: rgba(100, 100, 100, 0.5) !important;
    color: #AAAAAA !important;
    border: 1px solid rgba(100, 100, 100, 0.7) !important;
}

/* Movimientos */
.line-moves {
    flex: 1 1 auto;
    min-width: 0;
    color: #e8e8e8;
    font-size: 0.8rem;
    font-family: 'Courier New', monospace;
    margin: 0;
    padding: 0 56px 0 8px;  /* reserva espacio para badge flotante */
    text-align: left;
    font-weight: 500;
    letter-spacing: 0.5px;
    display: -webkit-box !important;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 3;
    overflow: hidden;
    line-height: 1.3;
    max-height: 3.9em;
}

/* Profundidad como badge flotante discreto */
.line-depth {
    position: absolute;
    top: 8px;
    right: 12px;
    font-size: 10px;
    opacity: 0.7;
    padding: 1px 5px;
    border-radius: 6px;
    border: 1px solid rgba(212, 175, 55, 0.2);
    background: rgba(212, 175, 55, 0.08);
    line-height: 1;
    pointer-events: none;
    white-space: nowrap;
    color: #D4AF37;
    font-weight: 500;
    font-family: 'Poppins', 'Segoe UI', sans-serif;
}

/* ===== RESPONSIVE ===== */
@media (max-width: 768px) {
    .stockfish-header {
        padding: 10px 12px;
        flex-direction: column;
        gap: 8px;
    }
    
    .stockfish-title {
        font-size: 0.8rem;
    }
    
    .stockfish-content {
        padding: 10px 12px;
    }
    
    .analysis-line {
        flex-direction: column;
        gap: 6px;
        text-align: center;
    }
    
    .line-moves {
        margin: 0;
        order: 1;
    }
    
    .line-evaluation {
        order: 2;
    }
    
    .line-depth {
        order: 3;
        text-align: center;
        min-width: auto;
    }
    
    .line-control {
        width: 32px;
        height: 32px;
        font-size: 0.9rem;
    }
}

/* ===== ANIMACIONES ===== */
@keyframes stockfish-thinking {
    0% { opacity: 0.6; }
    50% { opacity: 1; }
    100% { opacity: 0.6; }
}

.analysis-line[data-thinking="true"] .line-moves {
    animation: stockfish-thinking 1.5s ease-in-out infinite;
}

/* ===== ESTADOS ESPECIALES ===== */
.analysis-line[data-line="1"] {
    border-color: rgba(212, 175, 55, 0.4);
}

.analysis-line[data-line="2"] {
    border-color: rgba(197, 0, 57, 0.3);
}

.analysis-line[data-line="3"] {
    border-color: rgba(100, 100, 100, 0.3);
}

/* Efecto de actualización */
.analysis-line.updating {
    background: linear-gradient(145deg, #1f1f1f 0%, #252525 100%);
    border-color: rgba(212, 175, 55, 0.5);
}

.analysis-line.updating .line-moves {
    color: #D4AF37;
}

/* === STOCKFISH: overrides para altura dinámica === */

/* No permitir que el panel se estire por flex ni tenga alturas fijas */
#stockfish-panel {
  height: auto !important;
  min-height: 0 !important;
  max-height: none !important;
  flex: 0 0 auto !important;      /* <- evita que rellene el espacio */
  align-self: flex-start !important;
}

/* El contenedor que anima: sin height/min-height fijos */
#stockfish-panel .stockfish-content {
  height: auto !important;
  min-height: 0 !important;
  /* animación real con max-height */
  overflow: hidden;
  max-height: 0;                   /* se abre con JS */
  transition: max-height 220ms ease;
  will-change: max-height;
}

/* Las líneas: controladas por clases */
#stockfish-panel .analysis-line { display: none; }
#stockfish-panel .analysis-line.is-visible { display: flex; }

/* Estado deshabilitado para botones +/- */
.stockfish-controls button:disabled,
.stockfish-controls button.disabled {
    opacity: 0.3;
    cursor: not-allowed;
    pointer-events: none;
}

/* === MÓVILES: ancho estable === */
@media (max-width: 768px) {
    #stockfish-panel {
        min-width: 100%;
        width: 100%;
    }
    
    .stockfish-content {
        min-width: 100%;
        width: 100%;
    }
    
    .analysis-line {
        min-width: 100%;
    }
    
    .analysis-line .line-moves {
        min-width: 0;
        flex: 1 1 auto;
        width: 100%;
    }
}
