/* style.css - NextChessMove Utility Clone */
body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    background-color: #f8f9fa;
    color: #212529;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    box-sizing: border-box;
}

*, *::before, *::after {
    box-sizing: inherit;
}

header {
    width: 100%;
    background-color: #343a40;
    color: #fff;
    padding: 1rem 0;
    text-align: center;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

header h1 {
    margin: 0;
    font-size: 1.5rem;
    font-weight: 600;
}

.container {
    display: flex;
    flex-direction: row;
    gap: 2rem;
    padding: 2rem;
    max-width: 1000px;
    width: 100%;
}

@media (max-width: 800px) {
    .container {
        flex-direction: column;
        align-items: center;
        padding: 1rem;
    }
    .editor-palette {
        order: -2;
    }
    .pro-tip {
        order: -1;
        margin-bottom: 1rem;
    }
}

/* Board Styling */
.board-container {
    flex: 1.2;
    width: 100%;
    display: flex;
    justify-content: center;
    align-items: flex-start;
}

.board-wrapper {
    display: flex;
    flex-direction: row;
    align-items: stretch;
    width: 100%;
    max-width: 540px; /* 500 board + 30 bar + 10 gap */
    gap: 10px;
}

.eval-bar-container {
    width: 30px;
    background-color: #343a40; /* Black piece color */
    border-radius: 4px;
    position: relative;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    box-shadow: inset 0 2px 4px rgba(0,0,0,0.3);
}

.eval-bar-fill {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 50%;
    background-color: #e63946; /* Red piece color */
    transition: height 0.5s ease-in-out, background-color 0.3s ease;
}

.eval-bar-text {
    position: absolute;
    width: 100%;
    text-align: center;
    color: white;
    font-size: 0.7rem;
    font-weight: bold;
    z-index: 2;
    background: rgba(0,0,0,0.4);
    padding: 2px 0;
    /* text placed dynamically via js */
}

.board {
    display: grid;
    grid-template-columns: repeat(8, 1fr);
    grid-template-rows: repeat(8, 1fr);
    width: 100%;
    max-width: 500px;
    aspect-ratio: 1 / 1;
    border: 2px solid #343a40;
    background: #f0d9b5; /* Light square chess color */
    transition: transform 0.3s ease;
}

.board.flipped {
    transform: rotate(180deg);
}

.square {
    width: 100%;
    height: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
    position: relative;
}

.square.dark {
    background-color: #b58863; /* Dark square chess color */
}

.square.dark.highlight {
    background-color: #f6f669; /* Chess.com/NextChessMove style yellow highlight */
}

.square.dark.move-dest {
    background-color: #bacb44;
    cursor: pointer;
}

.piece {
    width: 80%;
    height: 80%;
    border-radius: 50%;
    position: relative;
    cursor: grab;
    z-index: 10;
    box-shadow: 0 2px 4px rgba(0,0,0,0.3);
    transition: transform 0.3s ease;
}

.board.flipped .piece {
    transform: rotate(-180deg);
}

.piece.red {
    background-color: #dc3545; /* Flat red */
    border: 2px solid #a71d2a;
}

.piece.black {
    background-color: #343a40; /* Flat black/dark gray */
    border: 2px solid #212529;
}

.piece.king::after {
    content: "♔";
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 1.8rem;
    font-weight: bold;
    color: rgba(255, 255, 255, 0.9);
}

/* Panel / Controls */
.panel {
    flex: 0.8;
    background: #fff;
    border: 1px solid #dee2e6;
    border-radius: 4px;
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
    box-shadow: 0 1px 3px rgba(0,0,0,0.05);
}

.controls-group {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

label {
    font-size: 0.85rem;
    color: #495057;
    font-weight: 600;
    text-transform: uppercase;
}

select, input[type="range"] {
    width: 100%;
    padding: 0.5rem;
    border: 1px solid #ced4da;
    border-radius: 4px;
    font-size: 1rem;
    color: #495057;
    background-color: #fff;
}

.btn {
    padding: 0.75rem 1rem;
    background: #0d6efd;
    color: white;
    border: none;
    border-radius: 4px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: background-color 0.2s;
}

.btn:hover {
    background: #0b5ed7;
}

.btn-secondary {
    background: #6c757d;
}
.btn-secondary:hover {
    background: #5c636a;
}

.button-row {
    display: flex;
    gap: 0.5rem;
}
.button-row .btn {
    flex: 1;
}

/* Status output box */
.status-panel {
    background: #f8f9fa;
    border: 1px solid #dee2e6;
    border-radius: 4px;
    padding: 1rem;
    font-family: SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
    font-size: 0.9rem;
    color: #212529;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.status-row {
    display: flex;
    justify-content: space-between;
}

.status-value {
    font-weight: bold;
    color: #0d6efd;
}

#status-move {
    cursor: pointer;
    text-decoration: underline;
    text-decoration-style: dotted;
    transition: color 0.2s;
}

#status-move:hover {
    color: #0b5ed7;
}

.editor-palette {
    display: none;
    justify-content: center;
    gap: 0.5rem;
    padding: 1rem;
    background: #f8f9fa;
    border: 1px solid #dee2e6;
    border-radius: 4px;
}

.editor-palette.active {
    display: flex;
}

.palette-item {
    width: 40px;
    height: 40px;
    border-radius: 4px;
    cursor: pointer;
    border: 2px solid transparent;
    display: flex;
    justify-content: center;
    align-items: center;
}

.palette-item.selected {
    border-color: #0d6efd;
    background: #e9ecef;
}

.palette-item .piece {
    width: 80%;
    height: 80%;
}

/* Custom Instant Tooltips */
.tooltip-trigger {
    position: relative;
    border-bottom: 1px dotted #888;
    cursor: help;
}

.tooltip-trigger::after {
    content: attr(data-tooltip);
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    background-color: #343a40;
    color: #fff;
    padding: 0.5rem 0.75rem;
    border-radius: 4px;
    font-size: 0.75rem;
    font-family: -apple-system, sans-serif;
    font-weight: normal;
    white-space: normal;
    width: max-content;
    max-width: 200px;
    text-align: center;
    line-height: 1.3;
    pointer-events: none;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.2s, visibility 0.2s;
    z-index: 100;
    margin-bottom: 8px;
    box-shadow: 0 4px 6px rgba(0,0,0,0.1);
}

.tooltip-trigger::before {
    content: "";
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    border-width: 5px;
    border-style: solid;
    border-color: #343a40 transparent transparent transparent;
    margin-bottom: -2px;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.2s, visibility 0.2s;
    z-index: 100;
}

.tooltip-trigger:hover::after,
.tooltip-trigger:hover::before {
    opacity: 1;
    visibility: visible;
}
