/* Chess Elegante - Play Page Specific Styles */

/* Main Content */
.main-content {
    margin-top: 56px;
    padding: 0;
    max-width: 1400px;
    margin-left: auto;
    margin-right: auto;
}

/* ============================================
   GAME CONTROLS BAR
   ============================================ */
.game-controls-bar {
    background: white;
    border-bottom: 1px solid #e8e8e8;
    padding: 12px 16px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: sticky;
    top: 56px;
    z-index: 100;
}

.game-status-indicator {
    display: flex;
    align-items: center;
    gap: 12px;
}

.status-dot {
    width: 8px;
    height: 8px;
    background: #10b981;
    border-radius: 50%;
    animation: pulse 2s cubic-bezier(0.4, 0, 0.6, 1) infinite;
}

@keyframes pulse {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0.5;
    }
}

.game-status-indicator span {
    font-size: 14px;
    color: #57534e;
    font-family: 'Helvetica Neue', sans-serif;
}

.game-action-buttons {
    display: flex;
    gap: 8px;
}

.game-ctrl-btn {
    padding: 8px;
    border-radius: 8px;
    background: #f5f5f4;
    border: none;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #57534e;
}

.game-ctrl-btn:hover {
    background: #e7e5e4;
}

.game-ctrl-btn-danger {
    background: #fef2f2;
    color: #dc2626;
}

.game-ctrl-btn-danger:hover {
    background: #fee2e2;
}

/* Mobile: Position game controls bar correctly */
@media (max-width: 767px) {
    .game-controls-bar {
        top: 56px; /* Below main nav */
    }
}

/* Desktop: Hide game controls bar, show as normal panels */
@media (min-width: 768px) {
    .game-controls-bar {
        display: none;
    }
}

/* ============================================
   DESKTOP/MOBILE VISIBILITY
   ============================================ */
.desktop-only {
    display: none;
}

@media (min-width: 768px) {
    .desktop-only {
        display: block;
    }

    .main-content {
        margin-top: 64px;
        padding: 40px;
    }
}

/* ============================================
   SHARED PANEL STYLES
   ============================================ */
.panel-section {
    background: #fafafa;
    border: 1px solid #e8e8e8;
}

.panel-title {
    font-size: 12px;
    letter-spacing: 2px;
    text-transform: uppercase;
    font-family: 'Helvetica Neue', sans-serif;
    margin-bottom: 20px;
    font-weight: 300;
    border-bottom: 1px solid #e8e8e8;
    padding-bottom: 15px;
}

/* ============================================
   MOBILE BOTTOM TABS
   ============================================ */
.mobile-bottom-tabs {
    display: none; /* Hidden by default, shown on mobile */
}

@media (max-width: 767px) {
    .mobile-bottom-tabs {
        display: block;
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        background: white;
        border-top: 1px solid #e8e8e8;
        z-index: 99; /* Below main nav (1000) but above content */
        padding-bottom: env(safe-area-inset-bottom);
        max-height: 50vh;
        transition: max-height 0.3s ease;
        box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.1);
    }

    .mobile-bottom-tabs.collapsed {
        max-height: 56px; /* Ensure buttons are always visible */
        overflow: hidden;
    }

    /* Hide left and right panels on mobile - content will show in tabs */
    .left-panel,
    .right-panel {
        display: none !important;
    }

    .bottom-tab-buttons {
        display: flex;
        gap: 4px;
        padding: 8px;
        background: white;
        position: sticky;
        top: 0;
        z-index: 10;
        border-bottom: 1px solid #e8e8e8;
        min-height: 56px; /* Ensure buttons area has minimum height */
    }

    .tab-btn {
        flex: 1;
        padding: 10px 12px;
        border-radius: 8px;
        background: #f5f5f4;
        border: none;
        cursor: pointer;
        font-size: 14px;
        font-weight: 500;
        font-family: 'Helvetica Neue', sans-serif;
        color: #57534e;
        transition: all 0.2s;
    }

    .tab-btn.active {
        background: #1a1a1a;
        color: white;
    }

    .bottom-tab-content {
        background: white;
        padding: 16px;
        max-height: calc(50vh - 48px);
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
    }

    .tab-panel {
        display: none;
    }

    .tab-panel.active {
        display: block;
    }
}

.page-title {
    font-size: 48px;
    font-weight: 300;
    text-align: center;
    margin-bottom: 20px;
    letter-spacing: -1px;
}

.page-subtitle {
    font-size: 16px;
    font-family: 'Helvetica Neue', sans-serif;
    font-weight: 300;
    color: #666;
    text-align: center;
    margin-bottom: 60px;
    letter-spacing: 0.5px;
}

/* Game Section */
.game-section {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 8px;
}

