:root {
    /* Color Palette */
    --primary-color: #0ea5e9; /* Sky Blue 500 */
    --primary-hover: #0284c7; /* Sky Blue 600 */
    --primary-light: #e0f2fe; /* Sky Blue 100 */
    --secondary-color: #64748b; /* Slate 500 */
    --secondary-hover: #475569; /* Slate 600 */
    --background-color: #f8fafc; /* Slate 50 */
    --card-bg: #ffffff;
    --text-main: #1e293b; /* Slate 800 */
    --text-muted: #64748b; /* Slate 500 */
    --success-color: #10b981; /* Emerald 500 */
    --border-color: #e2e8f0; /* Slate 200 */
    
    /* Spacing & Radius */
    --radius-md: 12px;
    --radius-lg: 16px;
    --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
    --shadow-md: 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);

    /* Transitions */
    --transition-fast: 0.2s ease;
}

/* Reset & Base */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: 'Inter', sans-serif;
    background-color: var(--background-color);
    color: var(--text-main);
    line-height: 1.6;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

/* Layout Container */
.container {
    width: 100%;
    max-width: 800px; /* Optimal readability width */
    margin: 0 auto;
    padding: 0 20px;
}

/* Header */
.site-header {
    background: var(--card-bg);
    padding: 24px 0;
    text-align: center;
    border-bottom: 1px solid var(--border-color);
    margin-bottom: 30px;
}

.logo-area {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    margin-bottom: 8px;
}

.site-header h1 {
    font-size: 1.8rem;
    font-weight: 700;
    color: var(--text-main);
}

.site-header .highlight {
    color: var(--primary-color);
}

.subtitle {
    color: var(--text-muted);
    font-size: 1rem;
}

/* AdSense Placeholders */
.ad-container {
    width: 100%;
    background-color: #f1f5f9;
    border: 1px dashed #cbd5e1;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #94a3b8;
    font-size: 0.8rem;
    border-radius: var(--radius-md);
    margin: 20px 0;
    position: relative;
    overflow: hidden;
}

.ad-top { height: 90px; } /* Banner Standard */
.ad-middle { height: 250px; } /* Rectangle */

.ad-label {
    position: absolute;
    top: 5px;
    right: 5px;
    font-size: 0.6rem;
    text-transform: uppercase;
    background: #e2e8f0;
    padding: 2px 6px;
    border-radius: 4px;
}

/* Calculator Card */
.calculator-card {
    background: var(--card-bg);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    padding: 30px;
    margin-bottom: 40px;
}

.calculator-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
    flex-wrap: wrap;
    gap: 15px;
}

.calculator-header h2 {
    font-size: 1.25rem;
    font-weight: 600;
}

/* Toggle Switch */
.toggle-container {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 0.9rem;
    color: var(--text-muted);
}

.switch {
    position: relative;
    display: inline-block;
    width: 44px;
    height: 24px;
}

.switch input { opacity: 0; width: 0; height: 0; }

.slider {
    position: absolute;
    cursor: pointer;
    top: 0; left: 0; right: 0; bottom: 0;
    background-color: #cbd5e1;
    transition: .4s;
}

.slider:before {
    position: absolute;
    content: "";
    height: 18px;
    width: 18px;
    left: 3px;
    bottom: 3px;
    background-color: white;
    transition: .4s;
}

input:checked + .slider { background-color: var(--primary-color); }
input:focus + .slider { box-shadow: 0 0 1px var(--primary-color); }
input:checked + .slider:before { transform: translateX(20px); }
.slider.round { border-radius: 34px; }
.slider.round:before { border-radius: 50%; }

/* Grid Layout */
.calculator-grid {
    display: flex;
    flex-wrap: wrap; /* Fallback */
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    gap: 20px; /* Space between inputs */
    align-items: center;
    margin-bottom: 30px;
}

.input-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.w-100-break {
    grid-column: 1 / -1;
    height: 1px;
    background: var(--border-color);
    margin: 10px 0;
    display: none; /* Only show on desktop if needed, usually hiding looks better */
}

/* On Desktop, make it 2x2 logic visually, but actually:
ROW 1: A  equals  B
ROW 2: C  equals  X
Wait, standard is A/B = C/X. Or A -> B, C -> X.
User request: "A está para B assim como C está para X" -> A/B = C/X
Let's do:
A   B
C   X
*/
.calculator-grid {
    grid-template-columns: 1fr 1fr;
    gap: 24px;
}

.separator {
    display: none; /* Hidden on grid layout, used mainly for semantics or mobile flow if completely stack */
}

