/* Opening Explorer Styles */
.opening-explorer-panel {
    display: none; /* hidden by default */
    background: var(--theme-bg-secondary, #1a1a1a);
    color: var(--theme-text-primary, #e0e0e0);
    border-radius: 6px;
    margin-top: 10px;
    font-size: 13px;
    font-family: Poppins, system-ui, sans-serif;
    overflow: hidden;
    border: 1px solid var(--theme-border-color, #333);
}

.pgn-section.opening-explorer-open {
    overflow: hidden !important;
}

.pgn-section.opening-explorer-open #pgn-viewer {
    min-height: 0 !important;
    overflow-y: auto !important;
}

.opening-explorer-panel.visible {
    display: flex;
    flex-direction: column;
    flex: 0 0 auto;
    max-height: min(42vh, 360px) !important;
    max-height: min(42svh, 360px) !important;
    min-height: 0;
    overflow: hidden;
    position: relative;
    z-index: 2;
}

.explorer-header {
    background: var(--theme-bg-tertiary, #222);
    padding: 8px 12px;
    font-weight: 600;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--theme-border-color, #333);
}

.explorer-title-flex {
    display: flex;
    align-items: center;
    gap: 8px;
}

.explorer-badge {
    background: #0083fe;
    color: white;
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 10px;
}

.explorer-close {
    background: transparent;
    border: none;
    color: var(--theme-text-secondary, #999);
    cursor: pointer;
    font-size: 16px;
    line-height: 1;
    padding: 0 4px;
}

.explorer-close:hover {
    color: var(--theme-text-primary, #fff);
}

.explorer-table {
    width: 100%;
    border-collapse: collapse;
}

.explorer-table-container {
    flex: 1 1 auto !important;
    min-height: 0 !important;
    overflow-y: auto !important;
}

.explorer-table th, .explorer-table td {
    padding: 6px 12px;
    text-align: left;
    border-bottom: 1px solid var(--theme-border-color, #333);
}

.explorer-table th {
    font-weight: 500;
    color: var(--theme-text-secondary, #999);
    font-size: 11px;
}

.explorer-table tr:hover:not(.explorer-empty) {
    background: var(--theme-bg-hover, rgba(255,255,255,0.05));
    cursor: pointer;
}

.td-move {
    font-weight: 600;
    min-width: 60px;
}

.td-games {
    min-width: 60px;
    text-align: right;
    color: var(--theme-text-secondary, #aaa);
}

.td-stats {
    width: 100%; /* forces other columns to compress */
}

/* Win/Draw/Loss Bar */
.wdl-bar {
    display: flex;
    height: 12px;
    width: 100%;
    border-radius: 3px;
    overflow: hidden;
    background: #444; /* fallback base */
    position: relative;
    box-shadow: inset 0 1px 2px rgba(0,0,0,0.3);
}

.wdl-white {
    background: #ddd;
    color: #000;
    display: flex;
    align-items: center;
    justify-content: flex-start;
    padding-left: 3px;
    font-size: 9px;
    font-weight: 600;
}
.wdl-draw {
    background: #777;
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 9px;
    font-weight: 600;
}
.wdl-black {
    background: #333;
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: flex-end;
    padding-right: 3px;
    font-size: 9px;
    font-weight: 600;
}

/* To display percentages cleanly without clipping on tiny bars */
.wdl-bar div {
    white-space: nowrap;
}

.explorer-loader {
    padding: 20px;
    text-align: center;
    color: var(--theme-text-secondary, #888);
    font-style: italic;
    font-size: 12px;
}

.explorer-empty {
    text-align: center;
    padding: 20px;
    color: var(--theme-text-secondary, #888);
}

@media (max-width: 768px) {
    .pgn-section.opening-explorer-open {
        height: min(72vh, 520px) !important;
        max-height: min(72vh, 520px) !important;
        height: min(72svh, 520px) !important;
        max-height: min(72svh, 520px) !important;
        display: flex !important;
        flex-direction: column !important;
    }

    .pgn-section.opening-explorer-open .opening-explorer-panel.visible {
        max-height: min(44vh, 300px) !important;
        max-height: min(44svh, 300px) !important;
        margin-bottom: 8px !important;
    }

    .pgn-section.opening-explorer-open #pgn-viewer {
        flex: 1 1 auto !important;
        max-height: none !important;
    }
}

@media (max-width: 768px) and (orientation: landscape) {
    .controls-container .pgn-section.opening-explorer-open {
        height: 100vh !important;
        max-height: 100vh !important;
        height: 100svh !important;
        max-height: 100svh !important;
    }

    .controls-container .pgn-section.opening-explorer-open .opening-explorer-panel.visible {
        max-height: min(52vh, 260px) !important;
        max-height: min(52svh, 260px) !important;
    }
}
