/**
 * VECTOR Game v2.0 - Main Styles
 * Core styles, CSS variables, and layout
 */

/* ============================================
   CSS CUSTOM PROPERTIES (Variables)
   ============================================ */
:root {
    /* Background colors - Deep, rich dark theme */
    --bg-primary: #0a0e14;
    --bg-secondary: #121820;
    --bg-tertiary: #1a222d;
    
    /* Surface colors */
    --surface-dark: rgba(255, 255, 255, 0.03);
    --surface-light: rgba(255, 255, 255, 0.06);
    --surface-hover: rgba(255, 255, 255, 0.08);
    --surface-active: rgba(255, 255, 255, 0.12);
    
    /* Text colors */
    --text-primary: #e8eef7;
    --text-secondary: #9aabb8;
    --text-muted: #5a6a78;
    
    /* Accent colors */
    --accent-blue: #4a9eff;      /* White player */
    --accent-red: #ff6b6b;       /* Black player */
    --accent-gold: #ffc857;      /* Nexus, highlights */
    --accent-green: #4ade80;     /* Legal moves, success */
    --accent-purple: #a78bfa;    /* Special effects */
    
    /* Semantic colors */
    --color-win: #4ade80;
    --color-lose: #ff6b6b;
    --color-warning: #fbbf24;
    --color-info: #60a5fa;
    
    /* Player colors */
    --color-white: #4a9eff;
    --color-white-bg: rgba(74, 158, 255, 0.15);
    --color-black: #ff6b6b;
    --color-black-bg: rgba(255, 107, 107, 0.15);
    
    /* Shadows */
    --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 8px 24px rgba(0, 0, 0, 0.4);
    --shadow-lg: 0 16px 48px rgba(0, 0, 0, 0.5);
    --shadow-glow-blue: 0 0 20px rgba(74, 158, 255, 0.3);
    --shadow-glow-red: 0 0 20px rgba(255, 107, 107, 0.3);
    --shadow-glow-gold: 0 0 30px rgba(255, 200, 87, 0.4);
    --shadow-glow-green: 0 0 15px rgba(74, 222, 128, 0.3);
    
    /* Borders */
    --border-subtle: 1px solid rgba(255, 255, 255, 0.08);
    --border-light: 1px solid rgba(255, 255, 255, 0.12);
    --border-accent: 1px solid rgba(255, 255, 255, 0.15);
    
    /* Animation */
    --transition-fast: 150ms ease;
    --transition-normal: 250ms ease;
    --transition-slow: 400ms ease;
    
    /* Spacing */
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-xl: 24px;
    
    /* Layout */
    --header-height: 64px;
    --panel-width: 320px;
    --board-size: min(540px, calc(100vw - 48px));
    --square-size: calc(var(--board-size) / 9);
    
    /* Font */
    --font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    --font-mono: 'SF Mono', 'Fira Code', 'Consolas', monospace;
}

/* ============================================
   RESET & BASE STYLES
   ============================================ */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    font-size: 16px;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

body {
    font-family: var(--font-family);
    background: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.5;
    min-height: 100vh;
    overflow-x: hidden;
}

/* ============================================
   APP LAYOUT
   ============================================ */
.app {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    background: linear-gradient(135deg, var(--bg-primary) 0%, var(--bg-secondary) 100%);
}

/* ============================================
   HEADER
   ============================================ */
.header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: var(--header-height);
    padding: 0 24px;
    background: var(--bg-secondary);
    border-bottom: var(--border-subtle);
    position: sticky;
    top: 0;
    z-index: 100;
}

.header-left {
    display: flex;
    align-items: baseline;
    gap: 12px;
}

