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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    line-height: 1.6;
    color: #333;
    background-color: #f8f9fa;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.container {
    max-width: 800px;
    margin: 0 auto;
    padding: 0 20px;
}

/* Header */
header {
    background: #2c3e50;
    color: white;
    padding: 1rem 0;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

header .container {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.header-left {
    display: flex;
    flex-direction: column;
}

header h1 {
    font-size: 1.5rem;
    font-weight: 600;
    margin: 0 0 0.25rem 0;
}

.header-stats {
    font-size: 0.9rem;
    color: #ecf0f1;
    opacity: 0.9;
}

#total-submissions {
    font-weight: 600;
    color: #3498db;
}

#instructions-link {
    color: #3498db;
    text-decoration: none;
    font-weight: 500;
}

#instructions-link:hover {
    text-decoration: underline;
}

/* Main content */
main {
    flex: 1;
    padding: 2rem 0;
}

.page {
    animation: fadeIn 0.3s ease-in-out;
}

.hidden {
    display: none !important;
}

/* Landing page */
.content {
    background: white;
    padding: 2rem;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    margin-bottom: 2rem;
}

.consent-section {
    background: #f8f9fa;
    padding: 1.5rem;
    border-radius: 6px;
    margin: 2rem 0;
    border: 2px solid #e9ecef;
}

.consent-checkbox {
    margin-top: 1rem;
    display: flex;
    align-items: flex-start;
    gap: 0.5rem;
}

.consent-checkbox input[type="checkbox"] {
    width: 18px;
    height: 18px;
    margin-top: 2px;
    flex-shrink: 0;
}

.consent-checkbox label {
    font-size: 0.9rem;
    line-height: 1.4;
    cursor: pointer;
}

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

.progress-info {
    text-align: center;
    font-weight: 600;
    color: #2c3e50;
}

/* Task content */
.task-content {
    background: white;
    padding: 2rem;
    border-radius: 0 0 8px 8px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

.task-section, .form-section, .recording-section {
    margin-bottom: 2rem;
    padding-bottom: 2rem;
    border-bottom: 1px solid #e9ecef;
}

.task-section:last-of-type, .recording-section:last-of-type {
    border-bottom: none;
}

/* Language badge */
.language-badge {
    display: inline-block;
    background: #3498db;
    color: white;
    padding: 0.25rem 0.75rem;
    border-radius: 20px;
    font-size: 0.8rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
}

/* Source text */
.source-text {
    background: #f8f9fa;
    padding: 1rem;
    border-radius: 6px;
    border: 2px solid #e9ecef;
    font-size: 1.1rem;
    line-height: 1.5;
    margin-top: 0.5rem;
}

/* Form elements */
label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 600;
    color: #2c3e50;
}

select, textarea, input[type="text"], input[type="email"] {
    width: 100%;
    padding: 0.75rem;
    border: 2px solid #e9ecef;
    border-radius: 6px;
    font-size: 1rem;
    font-family: inherit;
    transition: border-color 0.2s;
}

select:focus, textarea:focus, input[type="text"]:focus, input[type="email"]:focus {
    outline: none;
    border-color: #3498db;
}

textarea {
    min-height: 100px;
    resize: vertical;
}

#canton-note-section {
    margin-top: 1rem;
}

/* Recording controls */
.recording-controls {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 1rem;
}

.record-button, .stop-button, .play-button, .redo-button {
    padding: 0.75rem 1.5rem;
    border: none;
    border-radius: 6px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    min-width: 100px;
}

.record-button {
    background: #27ae60;
    color: white;
}

.record-button:hover {
    background: #229954;
}

.record-button:disabled {
    background: #95a5a6;
    cursor: not-allowed;
}

.stop-button {
    background: #e74c3c;
    color: white;
}

.stop-button:hover {
    background: #c0392b;
}

.play-button {
    background: #3498db;
    color: white;
}

.play-button:hover {
    background: #2980b9;
}

.redo-button {
    background: #f39c12;
    color: white;
}

.redo-button:hover {
    background: #d68910;
}

.timer {
    font-family: 'Courier New', monospace;
    font-size: 1.2rem;
    font-weight: bold;
    color: #2c3e50;
    min-width: 60px;
}

.recording-status {
    padding: 0.5rem;
    border-radius: 4px;
    font-size: 0.9rem;
    font-weight: 500;
}

.recording-status.recording {
    background: #d5f4e6;
    color: #27ae60;
}

.recording-status.completed {
    background: #d1ecf1;
    color: #3498db;
}

.recording-status.error {
    background: #f8d7da;
    color: #e74c3c;
}

/* Submit section */
.submit-section {
    margin-top: 2rem;
    text-align: center;
}

.submit-section .primary-button {
    margin-right: 1rem;
    margin-bottom: 1rem;
}

