/**
 * AI Chess Tutor - Styles
 * Color Scheme: Deep Burgundy (#6B1F3D), Soft Beige (#F5E6D3), Golden Yellow (#D4AF37)
 */

@import url('https://fonts.googleapis.com/css2?family=Alegreya:wght@400;500;700&family=Inter:wght@300;400;500;600&display=swap');

:root {
    /* Colors */
    --burgundy: #6B1F3D;
    --burgundy-dark: #4A1529;
    --burgundy-light: #8B2F4D;
    --beige: #F5E6D3;
    --beige-dark: #E5D6C3;
    --gold: #D4AF37;
    --gold-light: #E4BF47;
    --gold-dark: #C49F27;

    /* Board colors */
    --square-light: #F5E6D3;
    --square-dark: #8B6F47;

    /* UI colors */
    --bg-primary: #1A1A1A;
    --bg-secondary: #2A2A2A;
    --text-primary: #F5E6D3;
    --text-secondary: #C4B5A3;

    /* Typography */
    --font-heading: 'Alegreya', serif;
    --font-body: 'Inter', sans-serif;

    /* Spacing */
    --spacing-xs: 0.5rem;
    --spacing-sm: 1rem;
    --spacing-md: 1.5rem;
    --spacing-lg: 2rem;
    --spacing-xl: 3rem;

    /* Transitions */
    --transition-fast: 0.2s ease;
    --transition-normal: 0.3s ease;
    --transition-slow: 0.5s ease;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: var(--font-body);
    background: linear-gradient(135deg, var(--bg-primary) 0%, var(--burgundy-dark) 100%);
    color: var(--text-primary);
    min-height: 100vh;
    padding: var(--spacing-lg);
    overflow-x: hidden;
}

/* Header */
header {
    text-align: center;
    margin-bottom: var(--spacing-xl);
    animation: fadeInDown 0.6s ease;
}

h1 {
    font-family: var(--font-heading);
    font-size: 3.5rem;
    font-weight: 700;
    color: var(--gold);
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.5);
    margin-bottom: var(--spacing-xs);
    letter-spacing: 1px;
}

.subtitle {
    font-family: var(--font-body);
    font-size: 1.1rem;
    color: var(--text-secondary);
    font-weight: 300;
}

/* Main Layout */
.container {
    max-width: 1400px;
    margin: 0 auto;
    display: grid;
    grid-template-columns: 1fr 600px 1fr;
    gap: var(--spacing-lg);
    align-items: start;
}

/* Game Controls */
.game-controls {
    background: rgba(42, 42, 42, 0.8);
    backdrop-filter: blur(10px);
    border-radius: 16px;
    padding: var(--spacing-lg);
    border: 1px solid rgba(212, 175, 55, 0.2);
    animation: fadeInLeft 0.6s ease;
}

.control-section {
    margin-bottom: var(--spacing-lg);
}

.control-section:last-child {
    margin-bottom: 0;
}

.control-section h2 {
    font-family: var(--font-heading);
    font-size: 1.5rem;
    color: var(--gold);
    margin-bottom: var(--spacing-sm);
}

.mode-selector,
.color-selector {
    display: flex;
    gap: var(--spacing-sm);
    flex-wrap: wrap;
}

.btn {
    font-family: var(--font-body);
    padding: var(--spacing-sm) var(--spacing-md);
    border: 2px solid var(--burgundy);
    background: transparent;
    color: var(--text-primary);
    border-radius: 8px;
    cursor: pointer;
    font-size: 0.95rem;
    font-weight: 500;
    transition: all var(--transition-normal);
    position: relative;
    overflow: hidden;
}

.btn::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    border-radius: 50%;
    background: var(--burgundy);
    transform: translate(-50%, -50%);
    transition: width var(--transition-normal), height var(--transition-normal);
    z-index: -1;
}

.btn:hover::before {
    width: 300px;
    height: 300px;
}

.btn:hover {
    border-color: var(--gold);
    color: var(--gold);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(212, 175, 55, 0.3);
}

.btn.active {
    background: var(--burgundy);
    border-color: var(--gold);
    color: var(--gold);
    box-shadow: 0 0 20px rgba(212, 175, 55, 0.4);
}

.btn-primary {
    background: linear-gradient(135deg, var(--burgundy), var(--burgundy-light));
    border-color: var(--gold);
    color: var(--gold);
    width: 100%;
    margin-top: var(--spacing-sm);
}

.btn-primary:hover {
    background: linear-gradient(135deg, var(--burgundy-light), var(--burgundy));
    box-shadow: 0 6px 20px rgba(212, 175, 55, 0.4);
}

