* {
    box-sizing: border-box;
}

body {
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    overflow-x: hidden;
}

/* Container wide: até 1600px, responsivo em telas menores */
.container-wide {
    width: 100%;
    max-width: 1600px;
    margin-left: auto;
    margin-right: auto;
    padding-left: 1rem;
    padding-right: 1rem;
}
@media (min-width: 640px) {
    .container-wide {
        padding-left: 1.5rem;
        padding-right: 1.5rem;
    }
}

.modal {
    transition: opacity 0.3s ease;
}

body.modal-active {
    overflow: hidden !important;
}

input[type=number]::-webkit-inner-spin-button, 
input[type=number]::-webkit-outer-spin-button { 
    -webkit-appearance: none; 
    margin: 0; 
}
input[type=number] {
    -moz-appearance: textfield;
}

input[type="range"] {
    -webkit-appearance: none;
    appearance: none;
    width: 100%;
    height: 6px;
    border-radius: 999px;
    cursor: pointer;
    outline: none;
}

input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    height: 18px;
    width: 18px;
    border-radius: 50%;
    border: 3px solid white;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.15);
    cursor: pointer;
    transition: transform 0.15s ease, box-shadow 0.15s ease;
}

input[type="range"]::-webkit-slider-thumb:hover {
    transform: scale(1.1);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

input[type="range"]::-moz-range-thumb {
    height: 18px;
    width: 18px;
    border-radius: 50%;
    border: 3px solid white;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.15);
    cursor: pointer;
    transition: transform 0.15s ease;
}

