/* Reset and base styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary-color: #2563eb;
    --primary-dark: #1d4ed8;
    --secondary-color: #64748b;
    --success-color: #10b981;
    --background: #f8fafc;
    --surface: #ffffff;
    --text-primary: #1e293b;
    --text-secondary: #64748b;
    --border-color: #e2e8f0;
    --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
    --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1);
    --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1);
    --radius: 0.5rem;
    --transition: all 0.2s ease;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background: var(--background);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
}

/* Layout */
#app {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.screen {
    flex: 1;
    display: flex;
    flex-direction: column;
    transition: var(--transition);
}

.screen.hidden {
    display: none;
}

.container {
    max-width: 800px;
    margin: 0 auto;
    padding: 1rem;
    width: 100%;
}

/* Header */
header {
    text-align: center;
    margin-bottom: 2rem;
    padding: 1.5rem 0;
}

header h1 {
    font-size: 2.5rem;
    font-weight: 700;
    color: var(--primary-color);
    margin-bottom: 0.5rem;
}

header p {
    color: var(--text-secondary);
    font-size: 1.1rem;
}

/* Configuration Screen */
.config-section {
    margin-bottom: 1.5rem;
}

label {
    display: block;
    font-weight: 600;
    margin-bottom: 0.5rem;
    color: var(--text-primary);
}

select {
    width: 100%;
    padding: 0.75rem;
    border: 2px solid var(--border-color);
    border-radius: var(--radius);
    font-size: 1rem;
    background: var(--surface);
    transition: var(--transition);
}

select:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgb(37 99 235 / 0.1);
}

select:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Buttons */
.primary-btn, .control-btn, .back-btn {
    padding: 0.75rem 1.5rem;
    border: none;
    border-radius: var(--radius);
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
}

.primary-btn {
    background: var(--primary-color);
    color: white;
    width: 100%;
    padding: 1rem;
    font-size: 1.1rem;
    margin-top: 1rem;
}

.primary-btn:hover:not(:disabled) {
    background: var(--primary-dark);
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}

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

.control-btn {
    background: var(--surface);
    color: var(--text-primary);
    border: 2px solid var(--border-color);
    padding: 0.5rem 1rem;
}

.control-btn:hover {
    background: var(--background);
    border-color: var(--primary-color);
}

.back-btn {
    background: transparent;
    color: var(--text-secondary);
    padding: 0.5rem;
    position: absolute;
    left: 1rem;
    top: 1.5rem;
}

.back-btn:hover {
    color: var(--primary-color);
}

/* Training Screen */
#training-screen header {
    position: relative;
    border-bottom: 1px solid var(--border-color);
    margin-bottom: 2rem;
}

.controls {
    margin-top: 1rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
    align-items: center;
}

.verb-selector {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
    font-size: 0.9rem;
}

.verb-selector select {
    padding: 0.5rem;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    background: var(--background-color);
    color: var(--text-color);
    min-width: 150px;
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
}

.speed-control {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
    font-size: 0.9rem;
}

.speed-control input[type="range"] {
    width: 120px;
    height: 6px;
    background: var(--border-color);
    border-radius: 3px;
    outline: none;
    -webkit-appearance: none;
}

.speed-control input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 18px;
    height: 18px;
    background: var(--primary-color);
    cursor: pointer;
    border-radius: 50%;
}

.speed-control input[type="range"]::-moz-range-thumb {
    width: 18px;
    height: 18px;
    background: var(--primary-color);
    cursor: pointer;
    border-radius: 50%;
    border: none;
}

/* Training Area */
.training-area {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2rem;
}

.verb-card {
    background: var(--surface);
    padding: 3rem 2rem;
    border-radius: 1rem;
    box-shadow: var(--shadow-lg);
    text-align: center;
    min-width: 320px;
    max-width: 500px;
    width: 100%;
    transition: var(--transition);
}

.verb-card.revealed {
    box-shadow: 0 0 0 3px var(--success-color);
}

.verb-info {
    margin-bottom: 2rem;
}

.pronoun {
    font-size: 1.2rem;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 0.5rem;
}

.infinitive {
    font-size: 1.8rem;
    font-weight: 700;
    color: var(--text-primary);
}

.conjugation-container {
    position: relative;
    min-height: 3rem;
    display: flex;
    align-items: center;
    justify-content: center;
}

.conjugation {
    font-size: 2rem;
    font-weight: 700;
    color: var(--primary-color);
    animation: fadeIn 0.3s ease;
}

.conjugation.hidden {
    display: none;
}