/* Game Info */
.game-info {
    background: rgba(42, 42, 42, 0.6);
    backdrop-filter: blur(10px);
    border-radius: 12px;
    padding: var(--spacing-md);
    margin-bottom: var(--spacing-md);
    border: 1px solid rgba(212, 175, 55, 0.15);
}

.info-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: var(--spacing-sm);
}

.info-row:last-child {
    margin-bottom: 0;
}

.info-label {
    font-size: 0.9rem;
    color: var(--text-secondary);
}

.turn-indicator {
    padding: 0.4rem 1rem;
    border-radius: 20px;
    font-weight: 600;
    font-size: 0.9rem;
}

.turn-indicator.white {
    background: linear-gradient(135deg, var(--beige), var(--beige-dark));
    color: var(--burgundy);
}

.turn-indicator.black {
    background: linear-gradient(135deg, #333, #555);
    color: var(--gold);
}

/* Chess Board */
.board-wrapper {
    position: relative;
    animation: fadeInUp 0.6s ease;
}

#board-container {
    position: relative;
    width: 600px;
    height: 600px;
    margin: 0 auto;
}

.chess-board {
    display: grid;
    grid-template-columns: repeat(8, 1fr);
    grid-template-rows: repeat(8, 1fr);
    width: 600px;
    height: 600px;
    max-width: 100%;
    max-height: 100%;
    aspect-ratio: 1 / 1;
    border: 4px solid var(--gold);
    border-radius: 8px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.6),
        0 0 60px rgba(212, 175, 55, 0.2);
    overflow: hidden;
    user-select: none;
}

.square {
    position: relative;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background-color var(--transition-fast);
    cursor: pointer;
    overflow: hidden;
    min-width: 0;
    min-height: 0;
}

.square.light {
    background-color: var(--square-light);
}

.square.dark {
    background-color: var(--square-dark);
}

.square:hover {
    filter: brightness(1.1);
}

.square.selected {
    background-color: var(--gold) !important;
    box-shadow: inset 0 0 20px rgba(107, 31, 61, 0.5);
}

.square.legal-move {
    background-color: rgba(212, 175, 55, 0.3) !important;
}

.square.legal-move::after {
    content: '';
    position: absolute;
    width: 30%;
    height: 30%;
    background: var(--gold);
    border-radius: 50%;
    opacity: 0.6;
}

.square.legal-move:has(.piece)::after {
    width: 90%;
    height: 90%;
    background: transparent;
    border: 3px solid var(--gold);
    border-radius: 50%;
}

.square.last-move {
    background-color: rgba(212, 175, 55, 0.2) !important;
}

.square.in-check {
    background-color: rgba(255, 50, 50, 0.5) !important;
    animation: pulse 1s infinite;
}

.square.suggested {
    background-color: rgba(100, 200, 100, 0.3) !important;
    box-shadow: inset 0 0 15px rgba(100, 200, 100, 0.5);
}

/* Chess Pieces */
.piece {
    font-size: 3.5rem;
    line-height: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: grab;
    user-select: none;
    transition: transform var(--transition-fast);
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.5);
    z-index: 10;
    width: 100%;
    height: 100%;
}

.piece.white {
    color: var(--beige);
    filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.6));
}

.piece.black {
    color: var(--burgundy-dark);
    filter: drop-shadow(0 2px 4px rgba(212, 175, 55, 0.3));
}

.piece:hover {
    transform: scale(1.1);
}

.piece.dragging {
    opacity: 0.5;
    cursor: grabbing;
}

/* Coordinate Labels */
.file-labels,
.rank-labels {
    position: absolute;
    display: flex;
    font-family: var(--font-body);
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--gold);
}

.file-labels {
    bottom: -30px;
    left: 4px;
    right: 4px;
    justify-content: space-around;
}

.file-labels span {
    width: calc(100% / 8);
    text-align: center;
}

.rank-labels {
    top: 4px;
    left: -30px;
    bottom: 4px;
    flex-direction: column;
    justify-content: space-around;
}

.rank-labels span {
    height: calc(100% / 8);
    display: flex;
    align-items: center;
}

/* Side Panel */
.side-panel {
    background: rgba(42, 42, 42, 0.8);
    backdrop-filter: blur(10px);
    border-radius: 16px;
    padding: var(--spacing-lg);
    border: 1px solid rgba(212, 175, 55, 0.2);
    animation: fadeInRight 0.6s ease;
}

.panel-section {
    margin-bottom: var(--spacing-lg);
}

.panel-section:last-child {
    margin-bottom: 0;
}

