/**
 * styles.css - Application styles
 * 
 * Two-column layout (35% controls / 65% grids)
 * Responsive grid rendering with CSS Grid
 */

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
    background: #f5f5f5;
    min-height: 100vh;
}

header {
    background: #333;
    color: white;
    padding: 1rem 2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

header h1 {
    font-size: 1.5rem;
}

header nav a {
    color: white;
    text-decoration: none;
    margin-left: 1.5rem;
    padding: 0.5rem 1rem;
    border-radius: 4px;
    transition: background 0.2s;
}

header nav a:hover {
    background: #555;
}

main {
    padding: 2rem;
}

/* Workflow Container */
.workflow-container {
    display: flex;
    gap: 2rem;
    min-height: calc(100vh - 200px);
}

.controls-column {
    flex: 0 0 35%;
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.grids-column {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 2rem;
}

/* Word List Section */
.word-list-section {
    background: white;
    border-radius: 8px;
    padding: 1.5rem;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.word-list-section h2 {
    margin-bottom: 1rem;
    font-size: 1.2rem;
    color: #333;
}

.word-list {
    list-style: none;
    margin-bottom: 1rem;
    max-height: 300px;
    overflow-y: auto;
}

.word-list:empty::after {
    content: 'No words yet. Add your first word below.';
    display: block;
    color: #999;
    font-style: italic;
    padding: 1rem;
    text-align: center;
}

.word-item {
    display: flex;
    align-items: center;
    padding: 0.75rem;
    margin-bottom: 0.5rem;
    background: #f9f9f9;
    border-radius: 4px;
    cursor: move;
    transition: all 0.2s;
}

.word-item:hover {
    background: #e9e9e9;
}

.word-item.dragging {
    opacity: 0.5;
}

.word-drag-handle {
    color: #999;
    margin-right: 0.75rem;
    cursor: grab;
    user-select: none;
}

.word-value {
    flex: 1;
    font-weight: 600;
    color: #333;
}

.remove-word-btn {
    background: #dc3545;
    color: white;
    border: none;
    border-radius: 4px;
    padding: 0.25rem 0.75rem;
    cursor: pointer;
    font-size: 1.2rem;
    line-height: 1;
}

.remove-word-btn:hover {
    background: #c82333;
}

.remove-word-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.add-word-section {
    display: flex;
    gap: 0.5rem;
}

.add-word-section input {
    flex: 1;
    padding: 0.5rem;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 1rem;
}

.add-word-section button {
    padding: 0.5rem 1rem;
    background: #007bff;
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 1rem;
}

.add-word-section button:hover {
    background: #0056b3;
}

.add-word-section button:disabled,
.add-word-section input:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Grid Controls Section */
.grid-controls-section {
    background: white;
    border-radius: 8px;
    padding: 1.5rem;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.grid-controls-section h2 {
    margin-bottom: 1rem;
    font-size: 1.2rem;
    color: #333;
}

.grid-size-inputs {
    display: flex;
    gap: 1rem;
    margin-bottom: 1rem;
}

.grid-size-inputs label {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    color: #666;
    font-size: 0.9rem;
}

.grid-size-inputs input {
    padding: 0.5rem;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 1rem;
}

.grid-options {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    margin-bottom: 1rem;
}

.grid-options label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    cursor: pointer;
    color: #666;
}

.grid-options input[type="checkbox"] {
    cursor: pointer;
}

#start-generation-btn {
    width: 100%;
    padding: 0.75rem;
    background: #28a745;
    color: white;
    border: none;
    border-radius: 4px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
}

#start-generation-btn:hover {
    background: #218838;
}

#start-generation-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Message Area */
.message-area {
    background: white;
    border-radius: 8px;
    padding: 1rem;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    color: #333;
    line-height: 1.5;
}

.message-area div {
    margin-bottom: 0.25rem;
}

/* Progress Bar */
.progress-bar {
    background: white;
    border-radius: 8px;
    padding: 1rem;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.progress-fill {
    height: 20px;
    background: #007bff;
    border-radius: 4px;
    animation: pulse 1s infinite;
}

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

/* Candidates Section */
.candidates-section {
    background: white;
    border-radius: 8px;
    padding: 1.5rem;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.candidates-section h2 {
    margin-bottom: 1rem;
    font-size: 1.2rem;
    color: #333;
}

.candidates-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 1rem;
}

.candidate-thumbnail {
    border: 2px solid #ddd;
    border-radius: 4px;
    padding: 0.5rem;
    cursor: pointer;
    transition: all 0.2s;
}

.candidate-thumbnail:hover {
    border-color: #007bff;
    transform: scale(1.05);
}

.candidate-thumbnail.selected {
    border-color: #28a745;
    border-width: 3px;
}

/* Focused Grid Section */
.focused-grid-section {
    background: white;
    border-radius: 8px;
    padding: 1.5rem;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.focused-grid-section h2 {
    margin-bottom: 1rem;
    font-size: 1.2rem;
    color: #333;
}

#focused-grid-container {
    margin-bottom: 1rem;
}

/* Selection Buttons */
.selection-buttons {
    display: flex;
    gap: 1rem;
    justify-content: center;
}

.selection-buttons button {
    padding: 0.75rem 2rem;
    border: none;
    border-radius: 4px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

#select-crossword-btn {
    background: #007bff;
    color: white;
}

#select-crossword-btn:hover {
    background: #0056b3;
}

#select-wordsearch-btn {
    background: #28a745;
    color: white;
}

#select-wordsearch-btn:hover {
    background: #218838;
}

/* Word Grid (CSS Grid) */
.word-grid {
    display: grid;
    gap: 2px;
    background: #ddd;
    padding: 2px;
    border-radius: 4px;
    width: fit-content;
    margin: 0 auto;
}

.grid-cell {
    background: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 1rem;
    width: 35px;
    height: 35px;
    text-transform: uppercase;
}

/* Black cells for crossword mode */
.grid-cell.black-cell {
    background: #333;
    color: #333;
}

/* Thumbnail sizing */
.candidate-thumbnail .word-grid {
    transform: scale(0.35);
    transform-origin: top left;
}

.candidate-thumbnail .grid-cell {
    width: 35px;
    height: 35px;
    font-size: 12px;
}

/* Focused grid sizing */
#focused-grid-container .grid-cell {
    width: 50px;
    height: 50px;
    font-size: 1.5rem;
}

/* Legacy UI Styles */
.app-container {
    max-width: 800px;
    margin: 0 auto;
    background: white;
    border-radius: 8px;
    padding: 2rem;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.items-section {
    margin-top: 2rem;
}

.items-list {
    list-style: none;
    margin: 1rem 0;
}

.item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem;
    margin-bottom: 0.5rem;
    background: #f9f9f9;
    border-radius: 4px;
}

.remove-btn {
    background: #dc3545;
    color: white;
    border: none;
    border-radius: 4px;
    padding: 0.5rem 1rem;
    cursor: pointer;
}

.remove-btn:hover {
    background: #c82333;
}

.add-item-section {
    display: flex;
    gap: 0.5rem;
    margin-top: 1rem;
}

.add-item-section input {
    flex: 1;
    padding: 0.5rem;
    border: 1px solid #ddd;
    border-radius: 4px;
}

.add-item-section button {
    padding: 0.5rem 1rem;
    background: #007bff;
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
}

.add-item-section button:hover {
    background: #0056b3;
}

/* Responsive Design */
@media (max-width: 1024px) {
    .workflow-container {
        flex-direction: column;
    }
    
    .controls-column {
        flex: 1;
    }
}