@media (min-width: 768px) {
    .game-section {
        display: grid;
        grid-template-columns: 300px 600px 1fr;
        gap: 40px;
        align-items: start;
        padding: 0;
    }
}

/* Left Panel */
.left-panel {
    display: flex;
    flex-direction: column;
    gap: 30px;
}

.status-panel {
    padding: 30px;
    background: #fafafa;
    border: 1px solid #e8e8e8;
}

.status-panel h3 {
    font-size: 12px;
    letter-spacing: 2px;
    text-transform: uppercase;
    font-family: 'Helvetica Neue', sans-serif;
    margin-bottom: 20px;
    font-weight: 300;
    border-bottom: 1px solid #e8e8e8;
    padding-bottom: 15px;
}

.panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid #e8e8e8;
    padding-bottom: 15px;
    margin-bottom: 20px;
}

.panel-header h3 {
    font-size: 12px;
    font-weight: 300;
    letter-spacing: 2px;
    text-transform: uppercase;
    font-family: 'Helvetica Neue', sans-serif;
    margin: 0;
}

.status-controls {
    display: flex;
    gap: 8px;
    align-items: center;
}

.icon-btn {
    width: 32px;
    height: 32px;
    padding: 0;
    background: white;
    border: 1px solid #e8e8e8;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #1a1a1a;
    position: relative;
}

.icon-btn:hover {
    background: #1a1a1a;
    border-color: #1a1a1a;
    color: white;
}

.icon-btn-danger {
    background: #1a1a1a;
    border-color: #1a1a1a;
    color: white;
}

.icon-btn-danger:hover {
    background: #333;
    border-color: #333;
}

.icon-btn svg {
    pointer-events: none;
}

/* Tooltip styling */
.icon-btn .tooltip {
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%) translateY(-8px);
    background: #1a1a1a;
    color: white;
    padding: 6px 12px;
    font-size: 11px;
    font-family: 'Helvetica Neue', sans-serif;
    letter-spacing: 0.5px;
    white-space: nowrap;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s;
    z-index: 1000;
}

.icon-btn .tooltip::after {
    content: '';
    position: absolute;
    top: 100%;
    left: 50%;
    transform: translateX(-50%);
    border: 4px solid transparent;
    border-top-color: #1a1a1a;
}

.icon-btn:hover .tooltip {
    opacity: 1;
}

.status-message {
    text-align: center;
    padding: 20px;
    background: white;
    border: 1px solid #e8e8e8;
    font-family: 'Courier New', monospace;
    font-size: 14px;
    letter-spacing: 0.5px;
    min-height: 80px;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Center Panel */
.center-panel {
    display: flex;
    flex-direction: column;
    gap: 30px;
    align-items: center;
}

.status-message.info {
    background: #f0f0f0;
    color: #1a1a1a;
    border-color: #d0d0d0;
}

.status-message.success {
    background: #fafafa;
    color: #1a1a1a;
    border-color: #1a1a1a;
}

.status-message.error {
    background: #1a1a1a;
    color: white;
    border-color: #1a1a1a;
}

.status-message.warning {
    background: #f5f5f5;
    color: #1a1a1a;
    border-color: #d0d0d0;
}

.board-container {
    display: flex;
    justify-content: center;
    padding: 8px;
    background: white;
    border: 1px solid #e8e8e8;
    border-radius: 12px;
    width: 100%;
    max-width: 400px;
    margin: 0 auto;
}

#board {
    width: 100% !important;
    max-width: 400px;
}

@media (min-width: 768px) {
    .board-container {
        padding: 20px;
        background: #fafafa;
        max-width: none;
        width: auto;
    }

    #board {
        width: 480px !important;
        box-shadow: 0 10px 40px rgba(0,0,0,0.1);
    }
}

/* Click-to-move styling */
/* Enable pointer events on pieces so clicks are detected */
#board img {
    pointer-events: auto !important;
    cursor: pointer;
}

.selected-square {
    box-shadow: inset 0 0 0 3px rgba(26, 26, 26, 0.5) !important;
    background-color: rgba(255, 255, 100, 0.4) !important;
}

.move-hint {
    position: absolute;
    width: 25%;
    height: 25%;
    background-color: rgba(26, 26, 26, 0.3);
    border-radius: 50%;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    pointer-events: none;
    z-index: 10;
}

.move-hint.capture-hint {
    width: 80%;
    height: 80%;
    background-color: transparent;
    border: 3px solid rgba(26, 26, 26, 0.4);
}

/* Commentary Panel */
.commentary-panel {
    width: 100%;
    overflow: hidden;
    transition: all 0.3s ease;
    margin-top: 30px;
}

@media (min-width: 768px) {
    .commentary-panel {
        max-width: 600px;
    }
}

