/* 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: linear-gradient(135deg, #ff6b6b 0%, #ee5a52 100%);
    min-height: 100vh;
}

.container {
    max-width: 500px;
    margin: 0 auto;
    padding: 20px;
    min-height: 100vh;
}

/* Header */
header {
    text-align: center;
    margin-bottom: 30px;
}

h1 {
    color: white;
    font-size: 2rem;
    font-weight: 700;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
    margin-bottom: 10px;
}

/* Form styling */
#dough-form {
    background: white;
    border-radius: 16px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1);
    overflow: hidden;
    margin-bottom: 20px;
}

.input-section {
    padding: 24px;
    border-bottom: 1px solid #f0f0f0;
}

.input-section:last-child {
    border-bottom: none;
}

.input-section h2 {
    color: #2d3748;
    font-size: 1.25rem;
    font-weight: 600;
    margin-bottom: 20px;
    padding-bottom: 8px;
    border-bottom: 2px solid #ff6b6b;
}

.input-group {
    margin-bottom: 20px;
}

.input-group:last-child {
    margin-bottom: 0;
}

label {
    display: block;
    font-weight: 500;
    color: #4a5568;
    margin-bottom: 6px;
    font-size: 0.95rem;
}

input[type="number"],
select {
    width: 100%;
    padding: 12px 16px;
    border: 2px solid #e2e8f0;
    border-radius: 8px;
    font-size: 16px; /* Prevents zoom on iOS */
    background: white;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

input[type="number"]:focus,
select:focus {
    outline: none;
    border-color: #ff6b6b;
    box-shadow: 0 0 0 3px rgba(255, 107, 107, 0.1);
}

small {
    display: block;
    color: #718096;
    font-size: 0.8rem;
    margin-top: 4px;
    font-style: italic;
}

/* Checkbox styling */
.checkbox-label {
    display: flex;
    align-items: center;
    cursor: pointer;
    font-weight: 500;
}

input[type="checkbox"] {
    width: auto;
    margin-right: 10px;
    transform: scale(1.2);
    accent-color: #ff6b6b;
}

/* Pre-ferment section */
.preferment-section {
    margin-top: 20px;
    padding: 20px;
    background: #f7fafc;
    border-radius: 8px;
    border: 1px solid #e2e8f0;
}

/* Calculate button */
.calculate-btn {
    width: 100%;
    padding: 16px;
    background: linear-gradient(135deg, #ff6b6b 0%, #ee5a52 100%);
    color: white;
    border: none;
    border-radius: 0 0 16px 16px;
    font-size: 1.1rem;
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.calculate-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(238, 90, 82, 0.4);
}

.calculate-btn:active {
    transform: translateY(0);
}

/* Results section */
.results-section {
    background: white;
    border-radius: 16px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1);
    overflow: hidden;
    margin-top: 20px;
}

.results-section h2 {
    background: linear-gradient(135deg, #48bb78 0%, #38a169 100%);
    color: white;
    padding: 20px 24px;
    margin: 0;
    font-size: 1.5rem;
    font-weight: 600;
    text-align: center;
}

.recipe-group {
    padding: 24px;
    border-bottom: 1px solid #f0f0f0;
}

.recipe-group:last-child {
    border-bottom: none;
}

.recipe-group h3 {
    color: #2d3748;
    font-size: 1.1rem;
    font-weight: 600;
    margin-bottom: 16px;
    padding-bottom: 8px;
    border-bottom: 1px solid #e2e8f0;
}

.recipe-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 0;
    border-bottom: 1px solid #f7fafc;
}

.recipe-item:last-child {
    border-bottom: none;
}

.ingredient {
    font-weight: 500;
    color: #4a5568;
}

.amount {
    font-weight: 600;
    color: #2d3748;
    font-size: 1.1rem;
}

.totals-group {
    background: #f7fafc;
}

.totals-group .recipe-item {
    padding: 12px 0;
}

.totals-group .ingredient {
    font-weight: 600;
    color: #2d3748;
}

.totals-group .amount {
    font-size: 1.2rem;
    color: #ff6b6b;
    font-weight: 700;
}

.fermentation-note {
    margin-top: 12px;
    padding: 12px;
    background: #fef5e7;
    border: 1px solid #f6e05e;
    border-radius: 6px;
    color: #744210;
    font-style: italic;
}

/* Instructions */
.instructions {
    padding: 24px;
    background: #f7fafc;
}

.instructions h3 {
    color: #2d3748;
    font-size: 1.1rem;
    font-weight: 600;
    margin-bottom: 16px;
}

.instructions ol {
    padding-left: 20px;
}

.instructions li {
    margin-bottom: 12px;
    line-height: 1.6;
    color: #4a5568;
}

.instructions strong {
    color: #2d3748;
}

/* Responsive design */
@media (min-width: 768px) {
    .container {
        max-width: 600px;
        padding: 40px 20px;
    }

    h1 {
        font-size: 2.5rem;
    }

    .input-section {
        padding: 32px;
    }

    .recipe-group {
        padding: 32px;
    }

    .instructions {
        padding: 32px;
    }
}

@media (min-width: 1024px) {
    .container {
        max-width: 700px;
    }
}

/* Animation for results appearing */
.results-section {
    animation: slideIn 0.3s ease-out;
}

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

/* Input validation states */
input.valid,
select.valid {
    border-color: #48bb78;
    background-color: #f0fff4;
}

input.invalid,
select.invalid {
    border-color: #f56565;
    background-color: #fff5f5;
}

/* Error display containers */
.validation-errors,
.calculation-errors {
    margin-bottom: 20px;
    display: none;
}

.error-message {
    background: #fed7d7;
    border: 1px solid #f56565;
    border-radius: 8px;
    padding: 16px;
    color: #742a2a;
}

.error-message strong {
    color: #742a2a;
    display: block;
    margin-bottom: 8px;
}

.error-message ul {
    margin: 0;
    padding-left: 20px;
}

.error-message li {
    margin-bottom: 4px;
    line-height: 1.4;
}

/* Screen reader only content */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* Enhanced focus states for accessibility */
button:focus,
input:focus,
select:focus {
    outline: 3px solid #ff6b6b;
    outline-offset: 2px;
    box-shadow: 0 0 0 1px #fff, 0 0 0 4px #ff6b6b;
}

/* Focus visible for better keyboard navigation */
button:focus:not(:focus-visible),
input:focus:not(:focus-visible),
select:focus:not(:focus-visible) {
    outline: none;
    box-shadow: none;
}

button:focus-visible,
input:focus-visible,
select:focus-visible {
    outline: 3px solid #ff6b6b;
    outline-offset: 2px;
    box-shadow: 0 0 0 1px #fff, 0 0 0 4px #ff6b6b;
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    body {
        background: #fff;
    }
    
    #dough-form {
        border: 2px solid #000;
    }
}