.thinking-hint {
    font-size: 1.2rem;
    color: var(--text-secondary);
    opacity: 0.7;
    animation: pulse 1.5s infinite;
}

.thinking-hint.hidden {
    display: none;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes pulse {
    0%, 100% { opacity: 0.7; }
    50% { opacity: 0.3; }
}

/* Progress */
.progress-info {
    text-align: center;
    width: 100%;
    max-width: 500px;
}

#progress-text {
    font-size: 0.9rem;
    color: var(--text-secondary);
    margin-bottom: 0.5rem;
}

.progress-bar {
    width: 100%;
    height: 8px;
    background: var(--border-color);
    border-radius: 4px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    background: var(--primary-color);
    transition: width 0.3s ease;
    border-radius: 4px;
}

/* Training Controls */
.training-controls {
    display: flex;
    gap: 1rem;
    justify-content: center;
}

/* Responsive Design */
@media (max-width: 768px) {
    .container {
        padding: 0.75rem;
    }
    
    header h1 {
        font-size: 2rem;
    }
    
    .verb-card {
        padding: 2rem 1.5rem;
        min-width: 280px;
    }
    
    .conjugation {
        font-size: 1.5rem;
    }
    
    .infinitive {
        font-size: 1.5rem;
    }
    
    .speed-control input[type="range"] {
        width: 100px;
    }
    
    .back-btn {
        position: static;
        margin-bottom: 1rem;
    }
    
    #training-screen header {
        text-align: left;
    }
    
    .controls {
        text-align: center;
    }
}

@media (max-width: 480px) {
    .verb-card {
        padding: 1.5rem 1rem;
        min-width: 250px;
    }
    
    .training-controls {
        flex-direction: column;
        width: 100%;
        max-width: 250px;
    }
    
    .control-btn {
        width: 100%;
    }
}

/* Tense Selection Styles */
.tense-selection {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 1rem;
    margin-top: 0.5rem;
}

.tense-item {
    display: flex;
    align-items: center;
    justify-content: flex-start;
    padding: 1rem 1.25rem;
    background: var(--surface);
    border: 2px solid var(--border-color);
    border-radius: var(--radius);
    transition: var(--transition);
    cursor: pointer;
    position: relative;
    min-height: 52px;
}

.tense-item:hover {
    border-color: var(--primary-color);
    background: #f8faff;
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.tense-item input[type="checkbox"] {
    width: 1.125rem;
    height: 1.125rem;
    margin-right: 0.875rem;
    accent-color: var(--primary-color);
    cursor: pointer;
    flex-shrink: 0;
}

.tense-item label {
    margin: 0;
    font-weight: 500;
    cursor: pointer;
    color: var(--text-primary);
    user-select: none;
    font-size: 0.95rem;
    line-height: 1.2;
}

.tense-item input[type="checkbox"]:checked + label {
    color: var(--primary-color);
    font-weight: 600;
}

.tense-item:has(input:checked) {
    border-color: var(--primary-color);
    background: #f0f7ff;
    box-shadow: 0 0 0 3px rgb(37 99 235 / 0.1);
}

/* Mobile responsive for tense selection */
@media (max-width: 768px) {
    .tense-selection {
        grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
        gap: 0.875rem;
    }
    
    .tense-item {
        padding: 0.875rem 1rem;
        min-height: 48px;
    }
    
    .tense-item input[type="checkbox"] {
        width: 1rem;
        height: 1rem;
        margin-right: 0.75rem;
    }
    
    .tense-item label {
        font-size: 0.9rem;
    }
}

@media (max-width: 480px) {
    .tense-selection {
        grid-template-columns: 1fr;
        gap: 0.75rem;
    }
    
    .tense-item {
        padding: 0.875rem 1rem;
        min-height: 48px;
        justify-content: flex-start;
        text-align: left;
        flex-direction: row; /* Keep checkbox and text side-by-side */
        gap: 0.75rem;
    }
    
    .tense-item input[type="checkbox"] {
        width: 1.125rem;
        height: 1.125rem;
        margin-right: 0;
        margin-bottom: 0;
        flex-shrink: 0;
    }
    
    .tense-item label {
        font-size: 0.95rem;
        font-weight: 500;
        flex: 1;
    }
}

/* PWA Install Styles */
@media (display-mode: standalone) {
    header {
        padding-top: 2rem;
    }
    
    .back-btn {
        top: 2rem;
    }
}

/* Focus and accessibility */
*:focus-visible {
    outline: 2px solid var(--primary-color);
    outline-offset: 2px;
}

button:focus-visible,
select:focus-visible {
    outline: 2px solid var(--primary-color);
    outline-offset: 2px;
}
