/* CSS Reset and Base Styles */
*,
*::before,
*::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

:root {
    --primary-color: #4f46e5;
    --primary-hover: #4338ca;
    --primary-light: #eef2ff;
    --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: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
    --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
    --radius: 12px;
    --radius-sm: 8px;
}

html {
    font-size: 16px;
}

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;
}

.container {
    max-width: 640px;
    margin: 0 auto;
    padding: 2rem 1rem;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

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

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

.subtitle {
    color: var(--text-secondary);
    font-size: 1.1rem;
}

/* Main Content */
main {
    flex: 1;
}

/* Mode Tabs */
.mode-tabs {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1.5rem;
    background: var(--surface);
    padding: 0.5rem;
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
}

.mode-tab {
    flex: 1;
    padding: 0.75rem 1rem;
    border: none;
    background: transparent;
    border-radius: var(--radius-sm);
    font-size: 0.95rem;
    font-weight: 500;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.2s ease;
}

.mode-tab:hover {
    color: var(--text-primary);
    background: var(--background);
}

.mode-tab.active {
    background: var(--primary-color);
    color: white;
}

/* Mode Sections */
.mode-section {
    display: none;
    background: var(--surface);
    border-radius: var(--radius);
    padding: 1.5rem;
    box-shadow: var(--shadow);
}

.mode-section.active {
    display: block;
}

/* Date Inputs */
.date-inputs {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.input-group {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.input-group label {
    font-weight: 500;
    color: var(--text-primary);
    font-size: 0.95rem;
}

.input-group input[type="date"],
.input-group input[type="number"],
.input-group select {
    padding: 0.875rem 1rem;
    border: 2px solid var(--border-color);
    border-radius: var(--radius-sm);
    font-size: 1rem;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
    background: var(--surface);
    width: 100%;
}

.input-group input:focus,
.input-group select:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px var(--primary-light);
}

.inline-group {
    flex-direction: row;
    gap: 1rem;
}

.inline-group > div {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

/* Options */
.options {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    margin-bottom: 1.5rem;
    padding: 1rem;
    background: var(--background);
    border-radius: var(--radius-sm);
}

.option {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.option input[type="checkbox"] {
    width: 1.25rem;
    height: 1.25rem;
    accent-color: var(--primary-color);
    cursor: pointer;
}

.option label {
    color: var(--text-secondary);
    font-size: 0.95rem;
    cursor: pointer;
}

/* Primary Button */
.primary-btn {
    width: 100%;
    padding: 1rem 1.5rem;
    background: var(--primary-color);
    color: white;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s ease, transform 0.1s ease;
}

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

.primary-btn:active {
    transform: scale(0.98);
}

/* Results */
.results {
    margin-top: 2rem;
    padding-top: 1.5rem;
    border-top: 2px solid var(--border-color);
}

.results.hidden {
    display: none;
}

.results h2 {
    font-size: 1.25rem;
    font-weight: 600;
    margin-bottom: 1rem;
    color: var(--text-primary);
}

.results-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.result-card {
    background: var(--background);
    border-radius: var(--radius-sm);
    padding: 1.25rem;
    text-align: center;
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.result-card.large {
    padding: 2rem;
    background: linear-gradient(135deg, var(--primary-light) 0%, var(--background) 100%);
}

.result-value {
    font-size: 2rem;
    font-weight: 700;
    color: var(--primary-color);
}

.result-card.large .result-value {
    font-size: 1.5rem;
}

.result-label {
    font-size: 0.875rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.detailed-results {
    background: var(--background);
    border-radius: var(--radius-sm);
    padding: 1rem;
}

.detailed-results p {
    color: var(--text-secondary);
    font-size: 0.95rem;
    line-height: 1.6;
}

.detailed-results p + p {
    margin-top: 0.5rem;
}

.calculation-info {
    margin-top: 1rem;
    color: var(--text-secondary);
    font-size: 0.95rem;
    text-align: center;
}

/* Footer */
footer {
    margin-top: 3rem;
    padding-top: 1.5rem;
    border-top: 1px solid var(--border-color);
    text-align: center;
}

footer p {
    color: var(--text-secondary);
    font-size: 0.9rem;
}

footer a {
    color: var(--primary-color);
    text-decoration: none;
    font-weight: 500;
    transition: color 0.2s ease;
}

footer a:hover {
    color: var(--primary-hover);
    text-decoration: underline;
}

/* Responsive Design */
@media (min-width: 480px) {
    .date-inputs {
        flex-direction: row;
        gap: 1rem;
    }

    .date-inputs > .input-group {
        flex: 1;
    }

    .results-grid {
        grid-template-columns: repeat(4, 1fr);
    }

    .result-value {
        font-size: 1.75rem;
    }
}

@media (max-width: 479px) {
    header h1 {
        font-size: 2rem;
    }

    .mode-tab {
        font-size: 0.85rem;
        padding: 0.625rem 0.75rem;
    }

    .mode-section {
        padding: 1.25rem;
    }

    .result-card {
        padding: 1rem;
    }

    .result-value {
        font-size: 1.5rem;
    }
}

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

.results:not(.hidden) {
    animation: fadeIn 0.3s ease;
}

/* Error State */
.input-group input.error {
    border-color: #ef4444;
}

.error-message {
    color: #ef4444;
    font-size: 0.875rem;
    margin-top: 0.5rem;
}
