:root {
    --primary-color: #4F46E5;
    --primary-hover: #4338ca;
    --bg-color: #F3F4F6;
    --card-bg: #ffffff;
    --text-color: #1F2937;
    --border-radius: 12px;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    font-family: 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
}

body {
    background-color: var(--bg-color);
    color: var(--text-color);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    padding: 20px;
    position: relative;
}

/* Classe para elementos ocultos mas acessíveis para leitores de tela */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border-width: 0;
}

.container {
    width: 100%;
    max-width: 500px;
    margin-bottom: 30px;
}

.calculator-card {
    background: var(--card-bg);
    padding: 2rem;
    border-radius: var(--border-radius);
    box-shadow: 0 10px 25px rgba(0,0,0,0.1);
}

h1 {
    text-align: center;
    color: var(--primary-color);
    margin-bottom: 0.5rem;
}

p {
    text-align: center;
    color: #6B7280;
    margin-bottom: 2rem;
    font-size: 0.9rem;
}

/* ================== ANÚNCIOS ================== */
.ad-container-top {
    margin-bottom: 1.5rem;
    min-height: 100px;
    display: flex;
    justify-content: center;
    align-items: center;
}

.ad-container-content {
    margin: 2rem 0;
    min-height: 250px;
    display: flex;
    justify-content: center;
    align-items: center;
}

/* ================== LOADING DO FORMULÁRIO ================== */
.form-wrapper {
    position: relative;
    min-height: 480px;
    background: white;
    transition: min-height 0.5s ease;
}

/* Quando formulário estiver visível, altura automática */
.form-wrapper.has-form {
    min-height: auto;
}

/* Tela de loading */
.form-loading {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    min-height: 480px;
    background: white;
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 100;
    opacity: 1;
    visibility: visible;
    transition: opacity 0.4s ease, visibility 0.4s ease;
}

.form-loading.hidden {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    z-index: -1;
}

.form-loading-content {
    text-align: center;
    padding: 40px;
    width: 100%;
    max-width: 350px;
}

.loading-icon {
    font-size: 50px;
    color: var(--primary-color);
    margin-bottom: 20px;
    animation: pulse 1.2s infinite;
}

@keyframes pulse {
    0%, 100% { transform: scale(1); opacity: 1; }
    50% { transform: scale(1.15); opacity: 0.8; }
}

.loading-text {
    color: #555;
    font-size: 16px;
    margin-bottom: 25px;
    font-weight: 500;
    line-height: 1.4;
}

.progress-container-small {
    width: 100%;
    height: 8px;
    background: #e8e8e8;
    border-radius: 10px;
    overflow: hidden;
    margin-bottom: 12px;
    box-shadow: inset 0 1px 3px rgba(0,0,0,0.1);
}

.progress-bar-small {
    height: 100%;
    width: 0%;
    background: linear-gradient(90deg, var(--primary-color) 0%, #7C3AED 100%);
    border-radius: 10px;
    transition: width 0.1s linear;
    position: relative;
    overflow: hidden;
    box-shadow: 0 2px 4px rgba(79, 70, 229, 0.3);
}

.progress-bar-small::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(
        90deg,
        transparent,
        rgba(255, 255, 255, 0.4),
        transparent
    );
    animation: shimmer 1s infinite;
}

@keyframes shimmer {
    0% { transform: translateX(-100%); }
    100% { transform: translateX(100%); }
}

.loading-percentage-small {
    font-size: 28px;
    font-weight: bold;
    color: var(--primary-color);
    font-family: 'Segoe UI', Tahoma, sans-serif;
    text-shadow: 0 2px 4px rgba(79, 70, 229, 0.2);
}

/* FORMULÁRIO - Inicialmente escondido */
form {
    opacity: 0;
    display: none;
    transform: translateY(20px);
    transition: opacity 0.5s ease, transform 0.5s ease;
}

form.form-visible {
    display: block;
    opacity: 1;
    transform: translateY(0);
    animation: formSlideIn 0.5s ease;
}

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

/* Fieldset para agrupamento semântico */
fieldset {
    border: none;
    padding: 0;
}

legend {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 600;
    font-size: 0.9rem;
}

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

label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 600;
    font-size: 0.9rem;
}

.input-hint {
    display: block;
    color: #6B7280;
    font-size: 0.8rem;
    margin-top: 4px;
}

/* Inputs e Selects */
input[type="number"], select {
    width: 100%;
    padding: 12px;
    border: 1px solid #D1D5DB;
    border-radius: 8px;
    font-size: 1rem;
    transition: border-color 0.2s;
}

input[type="number"]:focus, select:focus {
    outline: 2px solid var(--primary-color);
    outline-offset: 2px;
    border-color: var(--primary-color);
}

