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

/* Accessibility helpers */
.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;
}

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

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

/* Header */
header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 2rem 0;
    text-align: center;
}

header h1 {
    font-size: 2.5rem;
    margin-bottom: 0.5rem;
    font-weight: 700;
}

.tagline {
    font-size: 1.1rem;
    opacity: 0.9;
    font-weight: 300;
}

/* Main content */
main {
    padding: 3rem 0;
}

.hero {
    text-align: center;
    margin-bottom: 3rem;
}

.hero h2 {
    font-size: 2rem;
    margin-bottom: 1rem;
    color: #2c3e50;
}

.hero p {
    font-size: 1.1rem;
    color: #7f8c8d;
    max-width: 600px;
    margin: 0 auto;
}

/* Value propositions */
.value-props {
    display: flex;
    justify-content: center;
    gap: 2rem;
    margin-top: 2rem;
    flex-wrap: wrap;
}

.prop {
    text-align: center;
    max-width: 180px;
}

.prop strong {
    display: block;
    color: #2c3e50;
    font-size: 1rem;
    margin-bottom: 0.5rem;
}

.prop span {
    color: #7f8c8d;
    font-size: 0.9rem;
}

/* Search and Navigation */
.search-and-navigation {
    margin-bottom: 3rem;
}

.search-container {
    margin-bottom: 2rem;
    text-align: center;
}

.search-box {
    position: relative;
    max-width: 500px;
    margin: 0 auto;
}

.search-box input {
    width: 100%;
    padding: 16px 50px 16px 20px;
    border: 2px solid #e1e8ed;
    border-radius: 50px;
    font-size: 1.1rem;
    transition: all 0.3s ease;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}

.search-box input:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 4px 20px rgba(102, 126, 234, 0.2);
}

.search-button {
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    color: #7f8c8d;
    cursor: pointer;
    padding: 8px;
    border-radius: 50%;
    transition: all 0.2s ease;
}

.search-button:hover {
    color: #667eea;
    background-color: rgba(102, 126, 234, 0.1);
}

.category-navigation {
    text-align: center;
}

.category-navigation h3 {
    font-size: 1.5rem;
    margin-bottom: 1.5rem;
    color: #2c3e50;
}

.category-filters {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 0.8rem;
}

.category-btn {
    background: white;
    border: 2px solid #e1e8ed;
    color: #495057;
    padding: 10px 20px;
    border-radius: 25px;
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    min-height: 44px;
}

.category-btn:hover {
    border-color: #667eea;
    color: #667eea;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.2);
}

.category-btn.active {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border-color: #667eea;
    color: white;
    box-shadow: 0 4px 15px rgba(102, 126, 234, 0.3);
}

.category-btn.active:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(102, 126, 234, 0.4);
}

/* No results message */
.no-results {
    text-align: center;
    padding: 3rem 2rem;
    color: #7f8c8d;
    display: none;
}

.no-results.show {
    display: block;
}

.no-results h3 {
    font-size: 1.5rem;
    margin-bottom: 1rem;
    color: #2c3e50;
}

.no-results p {
    font-size: 1.1rem;
    margin-bottom: 2rem;
}

.search-suggestions {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 0.5rem;
    margin-top: 1rem;
}

.suggestion-btn {
    background: #f8f9fa;
    border: 1px solid #dee2e6;
    color: #495057;
    padding: 8px 16px;
    border-radius: 20px;
    font-size: 0.9rem;
    cursor: pointer;
    transition: all 0.2s ease;
}

.suggestion-btn:hover {
    background: #e9ecef;
    border-color: #adb5bd;
}

/* Most Popular section */
.most-popular {
    margin-bottom: 3rem;
    text-align: center;
}

.most-popular h2 {
    font-size: 2rem;
    margin-bottom: 2rem;
    color: #2c3e50;
}

.popular-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1.5rem;
    max-width: 1000px;
    margin: 0 auto;
}

.popular-card {
    background: white;
    border-radius: 12px;
    padding: 1.5rem;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.07);
    transition: all 0.2s ease;
    cursor: pointer;
    text-align: center;
    border: 2px solid transparent;
}

.popular-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.15);
    border-color: #667eea;
}

.popular-icon {
    font-size: 2.5rem;
    margin-bottom: 1rem;
    display: block;
}

.popular-card h3 {
    font-size: 1.1rem;
    margin-bottom: 0.5rem;
    color: #2c3e50;
    font-weight: 600;
}

.popular-card p {
    color: #7f8c8d;
    font-size: 0.9rem;
    line-height: 1.4;
}

/* Calculator grid */
.calculators-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 2rem;
    margin-bottom: 3rem;
}

.calculator-card {
    background: white;
    border-radius: 12px;
    padding: 2rem;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.07);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    cursor: pointer;
}

.calculator-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.1);
}

.calculator-card h3 {
    font-size: 1.3rem;
    margin-bottom: 1rem;
    color: #2c3e50;
}

.calculator-card p {
    color: #7f8c8d;
    margin-bottom: 1.5rem;
}