.panel-section h2 {
    font-family: var(--font-heading);
    font-size: 1.5rem;
    color: var(--gold);
    margin-bottom: var(--spacing-sm);
}

/* Move History */
#move-history {
    max-height: 200px;
    overflow-y: auto;
    background: rgba(0, 0, 0, 0.3);
    border-radius: 8px;
    padding: var(--spacing-sm);
}

.move-item {
    padding: 0.4rem 0.6rem;
    margin-bottom: 0.3rem;
    background: rgba(212, 175, 55, 0.1);
    border-radius: 4px;
    font-family: 'Courier New', monospace;
    font-size: 0.9rem;
    transition: background var(--transition-fast);
}

.move-item:hover {
    background: rgba(212, 175, 55, 0.2);
}

.move-number {
    color: var(--gold);
    font-weight: 600;
    margin-right: 0.5rem;
}

/* Suggestion Panel */
#suggestion-panel {
    background: rgba(0, 0, 0, 0.3);
    border-radius: 8px;
    padding: var(--spacing-md);
    min-height: 150px;
}

.suggestion-move {
    font-size: 1.1rem;
    color: var(--gold);
    margin-bottom: var(--spacing-sm);
    font-weight: 600;
}

.suggestion-reasoning {
    line-height: 1.6;
    color: var(--text-secondary);
}

.loading {
    text-align: center;
    color: var(--gold);
    font-style: italic;
    animation: pulse 1.5s infinite;
}

/* Error Message */
#error-message {
    display: none;
    position: fixed;
    top: 20px;
    right: 20px;
    background: rgba(255, 50, 50, 0.9);
    color: white;
    padding: var(--spacing-md);
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
    z-index: 1000;
    animation: slideInRight 0.3s ease;
}

/* Game Over Modal */
.game-over-modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.8);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2000;
    animation: fadeIn 0.3s ease;
}

.modal-content {
    background: linear-gradient(135deg, var(--burgundy-dark), var(--burgundy));
    padding: var(--spacing-xl);
    border-radius: 16px;
    border: 2px solid var(--gold);
    text-align: center;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.6);
    animation: scaleIn 0.3s ease;
}

.modal-content h2 {
    font-family: var(--font-heading);
    font-size: 2.5rem;
    color: var(--gold);
    margin-bottom: var(--spacing-md);
}

.modal-content p {
    font-size: 1.2rem;
    margin-bottom: var(--spacing-lg);
}

.modal-content button {
    padding: var(--spacing-md) var(--spacing-xl);
    font-size: 1.1rem;
    background: var(--gold);
    color: var(--burgundy-dark);
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 600;
    transition: all var(--transition-normal);
}

.modal-content button:hover {
    background: var(--gold-light);
    transform: scale(1.05);
    box-shadow: 0 4px 12px rgba(212, 175, 55, 0.5);
}

/* Scrollbar Styling */
::-webkit-scrollbar {
    width: 8px;
}

::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.2);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb {
    background: var(--gold);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--gold-light);
}

/* Animations */
@keyframes fadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

@keyframes fadeInDown {
    from {
        opacity: 0;
        transform: translateY(-30px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(30px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes fadeInLeft {
    from {
        opacity: 0;
        transform: translateX(-30px);
    }

    to {
        opacity: 1;
        transform: translateX(0);
    }
}

@keyframes fadeInRight {
    from {
        opacity: 0;
        transform: translateX(30px);
    }

    to {
        opacity: 1;
        transform: translateX(0);
    }
}

@keyframes slideInRight {
    from {
        transform: translateX(100%);
    }

    to {
        transform: translateX(0);
    }
}

@keyframes scaleIn {
    from {
        transform: scale(0.8);
        opacity: 0;
    }

    to {
        transform: scale(1);
        opacity: 1;
    }
}

@keyframes pulse {

    0%,
    100% {
        opacity: 1;
    }

    50% {
        opacity: 0.6;
    }
}

/* Responsive Design */
@media (max-width: 1400px) {
    .container {
        grid-template-columns: 1fr;
        max-width: 700px;
    }

    .game-controls,
    .side-panel {
        max-width: 600px;
        margin: 0 auto var(--spacing-lg);
    }
}

@media (max-width: 768px) {
    h1 {
        font-size: 2.5rem;
    }

    #board-container {
        width: 100%;
        height: auto;
        aspect-ratio: 1;
    }

    .chess-board {
        width: 100%;
        height: 100%;
    }

    .piece {
        font-size: 2.5rem;
    }

    .container {
        padding: var(--spacing-sm);
    }
}