/* Grid para inputs menores */
.input-grid {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 10px;
}

/* Radio Buttons */
.radio-group {
    display: flex;
    gap: 20px;
}

.radio-label {
    font-weight: normal;
    display: flex;
    align-items: center;
    gap: 5px;
    cursor: pointer;
}

.radio-label input[type="radio"] {
    cursor: pointer;
}

/* Garantir foco visível para radio buttons */
.radio-label input[type="radio"]:focus {
    outline: 2px solid var(--primary-color);
    outline-offset: 2px;
}

/* Botão */
.btn-calc {
    width: 100%;
    padding: 14px;
    background-color: var(--primary-color);
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: bold;
    cursor: pointer;
    transition: background 0.2s;
}

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

.btn-calc:focus {
    outline: 2px solid var(--primary-color);
    outline-offset: 4px;
}

/* Resultados */
.hidden {
    display: none !important;
}

.result-container {
    margin-top: 2rem;
    padding-top: 2rem;
    border-top: 1px solid #E5E7EB;
    animation: fadeIn 0.5s ease-in;
}

.result-container h2 {
    text-align: center;
    margin-bottom: 1.5rem;
}

.result-box {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
    padding: 12px;
    background: #F9FAFB;
    border-radius: 8px;
    flex-wrap: wrap;
}

.result-box.highlight {
    background: #EEF2FF;
    border: 1px solid #C7D2FE;
}

.result-box.hydration {
    background: #F0F9FF;
    border: 1px solid #BAE6FD;
}

.result-box.macros {
    background: #F0FDF4;
    border: 1px solid #BBF7D0;
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
}

.macros-label {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
}

.info-btn {
    background: none;
    border: 1px solid transparent;
    cursor: pointer;
    font-size: 0.9rem;
    color: #6B7280;
    padding: 4px 8px;
    border-radius: 4px;
    transition: all 0.2s;
}

.info-btn:hover {
    background: rgba(0,0,0,0.05);
    color: var(--primary-color);
}

.info-btn:focus {
    outline: 2px solid var(--primary-color);
    outline-offset: 2px;
}

.macros-value {
    width: 100%;
}

.macro-display {
    display: flex;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 10px;
}

.macro-type {
    padding: 6px 12px;
    border-radius: 6px;
    font-size: 0.9rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    min-width: 120px;
    flex: 1;
}

.macro-type.protein {
    background: #DBEAFE;
    color: #1E40AF;
}

.macro-type.carbs {
    background: #DCFCE7;
    color: #166534;
}

.macro-type.fat {
    background: #FEF3C7;
    color: #92400E;
}

.macro-type strong {
    font-size: 1.1rem;
    margin-top: 2px;
}

.result-box.hydration .value {
    color: #0284C7;
    font-weight: bold;
}

.result-box.macros .value {
    color: #16A34A;
    font-weight: bold;
}

.result-box.highlight .value {
    color: var(--primary-color);
    font-weight: bold;
}

/* Cards de Objetivos */
.goals-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 15px;
    margin-top: 1.5rem;
}

.goal-card {
    padding: 15px;
    border-radius: 8px;
    text-align: center;
    display: flex;
    flex-direction: column;
    gap: 5px;
    position: relative;
}

.goal-card.lose {
    background-color: #FEF2F2;
    color: #B91C1C;
    border: 1px solid #FECACA;
}

.goal-card.gain {
    background-color: #ECFDF5;
    color: #047857;
    border: 1px solid #A7F3D0;
}

.goal-card small {
    color: inherit;
    opacity: 0.8;
    font-size: 0.8rem;
    margin-top: 4px;
}

/* Modal de Informações sobre Macronutrientes */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    padding: 20px;
}

.modal-content {
    background: white;
    border-radius: 12px;
    width: 100%;
    max-width: 500px;
    max-height: 90vh;
    overflow-y: auto;
    animation: modalFadeIn 0.3s ease;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1.2rem;
    border-bottom: 1px solid #E5E7EB;
    position: sticky;
    top: 0;
    background: white;
    border-radius: 12px 12px 0 0;
}

.modal-header h3 {
    color: var(--primary-color);
    margin: 0;
}

.modal-close {
    background: none;
    border: 1px solid transparent;
    font-size: 1.5rem;
    cursor: pointer;
    color: #6B7280;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    transition: all 0.2s;
}

.modal-close:hover {
    background: #F3F4F6;
    color: var(--text-color);
}

.modal-close:focus {
    outline: 2px solid var(--primary-color);
    outline-offset: 2px;
}

.modal-body {
    padding: 1.2rem;
}

.macro-info-card {
    margin-bottom: 1rem;
    border-radius: 8px;
    overflow: hidden;
    border: 1px solid #E5E7EB;
}

