/* style.css */
:root {
    --jeopardy-blue: #060a7d;
    --jeopardy-yellow: #fdd835;
    --jeopardy-dark: #333;
    --jeopardy-light: #fff;
    
    /* Clue Cell State Colors */
    --clue-answered-bg: #040640; 
    --clue-hover-bg: #0c128c; 
    --clue-active-bg: #080a5f; 

    font-family: Arial, sans-serif;
}

body {
    background-color: var(--jeopardy-blue);
    color: var(--jeopardy-light);
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

header {
    background-color: var(--jeopardy-dark);
    padding: 10px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

h1 {
    margin: 0;
    color: var(--jeopardy-yellow);
}

#controls button {
    margin-left: 10px;
    padding: 8px 15px;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    background-color: #555;
    color: white;
}

#controls button.danger {
    background-color: #d9534f;
}

#controls button.warning {
    background-color: #f0ad4e; /* Orange/Warning color */
    color: #333;
    font-weight: bold;
}

#app {
    padding: 20px;
    flex-grow: 1;
    display: flex;
    flex-direction: column;
}

/* Scoreboard */
#scoreboard-container {
    width: 100%;
}

#scoreboard {
    display: flex;
    justify-content: space-around;
    gap: 20px;
    padding: 10px;
    margin-bottom: 20px;
    background-color: rgba(0, 0, 0, 0.2);
    border-radius: 8px;
}

.team-score {
    text-align: center;
    padding: 10px;
    background-color: #222;
    border-radius: 5px;
    min-width: 150px;
}

.team-name {
    font-size: 1.2em;
    font-weight: bold;
    color: var(--jeopardy-yellow);
}

.score {
    font-size: 2em;
    margin-top: 5px;
}

/* Board View */
#jeopardy-board {
    display: grid;
    /* grid-template-columns set inline based on category count */
    gap: 10px;
    flex-grow: 1;
    width: 100%;
    max-width: 1200px;
    margin: 0 auto;
}

.category-header {
    background-color: var(--jeopardy-dark);
    padding: 10px 5px;
    text-align: center;
    font-weight: bold;
    text-transform: uppercase;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 50px;
    border-radius: 5px;
    font-size: 1.2em;
}

.clue-cell {
    background-color: var(--jeopardy-blue);
    border: 3px solid var(--jeopardy-light);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2em;
    font-weight: 900;
    cursor: pointer;
    transition: background-color 0.3s, transform 0.1s;
    aspect-ratio: 4/3;
    border-radius: 5px;
}

.clue-cell:hover:not(.answered) {
    background-color: var(--clue-hover-bg);
}

.clue-cell:active:not(.answered) {
    background-color: var(--clue-active-bg);
    transform: scale(0.95);
}

.clue-cell.answered {
    background-color: var(--clue-answered-bg);
    color: transparent;
    cursor: default;
    pointer-events: none;
}

/* Setup View */
#setup-view {
    display: flex;
    flex-direction: column;
    gap: 20px;
    width: 100%;
    max-width: 1200px;
    margin: 0 auto;
}

.category-setup {
    background-color: rgba(0, 0, 0, 0.2);
    padding: 15px;
    border-radius: 8px;
}

.category-setup h3 {
    margin-top: 0;
    color: var(--jeopardy-yellow);
}

.category-setup input[type="text"] {
    width: 100%;
    padding: 8px;
    margin-bottom: 10px;
    box-sizing: border-box;
    background-color: #444;
    color: white;
    border: 1px solid #666;
}

.clue-setup-grid {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 10px;
}

.clue-input-group {
    background-color: #333;
    padding: 10px;
    border-radius: 5px;
}

.clue-input-group h4 {
    margin: 0 0 5px 0;
    color: #ccc;
}

.clue-input-group label {
    display: block;
    font-size: 0.9em;
    margin-bottom: 3px;
}

.clue-input-group textarea {
    width: 100%;
    height: 60px;
    resize: vertical;
    padding: 5px;
    box-sizing: border-box;
    background-color: #444;
    color: white;
    border: 1px solid #666;
    margin-bottom: 5px;
}

/* General Customization */
.customization-section {
    background-color: rgba(0, 0, 0, 0.4);
    padding: 15px;
    border-radius: 8px;
    margin-bottom: 20px;
}

.color-picker-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 15px;
    margin-top: 10px;
}

.color-picker-group, .value-input-group {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.color-picker-group label, .value-input-group label {
    font-weight: bold;
    color: var(--jeopardy-light);
}

.color-picker-group input[type="color"] {
    height: 40px;
    width: 100%;
    border: none;
    padding: 0;
    cursor: pointer;
}

.value-input-group input[type="number"] {
    padding: 8px;
    background-color: #444;
    color: white;
    border: 1px solid #666;
    border-radius: 3px;
    width: 100%;
    box-sizing: border-box;
}

.clue-value-inputs {
    display: grid;
    /* grid-template-columns set inline based on category count */
    gap: 10px;
    margin-top: 10px;
}

.clue-value-controls {
    margin-bottom: 10px;
}

/* Clue View */
#clue-view {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: var(--jeopardy-blue);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: 20px;
    box-sizing: border-box;
    overflow-y: auto;
}