.game-title {
    font-size: 1.75rem;
    font-weight: 700;
    letter-spacing: 0.15em;
    background: linear-gradient(135deg, var(--accent-blue), var(--accent-purple));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.game-subtitle {
    font-size: 0.75rem;
    color: var(--text-muted);
    letter-spacing: 0.1em;
    text-transform: uppercase;
}

.header-center {
    display: flex;
    align-items: center;
    gap: 16px;
}

.turn-indicator, .mode-indicator {
    display: flex;
    align-items: center;
}

.turn-badge {
    padding: 8px 16px;
    border-radius: var(--radius-md);
    font-size: 0.875rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.turn-badge.white {
    background: var(--color-white-bg);
    color: var(--color-white);
    border: 1px solid var(--color-white);
}

.turn-badge.black {
    background: var(--color-black-bg);
    color: var(--color-black);
    border: 1px solid var(--color-black);
}

.mode-badge {
    padding: 6px 12px;
    border-radius: var(--radius-sm);
    font-size: 0.75rem;
    font-weight: 500;
    background: var(--surface-light);
    color: var(--text-secondary);
    border: var(--border-subtle);
}

.header-right {
    display: flex;
    align-items: center;
    gap: 8px;
}

/* ============================================
   MAIN CONTENT
   ============================================ */
.main-content {
    display: grid;
    grid-template-columns: var(--panel-width) 1fr;
    flex: 1;
    overflow: hidden;
}

/* ============================================
   CONTROL PANEL
   ============================================ */
.control-panel {
    display: flex;
    flex-direction: column;
    gap: 16px;
    padding: 16px;
    background: var(--bg-secondary);
    border-right: var(--border-subtle);
    overflow-y: auto;
    max-height: calc(100vh - var(--header-height));
}

.panel-card {
    background: var(--bg-tertiary);
    border-radius: var(--radius-md);
    border: var(--border-subtle);
    overflow: hidden;
}

.panel-header {
    padding: 12px 16px;
    background: var(--surface-dark);
    border-bottom: var(--border-subtle);
}

.panel-header h3 {
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--text-secondary);
}

.panel-body {
    padding: 16px;
}

/* ============================================
   TURN INFO PANEL
   ============================================ */
.turn-number {
    font-size: 2rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 12px;
}

.current-player {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.875rem;
    color: var(--text-secondary);
    margin-bottom: 12px;
}

.player-indicator {
    font-size: 1rem;
}

.mode-selector {
    display: flex;
    gap: 8px;
    margin-bottom: 16px;
}

.btn-mode {
    flex: 1;
    padding: 8px 12px;
    background: var(--surface-dark);
    border: var(--border-subtle);
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    font-size: 0.75rem;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition-fast);
}

.btn-mode:hover {
    background: var(--surface-hover);
}

.btn-mode.active {
    background: var(--accent-blue);
    border-color: var(--accent-blue);
    color: white;
}

.selected-info, .legal-moves-info {
    display: flex;
    justify-content: space-between;
    font-size: 0.8125rem;
    padding: 8px 0;
    border-top: var(--border-subtle);
}

.info-label {
    color: var(--text-muted);
}

.info-value {
    color: var(--text-primary);
    font-weight: 500;
}

/* ============================================
   AI PANEL
   ============================================ */
.checkbox-label {
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    font-size: 0.875rem;
    color: var(--text-primary);
    margin-bottom: 12px;
}

.checkbox-label input[type="checkbox"] {
    width: 18px;
    height: 18px;
    accent-color: var(--accent-blue);
    cursor: pointer;
}

.ai-config {
    margin-top: 12px;
    padding-top: 12px;
    border-top: var(--border-subtle);
}

.form-group {
    margin-bottom: 16px;
}

.form-group label {
    display: block;
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-bottom: 6px;
}

.form-select {
    width: 100%;
    padding: 8px 12px;
    background: var(--surface-dark);
    border: var(--border-subtle);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-size: 0.875rem;
    cursor: pointer;
}

.form-select:focus {
    outline: none;
    border-color: var(--accent-blue);
}

.strength-slider {
    position: relative;
}

.strength-slider input[type="range"] {
    width: 100%;
    height: 4px;
    background: var(--surface-light);
    border-radius: 2px;
    outline: none;
    -webkit-appearance: none;
}

.strength-slider input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 16px;
    height: 16px;
    background: var(--accent-blue);
    border-radius: 50%;
    cursor: pointer;
    transition: transform var(--transition-fast);
}

.strength-slider input[type="range"]::-webkit-slider-thumb:hover {
    transform: scale(1.2);
}

.strength-labels {
    display: flex;
    justify-content: space-between;
    margin-top: 4px;
    font-size: 0.625rem;
    color: var(--text-muted);
}

.strength-desc {
    text-align: center;
    font-size: 0.75rem;
    color: var(--accent-blue);
    margin-top: 8px;
    font-weight: 500;
}

.ai-status {
    margin-top: 12px;
    padding-top: 12px;
    border-top: var(--border-subtle);
}

.ai-thinking {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.8125rem;
    color: var(--accent-blue);
}

.spinner {
    width: 16px;
    height: 16px;
    border: 2px solid var(--surface-light);
    border-top-color: var(--accent-blue);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* ============================================
   VIEW OPTIONS PANEL
   ============================================ */
#panel-view .panel-body {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

#panel-view .checkbox-label {
    margin-bottom: 0;
}

/* ============================================
   GAME LOG PANEL
   ============================================ */