.commentary-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 30px;
    background: #f5f5f5;
    border-bottom: 1px solid #e8e8e8;
    cursor: pointer;
    user-select: none;
}

.commentary-header:hover {
    background: #f0f0f0;
}

.commentary-header h3 {
    font-size: 12px;
    letter-spacing: 2px;
    text-transform: uppercase;
    font-family: 'Helvetica Neue', sans-serif;
    font-weight: 300;
    margin: 0;
}

.btn-collapse {
    background: none;
    border: none;
    font-size: 24px;
    font-weight: 300;
    color: #666;
    cursor: pointer;
    padding: 0;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.btn-collapse:hover {
    color: #1a1a1a;
    transform: scale(1.1);
}

.commentary-content {
    padding: 30px;
    background: white;
    max-height: 400px;
    overflow-y: auto;
    transition: max-height 0.3s ease;
}

.commentary-content.collapsed {
    max-height: 0;
    padding: 0 30px;
    overflow: hidden;
}

.commentary-text-content {
    font-family: 'Georgia', serif;
    font-size: 15px;
    line-height: 1.8;
    color: #2c2c2c;
    font-style: italic;
    margin: 0;
    text-align: justify;
}

.commentary-loading {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    color: #666;
    font-family: 'Helvetica Neue', sans-serif;
    font-size: 14px;
    font-style: normal;
    padding: 20px 0;
}

.spinner {
    width: 20px;
    height: 20px;
    border: 2px solid #e8e8e8;
    border-top: 2px solid #1a1a1a;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.right-panel {
    display: flex;
    flex-direction: column;
    gap: 30px;
}

.move-history-panel {
    padding: 30px;
}

@media (min-width: 768px) {
    .move-history-panel {
        max-height: 500px;
        overflow-y: auto;
    }
}

/* Analysis Panel */
.analysis-panel {
    padding: 30px;
}

.btn-analyze {
    width: 100%;
    padding: 12px;
    border-radius: 8px;
    border: 2px solid #1a1a1a;
    background: white;
    font-size: 14px;
    font-weight: 500;
    font-family: 'Helvetica Neue', sans-serif;
    cursor: pointer;
    transition: all 0.2s;
    margin-bottom: 20px;
}

.btn-analyze:hover {
    background: #1a1a1a;
    color: white;
}

.analysis-display {
    margin-top: 20px;
    font-family: 'Helvetica Neue', sans-serif;
    font-size: 14px;
    line-height: 1.8;
}

.analysis-item {
    padding: 15px;
    margin-bottom: 10px;
    background: white;
    border: 1px solid #e8e8e8;
}

.analysis-evaluation {
    font-size: 18px;
    font-weight: 300;
    margin-bottom: 10px;
    font-family: 'Courier New', monospace;
}

.analysis-best-move {
    font-family: 'Courier New', monospace;
    font-size: 16px;
    margin-top: 5px;
}

.analysis-pv {
    font-size: 12px;
    color: #666;
    margin-top: 8px;
    font-family: 'Courier New', monospace;
}

.analysis-loading {
    text-align: center;
    padding: 20px;
    color: #666;
    font-style: italic;
}

.evaluation-positive {
    color: #2d7a2d;
}

.evaluation-negative {
    color: #a63939;
}

.evaluation-neutral {
    color: #666;
}

/* Move Evaluation Display */
.move-evaluation {
    margin-top: 20px;
    border: 1px solid #e8e8e8;
    background: white;
    overflow: hidden;
}

.move-eval-header {
    padding: 15px 20px;
    color: white;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 10px;
}

.eval-icon {
    font-size: 20px;
    font-weight: bold;
}

.eval-label {
    font-family: 'Helvetica Neue', sans-serif;
    font-size: 14px;
    letter-spacing: 1px;
    text-transform: uppercase;
}

.move-eval-body {
    padding: 20px;
}

.eval-detail {
    display: flex;
    justify-content: space-between;
    padding: 10px 0;
    border-bottom: 1px solid #f0f0f0;
    font-family: 'Helvetica Neue', sans-serif;
}

.eval-detail:last-child {
    border-bottom: none;
}

.eval-detail-label {
    color: #666;
    font-size: 13px;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.eval-detail-value {
    font-family: 'Courier New', monospace;
    font-size: 16px;
    font-weight: 500;
    color: #1a1a1a;
}

/* AI Commentary Styling */
.eval-commentary {
    padding: 15px;
    background: #f8f9fa;
    border-left: 3px solid #1a1a1a;
    margin-bottom: 15px;
    font-family: 'Georgia', serif;
    line-height: 1.6;
}

.commentary-label {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: 8px;
    color: #666;
    font-family: 'Helvetica Neue', sans-serif;
}

.commentary-text {
    font-size: 14px;
    color: #2c2c2c;
    font-style: italic;
}

/* Settings Modal */
.modal {
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-content {
    background: white;
    width: 90%;
    max-width: 500px;
    border: 1px solid #e8e8e8;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    animation: modalSlideIn 0.3s ease;
}

@keyframes modalSlideIn {
    from {
        opacity: 0;
        transform: translateY(-50px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 30px 40px;
    border-bottom: 1px solid #e8e8e8;
    background: #fafafa;
}

.modal-header h3 {
    font-size: 14px;
    letter-spacing: 2px;
    text-transform: uppercase;
    font-family: 'Helvetica Neue', sans-serif;
    font-weight: 300;
    margin: 0;
}

.close-modal {
    font-size: 28px;
    font-weight: 300;
    color: #666;
    cursor: pointer;
    transition: color 0.2s;
    line-height: 1;
}

.close-modal:hover {
    color: #1a1a1a;
}

.modal-body {
    padding: 40px;
}

.setting-group {
    margin-bottom: 30px;
}

.setting-group:last-child {
    margin-bottom: 0;
}

.setting-group label {
    display: block;
    margin-bottom: 12px;
    font-family: 'Helvetica Neue', sans-serif;
    font-size: 12px;
    letter-spacing: 2px;
    text-transform: uppercase;
    font-weight: 300;
    color: #666;
}

.setting-group select {
    width: 100%;
    padding: 12px 15px;
    border: 1px solid #e8e8e8;
    background: #fafafa;
    font-size: 14px;
    font-family: 'Helvetica Neue', sans-serif;
    cursor: pointer;
    transition: all 0.2s;
}

.setting-group select:hover {
    border-color: #1a1a1a;
    background: white;
}

.setting-group select:focus {
    outline: none;
    border-color: #1a1a1a;
    background: white;
}

.modal-footer {
    padding: 30px 40px;
    border-top: 1px solid #e8e8e8;
    background: #fafafa;
    display: flex;
    justify-content: flex-end;
    gap: 10px;
}

footer {
    margin-top: 80px;
}

/* Responsive */
@media (max-width: 1200px) {
    .game-section {
        grid-template-columns: 1fr;
        gap: 40px;
    }

    .main-content {
        padding: 40px 30px;
    }

    #board {
        width: 100% !important;
        max-width: 560px;
    }

    .left-panel {
        order: 2;
    }

    .center-panel {
        order: 1;
    }

    .right-panel {
        order: 3;
    }
}

@media (max-width: 767px) {
    .main-content {
        margin-top: 0;
        padding: 0;
        padding-top: calc(56px + 49px); /* Height of main nav + game controls bar */
        padding-bottom: 250px; /* Space for bottom tabs + extra buffer to prevent cutoff */
        min-height: 100vh;
        overflow-x: hidden;
    }

    .page-title {
        font-size: 32px;
        margin-bottom: 15px;
    }

    .page-subtitle {
        font-size: 14px;
        margin-bottom: 30px;
    }

    .game-section {
        gap: 0;
        padding: 8px;
        margin-bottom: 100px; /* Extra space to prevent board from being cut off */
    }

    /* Center the board on mobile */
    .center-panel {
        width: 100%;
        padding: 0;
        margin-bottom: 20px; /* Space between board and bottom tabs */
    }

    /* Maximize board size on mobile */
    .board-container {
        padding: 8px;
        background: white;
        border: 1px solid #e8e8e8;
        border-radius: 12px;
        margin: 0 auto;
    }

    #board {
        width: 100% !important;
        max-width: 100%;
    }

    /* Hide tooltips on mobile */
    .icon-btn .tooltip {
        display: none;
    }

    /* Modal adjustments */
    .commentary-header,
    .commentary-content,
    .modal-body {
        padding: 15px;
    }

    .modal-header,
    .modal-footer {
        padding: 20px;
    }

    /* Commentary panel - reduce padding on mobile */
    .commentary-panel {
        margin-top: 20px;
        padding: 0;
    }

    .commentary-panel .panel-title {
        display: none;
    }

    .commentary-content {
        max-height: 200px;
    }

    /* Analysis and move panels - reduce padding */
    .analysis-panel,
    .move-history-panel {
        padding: 0;
        border: none;
        background: transparent;
    }

    .panel-title {
        font-size: 11px;
        margin-bottom: 15px;
        padding-bottom: 10px;
    }
}

@media (max-width: 480px) {
    .main-content {
        padding: 8px;
    }

    .page-title {
        font-size: 24px;
    }

    .page-subtitle {
        font-size: 12px;
    }

    .board-container {
        padding: 5px;
    }
}