.input-group label {
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--text-muted);
}

.input-group input {
    width: 100%;
    padding: 12px 16px;
    border: 2px solid var(--border-color);
    border-radius: var(--radius-md);
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text-main);
    transition: var(--transition-fast);
    background: #fff;
}

.input-group input:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 4px var(--primary-light);
}

/* Result Input Styling */
.result-group input {
    background-color: var(--primary-light);
    border-color: var(--primary-color);
    color: var(--primary-color);
    cursor: default;
}

.result-display {
    position: relative;
    display: flex;
    align-items: center;
}

.icon-btn {
    position: absolute;
    right: 12px;
    background: none;
    border: none;
    color: var(--primary-color);
    cursor: pointer;
    font-size: 1.2rem;
    padding: 4px;
    border-radius: 4px;
    transition: var(--transition-fast);
}

.icon-btn:hover {
    background-color: rgba(14, 165, 233, 0.1);
}

/* Actions */
.actions {
    display: flex;
    gap: 16px;
    margin-top: 20px;
}

button {
    flex: 1;
    padding: 14px;
    border: none;
    border-radius: var(--radius-md);
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: var(--transition-fast);
}

.btn-primary {
    background-color: var(--primary-color);
    color: white;
    box-shadow: 0 4px 6px -1px rgba(14, 165, 233, 0.4);
}

.btn-primary:hover {
    background-color: var(--primary-hover);
    transform: translateY(-2px);
    box-shadow: 0 6px 8px -1px rgba(14, 165, 233, 0.5);
}

.btn-primary:active {
    transform: translateY(0);
}

.btn-secondary {
    background-color: white;
    color: var(--secondary-color);
    border: 2px solid var(--border-color);
}

.btn-secondary:hover {
    border-color: var(--secondary-hover);
    color: var(--secondary-hover);
    background-color: #f8fafc;
}

/* Educational Area */
.explanation-area {
    margin-top: 24px;
    padding: 20px;
    background-color: var(--primary-light);
    border-radius: var(--radius-md);
    border-left: 4px solid var(--primary-color);
    animation: fadeIn 0.3s ease-in-out;
}

.explanation-area.hidden {
    display: none;
}

.explanation-area h3 {
    font-size: 1rem;
    margin-bottom: 12px;
    color: var(--primary-color);
    display: flex;
    align-items: center;
    gap: 8px;
}

#explanation-content {
    font-family: monospace;
    color: var(--text-main);
    font-size: 1rem;
    white-space: pre-wrap;
    line-height: 1.8;
}

.example-trigger {
    margin-top: 15px;
    font-size: 0.9rem;
    color: var(--text-muted);
}

.example-trigger a {
    color: var(--primary-color);
    text-decoration: underline;
    cursor: pointer;
}

/* Content Section */
.content-section {
    max-width: 700px;
    margin: 0 auto 60px;
}

.content-section h2 {
    font-size: 1.5rem;
    margin-top: 40px;
    margin-bottom: 15px;
    color: var(--text-main);
}

.content-section h3 {
    font-size: 1.2rem;
    margin-top: 25px;
    margin-bottom: 10px;
    color: var(--text-main);
}

.content-section p, .content-section li {
    margin-bottom: 12px;
    color: var(--text-muted);
}

.content-section ul {
    list-style: none; /* Custom bullets */
    padding-left: 0;
}

.content-section li {
    padding-left: 10px;
}

.formula-box {
    background: #fff;
    border: 1px solid var(--border-color);
    padding: 15px;
    border-radius: var(--radius-md);
    text-align: center;
    font-family: monospace;
    font-size: 1.1rem;
}

details {
    margin-top: 20px;
    background: #fff;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 15px;
    cursor: pointer;
}

summary {
    font-weight: 600;
    color: var(--text-main);
}

.faq-content {
    margin-top: 15px;
    padding-top: 10px;
    border-top: 1px solid var(--border-color);
}

/* Footer */
.site-footer {
    margin-top: auto;
    background: white;
    padding: 30px 0;
    border-top: 1px solid var(--border-color);
    text-align: center;
    color: var(--text-muted);
    font-size: 0.9rem;
}

/* Animations */
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Responsive */
@media (max-width: 600px) {
    .calculator-grid {
        grid-template-columns: 1fr; /* Stack on mobile */
        gap: 16px;
    }
    
    .actions {
        flex-direction: column;
    }

    .site-header {
        padding: 15px 0;
    }

    .site-header h1 {
        font-size: 1.5rem;
    }
}