.macro-info-header {
    padding: 12px;
    color: white;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.macro-info-header.protein {
    background: #3B82F6;
}

.macro-info-header.carbs {
    background: #10B981;
}

.macro-info-header.fat {
    background: #F59E0B;
}

.macro-info-card ul {
    padding: 12px;
    background: #F9FAFB;
    margin: 0;
}

.macro-info-card li {
    margin-bottom: 8px;
    font-size: 0.9rem;
    line-height: 1.4;
}

.macro-calories {
    font-size: 0.8rem;
    opacity: 0.9;
}

.modal-tips {
    background: #FEF3C7;
    border: 1px solid #FBBF24;
    border-radius: 8px;
    padding: 12px;
    margin-top: 1rem;
}

.modal-tips h4 {
    color: #92400E;
    margin-bottom: 8px;
}

.modal-tips ul {
    padding-left: 20px;
    color: #92400E;
}

.modal-tips li {
    margin-bottom: 6px;
    font-size: 0.9rem;
}

/* Plano de Refeições */
.meal-plan {
    margin-top: 2rem;
    padding: 1.5rem;
    background: #F8FAFC;
    border-radius: 10px;
    border: 1px solid #E2E8F0;
}

.meal-plan h3 {
    text-align: center;
    color: var(--primary-color);
    margin-bottom: 1.2rem;
    font-size: 1.1rem;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.icon {
    font-size: 1.2em;
}

.meal-plan-summary {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
    margin-bottom: 1.5rem;
    background: white;
    padding: 12px;
    border-radius: 8px;
    border: 1px solid #E2E8F0;
}

.summary-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
}

.summary-label {
    font-size: 0.8rem;
    color: #6B7280;
    margin-bottom: 4px;
}

.summary-value {
    font-weight: bold;
    color: var(--primary-color);
    font-size: 0.9rem;
}

/* Distribuição de Refeições */
.meals-distribution {
    margin-bottom: 1.5rem;
}

.meal-item {
    background: white;
    border-radius: 8px;
    padding: 12px;
    margin-bottom: 10px;
    border: 1px solid #E2E8F0;
    display: flex;
    justify-content: space-between;
    align-items: center;
    transition: transform 0.2s;
}

.meal-item:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0,0,0,0.1);
}

.meal-name {
    display: flex;
    align-items: center;
    gap: 10px;
    flex: 1;
}

.meal-icon {
    font-size: 1.2rem;
    width: 30px;
    text-align: center;
}

.meal-time {
    font-weight: 600;
    color: var(--text-color);
}

.meal-calories {
    font-weight: bold;
    color: var(--primary-color);
    font-size: 0.9rem;
}

.meal-percentage {
    font-size: 0.8rem;
    color: #6B7280;
    margin-left: 8px;
}

.meal-tips {
    background: #EFF6FF;
    border: 1px solid #BFDBFE;
    border-radius: 8px;
    padding: 12px;
    margin-top: 1rem;
}

.meal-tips h4 {
    color: #1E40AF;
    margin-bottom: 8px;
    display: flex;
    align-items: center;
    gap: 6px;
}

.meal-tips ul {
    padding-left: 20px;
    color: #1E40AF;
}

.meal-tips li {
    margin-bottom: 6px;
    font-size: 0.9rem;
}

/* Notas e Avisos */
.meal-plan-notes {
    margin-top: 1.5rem;
}

.warning-note {
    background: #FEF3C7;
    border: 1px solid #FBBF24;
    border-radius: 8px;
    padding: 12px;
    margin-bottom: 1.2rem;
}

.warning-note strong {
    color: #92400E;
    display: block;
    margin-bottom: 8px;
}

.warning-note ul {
    padding-left: 20px;
    font-size: 0.85rem;
    color: #92400E;
}

.warning-note li {
    margin-bottom: 4px;
}

/* Macronutrientes */
.macronutrients-info h4 {
    color: var(--text-color);
    margin-bottom: 10px;
    font-size: 0.9rem;
    text-align: center;
}

.macros-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
    margin-bottom: 1rem;
}

.macro-item {
    background: white;
    border-radius: 8px;
    padding: 10px;
    text-align: center;
    border: 1px solid #E2E8F0;
}

.macro-item.protein {
    border-top: 3px solid #3B82F6;
}

.macro-item.carbs {
    border-top: 3px solid #10B981;
}

.macro-item.fat {
    border-top: 3px solid #F59E0B;
}

.macro-name {
    display: block;
    font-weight: 600;
    font-size: 0.85rem;
    margin-bottom: 4px;
}

.macro-percent {
    display: block;
    font-weight: bold;
    color: var(--primary-color);
    font-size: 1rem;
    margin-bottom: 2px;
}