.game-log {
    max-height: 120px;
    overflow-y: auto;
    font-size: 0.75rem;
    font-family: var(--font-mono);
}

.log-entry {
    padding: 6px 0;
    color: var(--text-secondary);
    border-bottom: var(--border-subtle);
}

.log-entry:last-child {
    border-bottom: none;
}

.log-entry.white-move {
    color: var(--color-white);
}

.log-entry.black-move {
    color: var(--color-black);
}

/* ============================================
   MOVE HISTORY PANEL
   ============================================ */
.move-history {
    max-height: 100px;
    overflow-y: auto;
    margin-bottom: 12px;
}

.history-controls {
    display: flex;
    gap: 4px;
    justify-content: center;
}

.history-entry {
    display: flex;
    gap: 8px;
    padding: 4px 0;
    font-size: 0.75rem;
    font-family: var(--font-mono);
}

.history-entry .move-number {
    color: var(--text-muted);
    min-width: 24px;
}

.history-entry .white-move {
    color: var(--color-white);
}

.history-entry .black-move {
    color: var(--color-black);
}

/* ============================================
   BUTTONS
   ============================================ */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 16px;
    border: none;
    border-radius: var(--radius-sm);
    font-family: inherit;
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition-fast);
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.btn-sm {
    padding: 6px 10px;
    font-size: 0.75rem;
}

.btn-lg {
    padding: 14px 24px;
    font-size: 1rem;
}

.btn-icon {
    padding: 8px;
    background: transparent;
    color: var(--text-secondary);
}

.btn-icon:hover {
    background: var(--surface-hover);
    color: var(--text-primary);
}

.btn-icon svg {
    width: 20px;
    height: 20px;
}

.btn-sm.btn-icon svg {
    width: 16px;
    height: 16px;
}

.btn-primary {
    background: var(--accent-blue);
    color: white;
}

.btn-primary:hover:not(:disabled) {
    background: #3a8eef;
    box-shadow: var(--shadow-glow-blue);
}

.btn-secondary {
    background: var(--surface-light);
    color: var(--text-primary);
    border: var(--border-subtle);
}

.btn-secondary:hover:not(:disabled) {
    background: var(--surface-hover);
}

.btn-danger {
    background: var(--accent-red);
    color: white;
}

.btn-danger:hover:not(:disabled) {
    background: #ef5b5b;
}

.btn-block {
    width: 100%;
}

/* ============================================
   BOARD AREA
   ============================================ */
.board-area {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 32px;
    overflow: auto;
}

.board-container {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* ============================================
   AI EXPLANATION PANEL
   ============================================ */
.ai-explanation {
    margin-top: 24px;
    width: 100%;
    max-width: 540px;
    background: var(--bg-tertiary);
    border-radius: var(--radius-md);
    border: var(--border-subtle);
    overflow: hidden;
}

.explanation-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    background: var(--surface-dark);
    border-bottom: var(--border-subtle);
}

.explanation-header h4 {
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--text-secondary);
}

.explanation-body {
    padding: 16px;
    font-size: 0.875rem;
    line-height: 1.6;
    color: var(--text-secondary);
}

.explanation-body strong {
    color: var(--text-primary);
}

/* ============================================
   NOTIFICATIONS
   ============================================ */
.notifications {
    position: fixed;
    bottom: 24px;
    right: 24px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    z-index: 1000;
    pointer-events: none;
}

.notification {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    background: var(--bg-tertiary);
    border-radius: var(--radius-md);
    border: var(--border-subtle);
    box-shadow: var(--shadow-md);
    font-size: 0.875rem;
    color: var(--text-primary);
    pointer-events: auto;
    animation: slideIn 0.3s ease;
}

.notification.success {
    border-left: 3px solid var(--color-win);
}

.notification.error {
    border-left: 3px solid var(--color-lose);
}

.notification.info {
    border-left: 3px solid var(--color-info);
}

.notification.warning {
    border-left: 3px solid var(--color-warning);
}

@keyframes slideIn {
    from {
        transform: translateX(100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

/* ============================================
   SCROLLBAR STYLING
   ============================================ */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

::-webkit-scrollbar-track {
    background: var(--surface-dark);
}

::-webkit-scrollbar-thumb {
    background: var(--surface-hover);
    border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--surface-active);
}

/* ============================================
   SELECTION STYLING
   ============================================ */
::selection {
    background: var(--accent-blue);
    color: white;
}

/* ============================================
   FOCUS STYLING
   ============================================ */
:focus-visible {
    outline: 2px solid var(--accent-blue);
    outline-offset: 2px;
}

button:focus-visible {
    outline-offset: 1px;
}