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

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    line-height: 1.6;
    color: #333;
    background-color: #f8f9fa;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* Header */
header {
    background: linear-gradient(135deg, #dc2626, #b91c1c);
    color: white;
    /* Reduced padding for a smaller header */
    padding: 0.75rem 1rem; 
    text-align: center;
    position: sticky;
    top: 0;
    z-index: 1000;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

header h1 {
    /* Reduced font size */
    font-size: 1.6rem; 
    margin-bottom: 0.2rem;
}

header p {
    /* Reduced font size */
    font-size: 0.9rem; 
    opacity: 0.9;
    margin-bottom: 0.5rem; 
}

/* Unit Toggle Container */
.unit-toggle-container {
    /* Always center on mobile */
    margin-bottom: 0.5rem;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 10px;
}
.unit-toggle-container label {
    font-weight: 600;
    color: white;
    font-size: 0.9rem; /* Smaller label */
}
#unit-switch {
    background: #1f2937;
    color: white;
    border: 1px solid white;
    padding: 0.4rem 0.8rem; /* Smaller padding */
    border-radius: 5px;
    cursor: pointer;
    font-weight: 600;
    appearance: none;
    background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3e%3cpolyline points='6 9 12 15 18 9'%3e%3c/polyline%3e%3c/svg%3e");
    background-repeat: no-repeat;
    background-position: right 0.7em top 50%, 0 0;
    background-size: 0.65em auto, 100%;
    font-size: 0.9rem; /* Smaller select box text */
}

/* --- Desktop/Tablet (Wider Screens) Layout: Make it a single compact bar --- */
@media (min-width: 768px) {
    header {
        /* Use Flexbox to align content and units horizontally */
        display: flex;
        justify-content: space-between;
        align-items: center;
        padding: 0.5rem 1.5rem; /* Even smaller padding */
    }
    
    .unit-toggle-container {
        margin-bottom: 0; 
    }

    /* Move the navigation bar out of the header flex container, if possible, 
       or keep it separate as currently implemented in index.html */
    header h1, header p {
        /* Remove margins to keep them close together */
        margin: 0;
        padding: 0;
    }
    header h1 {
        line-height: 1.2;
    }
    header p {
        display: block;
    }
}


/* Navigation (Refactored for many calculators) */
.main-nav {
    display: flex;
    justify-content: center;
    flex-wrap: wrap;
    gap: 0.5rem;
    padding: 0.5rem 0;
    background: #1f2937; /* Dark background for the nav bar */
    border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.nav-btn {
    color: white;
    text-decoration: none;
    padding: 0.5rem 1rem;
    border-radius: 5px;
    transition: background 0.2s ease, transform 0.1s ease;
    font-size: 0.8rem; /* Reduced font size for navigation buttons */
    font-weight: 500;
    white-space: nowrap;
    border: 1px solid transparent;
}

.nav-btn:hover {
    background: #374151;
}

.nav-btn.active {
    background: #dc2626;
    border-color: #f8fafc;
    font-weight: 600;
}

/* Main Content Area */
main {
    flex-grow: 1;
    padding: 1rem 0;
}

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

/* Introduction Text */
.tool-intro {
    background: #fef3c7;
    padding: 1rem;
    border-radius: 5px;
    margin-top: 1rem;
    color: #92400e;
    font-weight: 500;
}
.tool-intro.hidden {
    display: none;
}

/* Calculator Box */
.calculator-box {
    background: #ffffff;
    padding: 2rem;
    border-radius: 10px;
    box-shadow: 0 10px 15px rgba(0, 0, 0, 0.1);
    margin-top: 1.5rem;
}

.calculator-box.hidden {
    display: none;
}

.calculator-box h2 {
    color: #dc2626;
    margin-bottom: 0.5rem;
    font-size: 1.75rem;
}

.calculator-box .description {
    color: #6b7280;
    margin-bottom: 1.5rem;
    font-size: 0.95rem;
}

.calculator-box h3 {
    color: #374151;
    margin-top: 1.5rem;
    margin-bottom: 1rem;
    border-bottom: 1px solid #e5e7eb;
    padding-bottom: 0.5rem;
}

/* Form and Inputs */
.input-group {
    margin-bottom: 1rem;
}

.input-group label {
    display: block;
    margin-bottom: 0.3rem;
    font-weight: 600;
    color: #374151;
}

.input-group input[type="number"],
.input-group select {
    width: 100%;
    padding: 0.75rem;
    border: 1px solid #d1d5db;
    border-radius: 5px;
    font-size: 1rem;
    transition: border-color 0.2s ease;
}

.input-group input[type="number"]:focus,
.input-group select:focus {
    border-color: #dc2626;
    outline: none;
    box-shadow: 0 0 0 3px rgba(220, 38, 38, 0.2);
}

.input-group small {
    display: block;
    margin-top: 0.2rem;
    color: #6b7280;
    font-size: 0.85rem;
}

/* Buttons */
button[type="submit"] {
    display: block;
    width: 100%;
    padding: 1rem;
    margin-top: 1.5rem;
    background: #dc2626;
    color: white;
    border: none;
    border-radius: 5px;
    font-size: 1.1rem;
    font-weight: 700;
    cursor: pointer;
    transition: background 0.2s ease, transform 0.1s ease;
}

button[type="submit"]:hover {
    background: #b91c1c;
    transform: translateY(-2px);
}

/* Results */
.result {
    margin-top: 2rem;
    padding: 1.5rem;
    background: #f8fafc;
    border-radius: 8px;
    border-left: 4px solid #dc2626;
}

.result.hidden {
    display: none;
}

.result h3 {
    color: #dc2626;
    margin-bottom: 1rem;
    border-bottom: none;
    padding-bottom: 0;
    font-size: 1.5rem;
}

.result p {
    margin-bottom: 0.5rem;
}

.result .badge {
    padding: 0.25rem 0.75rem;
    border-radius: 4px;
    color: white;
    font-weight: bold;
    display: inline-block;
    margin-left: 10px;
}

.result .badge.pass {
    background-color: #10b981; /* Green */
}

.result .badge.fail {
    background-color: #ef4444; /* Red */
}

/* Checklist Group Styling for Passive Tools */
.checklist-group {
    margin-bottom: 1.5rem;
    padding: 1rem;
    border: 1px solid #e5e7eb;
    border-radius: 5px;
}
.checklist-group label {
    font-weight: 500;
    color: #333;
    display: block;
    margin-bottom: 0.5rem;
}
.checklist-group select {
    width: auto;
    display: block;
    min-width: 150px;
    margin-top: 0.5rem;
}
.result h4 {
    color: #374151;
    margin-top: 1rem;
    font-size: 1.25rem;
}
.result ul {
    list-style-type: disc;
    margin-left: 1.5rem;
}
.result li {
    margin-bottom: 0.25rem;
}

/* Footer */
footer {
    margin-top: 2rem;
    padding: 1.5rem 1rem;
    background: #1f2937;
    color: #d1d5db;
    text-align: center;
    font-size: 0.9rem;
}

.footer-links {
    margin-bottom: 1rem;
}

.footer-links a {
    color: #d1d5db;
    margin: 0 0.5rem;
    text-decoration: none;
    transition: color 0.2s ease;
}

.footer-links a:hover {
    color: #fff;
    text-decoration: underline;
}

footer p {
    margin: 0.5rem 0;
}
