/**
 * styles.css - Application styles
 * Mobile-first responsive design with subtle gradients and modern styling
 */

:root {
    --primary-color: #4a90e2;
    --secondary-color: #67b8e3;
    --background: #f8f9fa;
    --card-bg: #ffffff;
    --text-color: #333;
    --border-color: #e0e0e0;
    --shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    --shadow-hover: 0 4px 8px rgba(0, 0, 0, 0.15);
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background: linear-gradient(135deg, #f5f7fa 0%, #c3cfe2 100%);
    color: var(--text-color);
    line-height: 1.6;
    min-height: 100vh;
    padding: 1rem;
}

#app {
    max-width: 1400px;
    margin: 0 auto;
}

h1 {
    font-size: 1.8rem;
    margin-bottom: 1rem;
    color: var(--primary-color);
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.1);
}

h2 {
    font-size: 1.2rem;
    margin-bottom: 0.75rem;
    color: var(--text-color);
}

/* Workflow Container */
.workflow-container {
    background: var(--card-bg);
    border-radius: 12px;
    padding: 1.5rem;
    box-shadow: var(--shadow);
}

/* Message Area */
.message-area {
    background: linear-gradient(135deg, #e3f2fd 0%, #bbdefb 100%);
    padding: 0.75rem;
    border-radius: 6px;
    margin-bottom: 1rem;
    border-left: 4px solid var(--primary-color);
}

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

.message-area div:last-child {
    margin-bottom: 0;
}

/* Progress Bar */
.progress-bar {
    height: 6px;
    background: var(--border-color);
    border-radius: 3px;
    margin-bottom: 1rem;
    overflow: hidden;
    position: relative;
}

.progress-bar::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    height: 100%;
    width: 40%;
    background: linear-gradient(90deg, var(--primary-color) 0%, var(--secondary-color) 100%);
    animation: progress 1.5s ease-in-out infinite;
}

@keyframes progress {
    0% { transform: translateX(-100%); }
    100% { transform: translateX(350%); }
}

/* Sections */
section {
    margin-bottom: 1.5rem;
}

/* Word List */
.word-input-container {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 0.75rem;
}

.word-input-container input {
    flex: 1;
    padding: 0.5rem;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    font-size: 1rem;
}

.word-input-container button {
    padding: 0.5rem 1rem;
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--secondary-color) 100%);
    color: white;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-weight: 500;
    box-shadow: var(--shadow);
    transition: all 0.2s;
}

.word-input-container button:hover:not(:disabled) {
    box-shadow: var(--shadow-hover);
    transform: translateY(-1px);
}

.word-input-container button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.word-list {
    list-style: none;
    background: var(--background);
    border-radius: 6px;
    padding: 0.5rem;
    min-height: 50px;
}

.word-list:empty::after {
    content: 'No words added yet';
    display: block;
    text-align: center;
    color: #999;
    padding: 1rem;
}

.word-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem;
    background: white;
    margin-bottom: 0.25rem;
    border-radius: 4px;
    cursor: move;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}

.word-item:hover {
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.word-drag-handle {
    color: #999;
    user-select: none;
}

.word-value {
    flex: 1;
    font-weight: 500;
}

.remove-word-btn {
    padding: 0.25rem 0.5rem;
    background: #f44336;
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.85rem;
}

.remove-word-btn:hover:not(:disabled) {
    background: #d32f2f;
}

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

/* Grid Controls */
.grid-size-controls {
    display: flex;
    gap: 1rem;
    margin-bottom: 0.75rem;
}

.grid-size-controls label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.grid-size-controls input {
    width: 60px;
    padding: 0.25rem;
    border: 1px solid var(--border-color);
    border-radius: 4px;
}

#start-generation-btn {
    padding: 0.75rem 1.5rem;
    background: linear-gradient(135deg, #4caf50 0%, #66bb6a 100%);
    color: white;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-weight: 500;
    font-size: 1rem;
    box-shadow: var(--shadow);
    transition: all 0.2s;
}

#start-generation-btn:hover:not(:disabled) {
    box-shadow: var(--shadow-hover);
    transform: translateY(-1px);
}

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

/* Candidates */
.candidates-container {
    display: flex;
    gap: 0.75rem;
    flex-wrap: wrap;
    min-height: 60px;
}

.candidate-thumbnail {
    cursor: pointer;
    border: 3px solid transparent;
    border-radius: 6px;
    padding: 0.25rem;
    transition: all 0.2s;
}

.candidate-thumbnail:hover {
    border-color: var(--secondary-color);
}

.candidate-thumbnail.active {
    border-color: var(--primary-color);
    box-shadow: 0 0 8px rgba(74, 144, 226, 0.3);
}

/* Word Grid */
.word-grid {
    display: grid;
    gap: 1px;
    background: #ccc;
    width: fit-content;
    margin: 0 auto;
}

.word-grid.thumbnail {
    max-width: 8vh;
    max-height: 8vh;
}

.word-grid.preview {
    max-width: 40vh;
    max-height: 40vh;
}

.grid-cell {
    background: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    font-family: monospace;
    aspect-ratio: 1;
    min-width: 25px;
    min-height: 25px;
}

.grid-cell.empty {
    background: #000;
}

/* Preview Section */
.preview-container {
    min-height: 150px;
    display: flex;
    align-items: center;
    justify-content: center;
}

#select-crossword-btn {
    margin-top: 1rem;
    padding: 0.75rem 1.5rem;
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--secondary-color) 100%);
    color: white;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-weight: 500;
    box-shadow: var(--shadow);
    transition: all 0.2s;
}

#select-crossword-btn:hover {
    box-shadow: var(--shadow-hover);
    transform: translateY(-1px);
}

/* Links */
linkset {
    display: flex;
    gap: 1rem;
    justify-content: center;
    margin-top: 2rem;
    padding: 1rem;
}

linkset a {
    color: var(--primary-color);
    text-decoration: none;
    font-weight: 500;
}

linkset a:hover {
    text-decoration: underline;
}

/* Print Styles */
@media print {
    body:not(.final_grid_only) {
        /* Normal print - everything shows */
    }
    
    body.final_grid_only * {
        display: none !important;
    }
    
    body.final_grid_only .preview-section,
    body.final_grid_only .preview-section * {
        display: block !important;
    }
    
    body.final_grid_only .word-grid,
    body.final_grid_only .word-grid * {
        display: flex !important;
    }
    
    body.final_grid_only .grid-cell.empty {
        background: #000 !important;
        print-color-adjust: exact;
        -webkit-print-color-adjust: exact;
    }
}

/* Landscape Layout (width > height and width >= 768px) */
@media (min-width: 768px) and (orientation: landscape) {
    .workflow-container.landscape-layout {
        display: grid;
        grid-template-columns: 1fr 1fr;
        grid-template-rows: auto 1fr;
        gap: 1.5rem;
    }
    
    .workflow-container.landscape-layout h1 {
        grid-column: 1 / -1;
    }
    
    .workflow-container.landscape-layout .message-area {
        grid-column: 1 / -1;
    }
    
    .workflow-container.landscape-layout .controls-section {
        grid-column: 1;
        grid-row: 2;
    }
    
    .workflow-container.landscape-layout .grids-section {
        grid-column: 2;
        grid-row: 2;
    }
}