.macro-grams {
    display: block;
    font-size: 0.8rem;
    color: #6B7280;
}

.macro-desc {
    display: block;
    font-size: 0.7rem;
    color: #9CA3AF;
    margin-top: 2px;
}

.macros-explanation {
    background: #F9FAFB;
    border-radius: 8px;
    padding: 12px;
    border: 1px solid #E5E7EB;
    font-size: 0.9rem;
}

.macros-explanation p {
    margin-bottom: 8px;
    text-align: left;
    color: var(--text-color);
}

.macros-explanation p:last-child {
    margin-bottom: 0;
}

/* Simulador de Tempo */
.time-simulator {
    margin-top: 2rem;
    padding: 1.5rem;
    background: #F8FAFC;
    border-radius: 10px;
    border: 1px solid #E2E8F0;
}

.time-simulator h3 {
    text-align: center;
    color: var(--primary-color);
    margin-bottom: 1rem;
    font-size: 1.1rem;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.simulator-box {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.simulator-result {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px;
    background: white;
    border-radius: 8px;
    border: 1px solid #E2E8F0;
}

.simulator-result .label {
    color: #4B5563;
}

.simulator-result .value {
    color: var(--primary-color);
    font-weight: bold;
}

.simulator-note {
    margin-top: 12px;
    text-align: center;
}

.simulator-note small {
    color: #6B7280;
    font-size: 0.75rem;
}

/* Seção de outras calculadoras */
.other-calculators {
    margin-top: 2.5rem;
    padding-top: 2rem;
    border-top: 1px solid #E5E7EB;
}

.other-calculators h3 {
    text-align: center;
    color: var(--primary-color);
    margin-bottom: 1.5rem;
    font-size: 1.2rem;
}

.calc-links-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 12px;
}

.calc-link {
    display: block;
    padding: 15px;
    background: #F9FAFB;
    border-radius: 8px;
    text-decoration: none;
    color: var(--text-color);
    border: 1px solid #E5E7EB;
    transition: all 0.2s;
}

.calc-link:hover {
    background: #EEF2FF;
    border-color: var(--primary-color);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(79, 70, 229, 0.1);
}

.calc-link:focus {
    outline: 2px solid var(--primary-color);
    outline-offset: 2px;
}

.calc-link strong {
    display: block;
    color: var(--primary-color);
    margin-bottom: 5px;
    font-size: 1rem;
}

.calc-link span {
    display: block;
    color: #6B7280;
    font-size: 0.85rem;
    line-height: 1.4;
}

/* Rodapé */
footer {
    width: 100%;
    max-width: 500px;
    text-align: center;
    padding: 1.5rem 0;
    margin-top: 10px;
    border-top: 1px solid #E5E7EB;
}

.footer-links {
    display: flex;
    justify-content: center;
    flex-wrap: wrap;
    gap: 20px;
    margin-bottom: 1rem;
}

.footer-links a {
    color: #6B7280;
    text-decoration: none;
    font-size: 0.9rem;
    transition: color 0.2s;
}

.footer-links a:hover {
    color: var(--primary-color);
}

.footer-links a:focus {
    outline: 2px solid var(--primary-color);
    outline-offset: 2px;
}

.footer-copyright {
    color: #9CA3AF;
    font-size: 0.8rem;
}

/* Responsividade Mobile */
@media (max-width: 480px) {
    .input-grid {
        grid-template-columns: 1fr;
    }
    .goals-grid {
        grid-template-columns: 1fr;
    }
    .calculator-card {
        padding: 1.5rem;
    }
    
    .meal-plan-summary,
    .macros-grid {
        grid-template-columns: 1fr;
    }
    
    .macro-display {
        flex-direction: column;
        gap: 8px;
    }
    
    .modal-content {
        margin: 10px;
    }
    
    .footer-links {
        flex-direction: column;
        gap: 10px;
        align-items: center;
    }
    
    .calc-link {
        padding: 12px;
    }
    
    .meal-plan,
    .time-simulator {
        padding: 1rem;
    }
    
    .meal-item {
        flex-direction: column;
        align-items: flex-start;
        gap: 8px;
    }
    
    .meal-calories {
        align-self: flex-end;
    }
    
    .form-loading-content {
        padding: 30px 20px;
    }
    
    .loading-icon {
        font-size: 40px;
    }
    
    .loading-text {
        font-size: 15px;
    }
    
    .form-wrapper {
        min-height: 520px;
    }
    
    .form-loading {
        min-height: 520px;
    }
}

@media (max-width: 600px) {
    body {
        padding: 15px;
    }
    
    .container {
        margin-bottom: 20px;
    }
    
    .other-calculators {
        margin-top: 2rem;
        padding-top: 1.5rem;
    }
}

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

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