.calc-button {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    padding: 12px 24px;
    border-radius: 6px;
    font-size: 1rem;
    font-weight: 500;
    cursor: pointer;
    transition: transform 0.2s ease;
    width: 100%;
}

.calc-button:hover {
    transform: translateY(-1px);
}

.calc-button:active {
    transform: translateY(0);
}

/* Modal styles */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
}

.modal-content {
    background-color: white;
    margin: 5% auto;
    padding: 2rem;
    border-radius: 12px;
    width: 90%;
    max-width: 600px;
    max-height: 80vh;
    overflow-y: auto;
    position: relative;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.2);
}

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

.close:hover,
.close:focus {
    color: #333;
}

/* Calculator form styles */
.calculator-form {
    margin-top: 2rem;
}

.form-group {
    margin-bottom: 1.5rem;
}

.form-group label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 500;
    color: #2c3e50;
}

.form-group input,
.form-group select {
    width: 100%;
    padding: 12px;
    border: 2px solid #e1e8ed;
    border-radius: 6px;
    font-size: 1rem;
    transition: border-color 0.2s ease;
}

.form-group input:focus,
.form-group select:focus {
    outline: none;
    border-color: #667eea;
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
}

.calculate-btn {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    padding: 14px 28px;
    border-radius: 6px;
    font-size: 1.1rem;
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.2s ease;
    width: 100%;
    margin-top: 1rem;
}

.calculate-btn:hover {
    transform: translateY(-1px);
}

.result {
    background: #f8f9fa;
    border: 2px solid #e9ecef;
    border-radius: 8px;
    padding: 1.5rem;
    margin-top: 2rem;
    display: none;
}

.result.show {
    display: block;
    animation: fadeIn 0.3s ease;
}

.result-value {
    font-size: 2rem;
    font-weight: 700;
    color: #28a745;
    margin-bottom: 0.5rem;
}

.result-label {
    color: #6c757d;
    font-size: 0.9rem;
}

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

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

/* Calculator card visibility */
.calculator-card.hidden {
    display: none;
}

/* Responsive design */
@media (max-width: 768px) {
    .search-box input {
        font-size: 1rem;
        padding: 14px 45px 14px 18px;
    }
    
    .category-filters {
        gap: 0.5rem;
    }
    
    .category-btn {
        font-size: 0.8rem;
        padding: 8px 16px;
        min-height: 40px;
    }
    
    .category-navigation h3 {
        font-size: 1.3rem;
        margin-bottom: 1rem;
    }
    header h1 {
        font-size: 2rem;
    }
    
    .tagline {
        font-size: 1rem;
    }
    
    .hero h2 {
        font-size: 1.5rem;
    }
    
    .popular-grid {
        grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
        gap: 1rem;
    }
    
    .popular-card {
        padding: 1rem;
    }
    
    .popular-icon {
        font-size: 2rem;
    }
    
    .popular-card h3 {
        font-size: 1rem;
    }
    
    .popular-card p {
        font-size: 0.85rem;
    }
    
    .most-popular h2 {
        font-size: 1.5rem;
        margin-bottom: 1.5rem;
    }
    
    .calculators-grid {
        grid-template-columns: 1fr;
        gap: 1.5rem;
    }
    
    .calculator-card {
        padding: 1.5rem;
    }
    
    .modal-content {
        margin: 10% auto;
        width: 95%;
        padding: 1.5rem;
    }
    
    .form-row {
        grid-template-columns: 1fr;
        gap: 0;
    }
}

/* Tip calculator preset buttons */
.tip-preset {
    background: #e9ecef;
    border: 2px solid #dee2e6;
    border-radius: 4px;
    padding: 8px 16px;
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    color: #495057;
}

.tip-preset:hover {
    background: #667eea;
    border-color: #667eea;
    color: white;
    transform: translateY(-1px);
}

.tip-preset:active {
    transform: translateY(0);
}

@media (max-width: 480px) {
    .container {
        padding: 0 15px;
    }
    
    header {
        padding: 1.5rem 0;
    }
    
    main {
        padding: 2rem 0;
    }
    
    .calculator-card {
        padding: 1.2rem;
    }
    
    .modal-content {
        padding: 1rem;
        margin: 5% auto;
    }
    
    /* Enhanced mobile touch targets */
    .calc-button,
    .calculate-btn {
        min-height: 48px; /* WCAG AA touch target */
        padding: 14px 20px;
        font-size: 1rem;
    }
    
    .tip-preset {
        min-height: 44px;
        padding: 12px 16px;
    }
    
    .form-group input,
    .form-group select {
        min-height: 48px;
        font-size: 16px; /* Prevents zoom on iOS */
    }
    
    .value-props {
        flex-direction: column;
        align-items: center;
        gap: 1.5rem;
    }
    
    .search-box {
        max-width: 100%;
    }
    
    .category-filters {
        justify-content: center;
    }
    
    .category-btn {
        font-size: 0.75rem;
        padding: 6px 12px;
        min-height: 36px;
    }
}