#clue-view h2 {
    color: var(--jeopardy-yellow);
    font-size: 3em;
    margin-bottom: 20px;
    text-align: center;
}

#clue-media-container {
    margin-bottom: 20px;
    max-height: 40vh;
    width: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
}

#clue-media-container img, 
#clue-media-container audio {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    border-radius: 5px;
}

#clue-content {
    background-color: var(--jeopardy-dark);
    padding: 40px;
    border: 5px solid var(--jeopardy-yellow);
    border-radius: 10px;
    text-align: center;
    min-width: 50%;
    max-width: 80%;
}

#clue-question {
    font-size: 2.5em;
    margin-bottom: 30px;
}

#clue-answer {
    font-size: 2em;
    color: #00ff00;
    display: none;
}

#answer-media-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    width: 100%;
}

#answer-media-container img {
    max-width: 100%;
    max-height: 40vh; /* Consistent with inline max height */
    object-fit: contain;
    border-radius: 5px;
    margin-top: 15px;
}

#answer-media-container audio {
    margin-top: 15px;
}

#clue-controls {
    margin-top: 20px;
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    justify-content: center;
}

#clue-controls button {
    padding: 15px 25px;
    font-size: 1.2em;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    transition: background-color 0.2s;
}

.clue-control-show { background-color: #4CAF50; color: white; }
.clue-control-correct { background-color: #2196F3; color: white; }
.clue-control-incorrect { background-color: #f44336; color: white; }
.clue-control-back { background-color: #ff9800; color: white; }

/* Utility Classes for Setup Teams */
.team-setup-container {
    background-color: rgba(0, 0, 0, 0.2);
    padding: 15px;
    border-radius: 8px;
    margin-top: 20px;
    margin-bottom: 20px;
}

.team-setup-controls {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.team-input-row {
    display: flex;
    align-items: center;
    gap: 10px;
    background-color: #222;
    padding: 10px;
    border-radius: 5px;
}

.team-input-row input {
    flex-grow: 1;
    padding: 8px;
    background-color: #444;
    color: white;
    border: 1px solid #666;
    border-radius: 3px;
}

.team-input-row .remove-team-btn {
    background-color: #d9534f;
    color: white;
    padding: 8px 12px;
    font-size: 1em;
    border-radius: 3px;
    cursor: pointer;
    flex-shrink: 0;
}

#add-team-btn {
    margin-top: 10px;
    padding: 10px 15px;
    background-color: #5cb85c;
    color: white;
    border: none;
    border-radius: 5px;
    cursor: pointer;
}

.clue-input-group input[type="file"] {
    margin-bottom: 5px;
}

#add-category-btn {
    margin-top: 5px;
    margin-bottom: 15px;
    padding: 10px 15px;
    background-color: #5cb85c;
    color: white;
    border: none;
    border-radius: 5px;
    cursor: pointer;
}

.team-score-modifier button {
    padding: 5px 10px;
    font-size: 1.1em;
    cursor: pointer;
    border: none;
    border-radius: 3px;
}

.team-score-modifier button[data-change="100"] {
    background-color: #5cb85c;
    color: white;
}

.team-score-modifier button[data-change="-100"] {
    background-color: #d9534f;
    color: white;
}

/* AI Generation Section */
.ai-generation-section {
    background-color: rgba(0, 0, 0, 0.3);
    padding: 10px;
    border-radius: 5px;
    margin-bottom: 10px;
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.ai-topic-input {
    width: 100%;
    padding: 8px;
    box-sizing: border-box;
    background-color: #555;
    color: white;
    border: 1px solid #777;
    border-radius: 3px;
}

.ai-generation-section label {
    font-weight: bold;
    color: var(--jeopardy-yellow);
}

.ai-generation-section button {
    padding: 8px 15px;
    background-color: #007bff; /* Blue for AI button */
    color: white;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    transition: opacity 0.2s;
}

.ai-generation-section button:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

/* Board Management Section */
.board-management-section .board-management-controls {
    display: flex;
    gap: 15px;
    margin-top: 10px;
}

.board-management-controls button,
.board-management-controls label {
    flex-grow: 1;
    text-align: center;
    cursor: pointer;
    white-space: nowrap;
}

.board-management-controls label.button {
    /* Style label as button, inheriting add-team-btn style */
    padding: 10px 15px;
    background-color: #5cb85c;
    color: white;
    border: none;
    border-radius: 5px;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Add generic styling for the modal content */
#media-viewer-content audio {
    width: 80vw;
    max-width: 600px;
}

#media-viewer-content img {
    /* Ensure image fits within modal constraints defined inline */
    display: block;
}