.slider-blue {
    background: linear-gradient(to right, #dbeafe, #93c5fd);
}
.slider-blue::-webkit-slider-thumb {
    background: linear-gradient(135deg, #3b82f6, #6366f1);
}
.slider-blue::-moz-range-thumb {
    background: linear-gradient(135deg, #3b82f6, #6366f1);
}

.slider-emerald {
    background: linear-gradient(to right, #d1fae5, #6ee7b7);
}
.slider-emerald::-webkit-slider-thumb {
    background: linear-gradient(135deg, #10b981, #14b8a6);
}
.slider-emerald::-moz-range-thumb {
    background: linear-gradient(135deg, #10b981, #14b8a6);
}

.slider-amber {
    background: linear-gradient(to right, #fef3c7, #fcd34d);
}
.slider-amber::-webkit-slider-thumb {
    background: linear-gradient(135deg, #f59e0b, #ea580c);
}
.slider-amber::-moz-range-thumb {
    background: linear-gradient(135deg, #f59e0b, #ea580c);
}

.slider-teal {
    background: linear-gradient(to right, #ccfbf1, #5eead4);
}
.slider-teal::-webkit-slider-thumb {
    background: linear-gradient(135deg, #14b8a6, #0d9488);
}
.slider-teal::-moz-range-thumb {
    background: linear-gradient(135deg, #14b8a6, #0d9488);
}

.slider-violet {
    background: linear-gradient(to right, #ede9fe, #c4b5fd);
}
.slider-violet::-webkit-slider-thumb {
    background: linear-gradient(135deg, #8b5cf6, #7c3aed);
}
.slider-violet::-moz-range-thumb {
    background: linear-gradient(135deg, #8b5cf6, #7c3aed);
}

.slider-rose {
    background: linear-gradient(to right, #ffe4e6, #fda4af);
}
.slider-rose::-webkit-slider-thumb {
    background: linear-gradient(135deg, #f43f5e, #e11d48);
}
.slider-rose::-moz-range-thumb {
    background: linear-gradient(135deg, #f43f5e, #e11d48);
}

input:focus {
    outline: none;
}

.input-group input:focus {
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
}

/* Consistent label height with or without tooltip */
.label-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    min-height: 20px;
    margin-bottom: 4px;
}

.label-row label {
    flex: 1;
}

/* Análise IA: seções e bullets */
#aiAnalysisContent {
    line-height: 1.6;
}
#aiAnalysisContent strong {
    color: #334155;
}
#aiAnalysisContent .ai-bullet {
    display: block;
    margin-left: 1rem;
    margin-top: 0.35rem;
    padding-left: 0.5rem;
    border-left: 2px solid #6366f1;
    color: #475569;
}
#aiAnalysisContent br + strong {
    margin-top: 1rem;
}
#aiAnalysisContent br + strong:first-of-type {
    margin-top: 0;
}

/* Tooltip (?) em mobile: não ultrapassar a tela */
@media (max-width: 640px) {
    .help-content {
        max-width: min(28rem, calc(100vw - 2rem));
        left: 0;
        right: auto;
    }
}

#barraMargem {
    transition: width 0.5s ease-out, background 0.3s ease;
}

#statusCard {
    transition: background 0.5s ease, box-shadow 0.5s ease;
}

#financialChart {
    max-width: 100%;
    max-height: 192px;
}

::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: #f1f5f9;
    border-radius: 4px;
}

::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: #94a3b8;
}

/* Mobile: área de toque mínima e evitar overflow */
@media (max-width: 768px) {
    header h1 {
        font-size: 1.5rem;
    }
    
    #statusCard {
        text-align: center;
    }
    
    /* Botões e links com área de toque mínima (~44px) */
    button:not(.help-trigger),
    a.inline-flex {
        min-height: 44px;
        display: inline-flex;
        align-items: center;
        justify-content: center;
    }
    
    .progress-step {
        padding: 0.5rem 0.4rem;
        min-height: 44px;
        display: inline-flex;
        align-items: center;
        justify-content: center;
    }
    
    .progress-steps {
        gap: 0.25rem;
    }
    
    /* Tabelas e grids do resultado: scroll horizontal se necessário */
    #step6 .overflow-x-auto {
        -webkit-overflow-scrolling: touch;
    }
    
    /* Ações do resultado: botões em coluna em mobile */
    #step6 .flex-wrap {
        gap: 0.75rem;
    }
}

/* Evitar que conteúdo do step 6 vaze na horizontal */
#step6 {
    overflow-x: hidden;
}

.bg-gradient-profit {
    background: linear-gradient(135deg, #10b981 0%, #14b8a6 100%);
    box-shadow: 0 10px 40px -10px rgba(16, 185, 129, 0.4);
}

.bg-gradient-loss {
    background: linear-gradient(135deg, #ef4444 0%, #f43f5e 100%);
    box-shadow: 0 10px 40px -10px rgba(239, 68, 68, 0.4);
}

.bg-gradient-neutral {
    background: linear-gradient(135deg, #6b7280 0%, #9ca3af 100%);
    box-shadow: 0 10px 40px -10px rgba(107, 114, 128, 0.4);
}

/* Step content animation */
.step-content {
    animation: fadeIn 0.3s ease-out;
}

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

/* Lead step animation */
.lead-step {
    animation: slideIn 0.4s ease-out;
}

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

/* Cost item hover */
.cost-item {
    transition: background-color 0.2s ease;
    padding: 0.5rem;
    margin: -0.5rem;
    border-radius: 0.75rem;
}

.cost-item:hover {
    background-color: rgba(248, 250, 252, 0.8);
}

/* Button press effect */
button:active:not(:disabled) {
    transform: scale(0.98);
}

/* Tab button transitions */
.tab-btn {
    transition: all 0.2s ease;
}

/* Progress bar */
#progressFill {
    transition: width 0.5s ease-out;
}

/* SweetAlert2 customizations */
.swal2-popup {
    font-family: 'Inter', system-ui, sans-serif !important;
    border-radius: 1rem !important;
}

.swal2-title {
    font-size: 1.25rem !important;
}

.swal2-confirm {
    border-radius: 0.75rem !important;
    padding: 0.75rem 1.5rem !important;
}

.swal2-cancel {
    border-radius: 0.75rem !important;
    padding: 0.75rem 1.5rem !important;
}

/* Tax tab active state */
.tax-tab {
    transition: all 0.2s ease;
}

/* Tooltip styles */
.tooltip-trigger {
    position: relative;
    cursor: help;
}

.tooltip-trigger .tooltip-content {
    visibility: hidden;
    opacity: 0;
    position: absolute;
    bottom: calc(100% + 8px);
    left: 50%;
    transform: translateX(-50%);
    background: #1e293b;
    color: white;
    padding: 8px 12px;
    border-radius: 8px;
    font-size: 12px;
    font-weight: 400;
    white-space: normal;
    width: 250px;
    max-width: 300px;
    z-index: 1000;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    transition: opacity 0.2s ease, visibility 0.2s ease;
    text-align: left;
    line-height: 1.4;
}

.tooltip-trigger .tooltip-content::after {
    content: '';
    position: absolute;
    top: 100%;
    left: 50%;
    transform: translateX(-50%);
    border: 6px solid transparent;
    border-top-color: #1e293b;
}

.tooltip-trigger:hover .tooltip-content {
    visibility: visible;
    opacity: 1;
}

/* Progress header & steps */
.progress-header {
    border-radius: 0 0 12px 12px;
}

.progress-steps {
    margin-top: 2px;
}

.progress-step {
    cursor: pointer;
    transition: color 0.2s ease, background 0.2s ease, transform 0.15s ease;
    padding: 6px 10px;
    border-radius: 8px;
    font-weight: 500;
    color: #64748b;
}

.progress-step:hover:not(.disabled) {
    background: rgba(99, 102, 241, 0.08);
    color: #475569;
}

.progress-step.active {
    color: #6366f1;
    font-weight: 700;
    background: rgba(99, 102, 241, 0.12);
}

.progress-step.completed {
    color: #10b981;
}

.progress-step.completed:hover:not(.disabled) {
    background: rgba(16, 185, 129, 0.08);
}

.progress-step.disabled {
    cursor: not-allowed;
    opacity: 0.5;
}

/* Variable cost item */
.variable-cost-item {
    transition: background-color 0.2s ease;
    padding: 0.5rem;
    margin: -0.5rem;
    border-radius: 0.75rem;
}

.variable-cost-item:hover {
    background-color: rgba(248, 250, 252, 0.8);
}

/* Revenue item */
.revenue-item {
    transition: background-color 0.2s ease;
    padding: 0.5rem;
    margin: -0.5rem;
    border-radius: 0.75rem;
}

.revenue-item:hover {
    background-color: rgba(248, 250, 252, 0.8);
}