.primary-button {
    background: #3498db;
    color: white;
    padding: 1rem 2rem;
    border: none;
    border-radius: 6px;
    font-size: 1.1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    min-width: 200px;
}

.primary-button:hover {
    background: #2980b9;
}

.primary-button:disabled {
    background: #95a5a6;
    cursor: not-allowed;
}

.skip-button {
    background: #6c757d;
    color: white;
    padding: 1rem 2rem;
    border: none;
    border-radius: 6px;
    font-size: 1.1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    min-width: 200px;
}

.skip-button:hover {
    background: #5a6268;
}

.skip-button:disabled {
    background: #95a5a6;
    cursor: not-allowed;
}

.submit-status {
    margin-top: 1rem;
    padding: 0.75rem;
    border-radius: 6px;
    font-weight: 500;
}

.submit-status.success {
    background: #d5f4e6;
    color: #27ae60;
}

.submit-status.error {
    background: #f8d7da;
    color: #e74c3c;
}

/* Modal */
.modal {
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0,0,0,0.5);
    animation: fadeIn 0.2s;
}

.modal-content {
    background-color: white;
    margin: 5% auto;
    padding: 2rem;
    border-radius: 8px;
    width: 90%;
    max-width: 600px;
    max-height: 80vh;
    overflow-y: auto;
    position: relative;
}

.close {
    position: absolute;
    right: 1rem;
    top: 1rem;
    color: #aaa;
    font-size: 28px;
    font-weight: bold;
    cursor: pointer;
}

.close:hover {
    color: #333;
}

/* Loading overlay */
#loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(255, 255, 255, 0.9);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    z-index: 1000;
}

.loading-spinner {
    border: 4px solid #f3f3f3;
    border-top: 4px solid #3498db;
    border-radius: 50%;
    width: 40px;
    height: 40px;
    animation: spin 1s linear infinite;
    margin-bottom: 1rem;
}

/* Footer */
footer {
    background: #2c3e50;
    color: white;
    text-align: center;
    padding: 1rem 0;
    margin-top: auto;
}

footer p {
    font-size: 0.9rem;
}

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

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Responsive design */
@media (max-width: 768px) {
    .container {
        padding: 0 15px;
    }
    
    header h1 {
        font-size: 1.25rem;
    }
    
    .content, .task-content {
        padding: 1.5rem;
    }
    
    .modal-content {
        margin: 10% auto;
        padding: 1.5rem;
        width: 95%;
    }
    
    .recording-controls {
        justify-content: center;
    }
    
    .record-button, .stop-button, .play-button, .redo-button {
        min-width: 80px;
        padding: 0.6rem 1rem;
        font-size: 0.9rem;
    }
    
    .primary-button, .skip-button {
        min-width: 150px;
        padding: 0.875rem 1.5rem;
    }
    
    .submit-section .primary-button {
        margin-right: 0.5rem;
        margin-bottom: 0.75rem;
    }
}

@media (max-width: 480px) {
    main {
        padding: 1rem 0;
    }
    
    .content, .task-content {
        padding: 1rem;
    }
    
    .progress-section {
        padding: 0.75rem 1rem;
    }
    
    .recording-controls {
        flex-direction: column;
        align-items: stretch;
    }
    
    .record-button, .stop-button, .play-button, .redo-button {
        width: 100%;
        min-width: unset;
    }
    
    .timer {
        text-align: center;
    }
    
    .submit-section {
        display: flex;
        flex-direction: column;
        gap: 0.75rem;
        align-items: center;
    }
    
    .primary-button, .skip-button {
        width: 100%;
        min-width: unset;
        margin: 0;
    }
}

/* Flag buttons */
.flag-btn {
    background: #fee2e2;
    border: 1px solid #fca5a5;
    color: #dc2626;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    padding: 6px 8px;
    margin-left: 8px;
    border-radius: 6px;
    transition: all 0.2s ease;
    vertical-align: middle;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}

.flag-btn:hover {
    background: #fecaca;
    border-color: #f87171;
    color: #b91c1c;
    transform: scale(1.05);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.flag-btn:active {
    transform: scale(0.95);
    background: #fca5a5;
}

.flag-btn:disabled {
    cursor: not-allowed;
    opacity: 0.5;
    background: #f3f4f6;
    border-color: #d1d5db;
    color: #6b7280;
}

.flag-btn:disabled:hover {
    transform: none;
    background: #f3f4f6;
    box-shadow: none;
}

/* Flag success message */
.flag-success-message {
    animation: slideInRight 0.3s ease-out;
}

@keyframes slideInRight {
    from {
        transform: translateX(100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

/* High DPI displays */
@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
    .language-badge {
        font-weight: 500;
    }
}