/* static/css/style.css */
/* AI-Comment: Base styles for a full-screen, flexbox-based layout. */
html, body {
    margin: 0;
    padding: 0;
    width: 100%;
    height: 100%;
    overflow: hidden;
    font-family: sans-serif;
    background-color: #262421; /* Darker background for more focus on the game */
    color: white;
}

/* AI-Comment: Main container using Flexbox to manage the board and chat panel. */
.main-container {
    display: flex;
    width: 100%;
    height: 100%;
    justify-content: center;
    align-items: center;
    padding: 10px;
    box-sizing: border-box;
    flex-direction: row; /* Default to side-by-side for desktop */
}

#board-container {
    display: flex;
    justify-content: center;
    align-items: center;
}

#board {
    width: 90vh; /* Default size for desktop, based on viewport height */
    height: 90vh;
}

/* AI-Comment: New sidebar container for desktop to hold profiles and chat. */
#sidebar-container {
    display: flex;
    flex-direction: column;
    height: 90vh;
    width: 300px;
    margin-left: 5px;
}

/* AI-Comment: Container for the chat history and input form. */
#chat-container {
    display: flex;
    flex-direction: column;
    flex-grow: 1; /* Allows chat to fill space between profiles */
    background-color: #302E2C;
    border-radius: 5px;
    overflow: hidden;
    position: relative; /* enable absolute-positioned overlays inside */
}

/* AI-Comment: The scrollable area for messages. */
#chat-history {
    flex-grow: 1;
    padding: 10px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
}

/* AI-Comment: Styles for the message bubbles. */
.chat-message {
    padding: 8px 12px;
    border-radius: 15px;
    margin-bottom: 8px;
    max-width: 80%;
    word-wrap: break-word;
    white-space: pre-wrap;
}

.chat-message.system {
    background-color: transparent;
    color: #aaa;
    text-align: center;
    align-self: center;
    max-width: 100%;
}

.chat-message.you {
    background-color: #FA660F;
    color: white;
    align-self: flex-end; /* Your messages on the right */
}

.chat-message.him {
    background-color: #5a5a5a;
    color: white;
    align-self: flex-start; /* Opponent's messages on the left */
}

#chat-form {
    display: flex;
    padding: 10px;
    border-top: 1px solid #444;
    align-items: flex-end; /* AI-Fix: Align to the bottom to keep button position stable. */
}

#chat-input {
    flex-grow: 1;
    padding: 8px;
    border: 1px solid #555;
    border-radius: 5px;
    background-color: #444;
    color: white;
    resize: none;
    overflow-y: hidden;
    font-family: sans-serif;
    font-size: 1em;
    box-sizing: border-box;
    height: 38px;
    line-height: 20px;
}

#chat-send {
    padding: 8px 15px;
    border: none;
    border-radius: 5px;
    background-color: #FA660F;
    color: white;
    cursor: pointer;
    font-size: 1em;
    margin-left: 10px;
    line-height: 22px;
}

/* Floating command palette overlay */
#command-hint {
    position: absolute;
    left: 8px;
    right: 8px;
    bottom: 60px; /* floats above the input area */
    background: rgba(20, 20, 20, 0.85);
    border: 1px solid #555;
    border-radius: 8px;
    box-shadow: 0 8px 24px rgba(0,0,0,0.5);
    z-index: 100; /* above chat content */
    padding: 8px;
    backdrop-filter: saturate(120%) blur(2px);
}

#command-hint div {
    padding: 8px 10px;
    border-radius: 6px;
    cursor: pointer;
}

#command-hint div:hover {
    background: #3a3836;
}

#login-btn {
    padding: 8px 15px;
    border: 1px solid #5a5a5a;
    border-radius: 5px;
    background-color: black;
    color: white;
    cursor: pointer;
    font-size: 1em;
    line-height: 22px;
}

.highlight-move {
    box-shadow: inset 0 0 3px 3px #FA660F;
}

.player-profile {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 5px 0px;
    height: 40px;
}

.player-profile .profile-info {
    display: flex;
    align-items: center;
}

.player-profile img {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    margin-right: 8px;
}

.player-profile .user-info .username {
    font-weight: bold;
    font-size: 1em;
}

.player-profile .user-info .handle {
    font-size: 1em;
    color: #aaa;
}

#opponent-profile-mobile, #player-profile-mobile {
    display: none;
}

#coming-soon {
    display: none;
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background-color: rgba(0, 0, 0, 0.7);
    color: white;
    padding: 15px 25px;
    border-radius: 5px;
    z-index: 1000;
}

@media (max-width: 768px), (orientation: portrait) {
    .main-container {
        flex-direction: column;
        padding: 5px;
        justify-content: flex-start;
        height: 100vh;
    }

    #board, #sidebar-container {
        width: 98vw;
        height: auto;
    }

    #opponent-profile-mobile { order: 1; }
    #board-container { order: 2; }
    #player-profile-mobile { order: 3; }
    #sidebar-container { order: 4; }

    #opponent-profile-mobile, #player-profile-mobile {
        display: flex;
        width: 98vw;
    }
    
    #sidebar-container {
        flex-grow: 1;
        min-height: 0;
        margin-left: 0;
        margin-top: 5px;
    }

    #sidebar-container #opponent-profile-desktop, 
    #sidebar-container #player-profile-desktop {
        display: none;
    }
}