/* Dark mode support */
@media (prefers-color-scheme: dark) {
    body {
        background: linear-gradient(135deg, #1a202c 0%, #2d3748 100%);
        color: #e2e8f0;
    }
    
    h1 {
        color: #e2e8f0;
    }
    
    #dough-form,
    .results-section {
        background: #2d3748;
        color: #e2e8f0;
    }
    
    .input-section {
        border-bottom-color: #4a5568;
    }
    
    .input-section h2 {
        color: #e2e8f0;
    }
    
    label {
        color: #cbd5e0;
    }
    
    input[type="number"],
    select {
        background: #4a5568;
        border-color: #718096;
        color: #e2e8f0;
    }
    
    input[type="number"]:focus,
    select:focus {
        border-color: #ff6b6b;
        background: #4a5568;
    }
    
    small {
        color: #a0aec0;
    }
    
    .preferment-section {
        background: #1a202c;
        border-color: #4a5568;
    }
    
    .recipe-group {
        border-bottom-color: #4a5568;
    }
    
    .recipe-group h3 {
        color: #e2e8f0;
        border-bottom-color: #4a5568;
    }
    
    .ingredient {
        color: #cbd5e0;
    }
    
    .amount {
        color: #e2e8f0;
    }
    
    .totals-group {
        background: #1a202c;
    }
    
    .instructions {
        background: #1a202c;
    }
    
    .instructions li {
        color: #cbd5e0;
    }
    
    .instructions strong {
        color: #e2e8f0;
    }
    
    .fermentation-note {
        background: #2d3748;
        border-color: #4a5568;
        color: #e2e8f0;
    }
    
    /* Dark mode validation styles */
    input.valid,
    select.valid {
        border-color: #68d391;
        background-color: #1a202c;
    }
    
    input.invalid,
    select.invalid {
        border-color: #fc8181;
        background-color: #2d3748;
    }
    
    .error-message {
        background: #2d3748;
        border-color: #fc8181;
        color: #fed7d7;
    }
    
    .error-message strong {
        color: #fed7d7;
    }
}