/* Global Variables
   Define reusable values for consistent styling */
:root {
    --board-max-width: 600px;
    --animation-duration: 0.5s;
    --progress-stripe-size: 1rem;
}

/* Layout & Container Styles
   Core structural elements */
.container {
    max-width: var(--board-max-width);
    width: 100%;
    margin: 0 auto;
}

/* Chessboard Component
   Main game display area */
.chessboard-wrapper {
    width: 100%;
    max-width: var(--board-max-width);
    aspect-ratio: 1;
    position: relative;
}

/* Input Elements
   Form controls and user input styling */
#pgnInput {
    font-family: monospace;
    resize: none;
}

#pgnInput::placeholder {
    color: rgba(255, 255, 255, 0.5);
}

/* Analysis Components
   Evaluation display and move analysis elements */
#evaluationChart {
    min-height: 200px;
    max-height: 300px;
}

.move-cell {
    font-family: monospace;
    white-space: nowrap;
}

.eval-positive {
    color: var(--bs-success);
}

.eval-negative {
    color: var(--bs-danger);
}

/* Progress Indicators
   Loading and progress visualization */
.progress {
    height: 1.2rem;
    border-radius: 0.6rem;
    background-color: rgba(255, 255, 255, 0.1);
    box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.1);
}

.progress-bar {
    transition: width var(--animation-duration) ease;
    background-image: linear-gradient(45deg,
            rgba(255, 255, 255, 0.15) 25%,
            transparent 25%,
            transparent 50%,
            rgba(255, 255, 255, 0.15) 50%,
            rgba(255, 255, 255, 0.15) 75%,
            transparent 75%,
            transparent);
    background-size: var(--progress-stripe-size) var(--progress-stripe-size);
    animation: progress-bar-stripes 1s linear infinite;
}

.progress-bar.complete {
    animation: none;
    background-image: none;
}

/* Animation Definitions
   Custom keyframe animations */
@keyframes progress-bar-stripes {
    from {
        background-position: var(--progress-stripe-size) 0;
    }

    to {
        background-position: 0 0;
    }
}

/* Responsive Adaptations
   Mobile and smaller screen adjustments */
@media (max-width: 768px) {
    .chessboard-wrapper {
        width: 100%;
        max-width: 100%;
    }
}

/* Accessibility Enhancements
   Focus states and interaction improvements */
.btn:focus {
    box-shadow: 0 0 0 0.25rem rgba(255, 255, 255, 0.25);
    outline: none;
}

.btn:focus-visible {
    outline: 3px solid #fff;
    outline-offset: 2px;
}

/* Bootstrap Framework Customization
   Override default Bootstrap styles */
.tooltip {
    --bs-tooltip-bg: rgba(0, 0, 0, 0.9);
    --bs-tooltip-color: #fff;
    --bs-tooltip-padding-x: 1rem;
    --bs-tooltip-padding-y: 0.5rem;
    font-size: 0.875rem;
}

.btn:disabled {
    opacity: 0.65;
    cursor: not-allowed;
}

/* Status Icons */
.status-icon {
    font-size: 1.2rem;
}

.status-perfect {
    color: #ffc107;
}

.status-blunder {
    color: #ea868f;
}

.status-mistake {
    color: #feb272;
}

.status-inaccuracy {
    color: #c29ffa;
}

.status-slight-inaccuracy {
    color: #6ea8fe;
}

.status-good {
    color: #75b798;
}

/* Analysis Table Mobile Optimization */
#analysisTable {
    min-width: 600px;
    /* Ensure minimum width for scrolling */
}

.table-scroll-indicator {
    display: none;
    text-align: center;
    padding: 0.5rem;
    color: rgba(255, 255, 255, 0.6);
    font-size: 0.875rem;
}

/* Add swipe animation */
@keyframes swipeHint {
    0% {
        transform: translateX(-10px);
        opacity: 0.5;
    }

    50% {
        transform: translateX(10px);
        opacity: 1;
    }

    100% {
        transform: translateX(-10px);
        opacity: 0.5;
    }
}

.swipe-hint {
    animation: swipeHint 2s ease-in-out infinite;
}

/* Position Preview Styles */
.preview-board {
    width: 160px;
    height: 160px;
    background: #fff;
    border-radius: 4px;
    overflow: hidden;
}

.fen-actions {
    display: flex;
    gap: 0.25rem;
    justify-content: center;
}

.fen-btn {
    padding: 0.25rem 0.5rem;
    font-size: 0.875rem;
}

/* Custom tooltip for board preview */
.board-preview-tooltip {
    position: absolute;
    z-index: 1080;
    background: #fff;
    border-radius: 4px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.25);
    padding: 4px;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.15s;
}

.board-preview-tooltip.show {
    opacity: 1;
}

/* Mobile Optimizations */
@media (max-width: 768px) {
    .table-scroll-indicator {
        display: block;
    }

    #analysisTable {
        font-size: 0.875rem;
    }

    #analysisTable th,
    #analysisTable td {
        padding: 0.5rem 0.25rem;
    }

    /* Optimize column widths for mobile */
    #analysisTable .move-number-col {
        width: 2rem;
    }

    #analysisTable .side-col {
        width: 4rem;
    }

    #analysisTable .status-col {
        width: 2.5rem;
    }

    #analysisTable .move-cell {
        width: 4rem;
    }

    #analysisTable .eval-col {
        width: 3.5rem;
    }

    /* Hide less important content on very small screens */
    @media (max-width: 360px) {
        .side-col {
            display: none !important;
        }
    }

    /* Adjust column widths */
    #analysisTable .fen-col {
        width: 5rem;
    }
}

/* Game analyzer mobile optimizations */
@media (max-width: 576px) {

    /* Compact header for mobile */
    .game-analyzer .navbar {
        padding: 0.25rem 0;
        min-height: auto;
    }

    .game-analyzer .navbar .container {
        padding: 0 0.5rem;
    }

    /* Optimize board container */
    .game-analyzer .chessboard-wrapper {
        margin-bottom: 0.25rem;
    }

    /* Optimize button sizing */
    .game-analyzer .btn {
        padding: 0.25rem 0.5rem;
    }

    /* Reduce overall spacing */
    .game-analyzer main {
        padding-top: 0.25rem;
        padding-bottom: 0.25rem;
    }

    /* More compact controls */
    .game-analyzer .card-body {
        padding: 0.5rem;
    }

    .game-analyzer .row {
        margin-right: -0.25rem;
        margin-left: -0.25rem;
    }

    .game-analyzer .col-3,
    .game-analyzer .col-4,
    .game-analyzer .col-12 {
        padding-right: 0.25rem;
        padding-left: 0.25rem;
    }

    .game-analyzer .g-1 {
        --bs-gutter-y: 0.25rem;
    }

    /* Make input area smaller */
    .game-analyzer #pgnInput {
        padding: 0.25rem;
        font-size: 0.875rem;
        min-height: 2.5rem;
    }

    /* Make footer ultra compact */
    .game-analyzer footer {
        padding-top: 0.125rem !important;
        padding-bottom: 0.125rem !important;
    }
}