:root {
    --bg: #121212;
    --card: #1e1e1e;
    --fg: #e0e0e0;
    --border: #333;
    --highlight: #3498db;
    --positive: #2ecc71;
    --negative: #e74c3c;
    --error-bg: rgba(231,76,60,0.1);
    --shadow: rgba(0,0,0,0.5);
    --transition: all 0.3s ease;
}

* {
    box-sizing: border-box;
}

body { 
    background: var(--bg); 
    color: var(--fg); 
    margin: 0; 
    font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
    line-height: 1.5;
}

.rent-calc-modern { 
    max-width: min(900px, 95vw); 
    margin: 1rem auto; 
    padding: 0 1rem; 
}

.rent-calc-modern[aria-busy="true"] { 
    opacity: 0.7; 
    pointer-events: none; 
}

.rent-calc-modern h2 {
    font-size: clamp(1.5rem, 5vw, 2rem); 
    text-align: center; 
    margin: 1.5rem 0;
    color: var(--highlight);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
}

.row { 
    display: flex; 
    flex-wrap: wrap; 
    gap: 1rem;
    margin-bottom: 1rem;
}

.form-group { 
    flex: 1 1 min(100%, 300px); 
    position: relative; 
    min-width: 0;
}

.form-group label { 
    display: block; 
    margin-bottom: 0.5rem; 
    font-weight: 600; 
    color: #bbb;
    font-size: 0.9rem;
}

.form-group .fa-icon {
    position: absolute; 
    left: 12px; 
    top: 50%; 
    transform: translateY(-50%);
    color: #888; 
    pointer-events: none;
    font-size: 0.9rem;
}

.form-group input, 
.form-group select {
    width: 100%; 
    padding: 0.75rem 0.75rem 0.75rem 2.5rem;
    background: var(--card); 
    border: 1px solid var(--border);
    border-radius: 6px; 
    color: var(--fg);
    font-size: 0.95rem;
    transition: var(--transition);
}

.form-group input:focus, 
.form-group select:focus {
    border-color: var(--highlight); 
    outline: none;
    box-shadow: 0 0 0 2px rgba(52,152,219,0.3);
}

button#calculate {
    flex: 1 1 100%; 
    padding: 0.85rem;
    background: var(--highlight); 
    color: #fff; 
    border: none;
    font-size: 1rem; 
    font-weight: 600; 
    border-radius: 6px;
    cursor: pointer; 
    display: flex; 
    align-items: center; 
    justify-content: center;
    gap: 0.5rem;
    transition: var(--transition);
    margin-top: 0.5rem;
}

button#calculate:disabled { 
    background: #555; 
    cursor: not-allowed; 
}

button#calculate:hover:not(:disabled) { 
    background: #2980b9; 
}

button#calculate:active { 
    transform: scale(0.98); 
}

/* Select2 Dark Theme */
.select2-container--default .select2-selection--single {
    background: var(--card); 
    border: 1px solid var(--border); 
    border-radius: 6px;
    height: 46px;
}

.select2-container--default .select2-selection--single .select2-selection__rendered {
    padding-left: 2.5rem;
    line-height: 46px;
    color: var(--fg);
}

.select2-container--default .select2-selection--single .select2-selection__arrow {
    height: 44px;
}

.select2-container--default .select2-results__option--highlighted {
    background: var(--highlight); 
    color: #fff;
}

.select2-dropdown { 
    background: var(--card); 
    border: 1px solid var(--border); 
}

/* Loading and Messages */
.loading, .error-message, .toast {
    text-align: center; 
    margin: 1rem 0; 
    font-size: 0.95rem;
}

.loading { 
    display: none; 
    color: #888; 
    padding: 1rem;
}

.loading .fa-spinner { 
    margin-bottom: 0.5rem; 
    animation: spin 1s linear infinite;
    font-size: 1.5rem;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.error-message {
    display: none; 
    background: var(--error-bg); 
    color: var(--negative);
    padding: 1rem; 
    border-radius: 6px; 
    border: 1px solid rgba(231,76,60,.3);
    font-size: 0.9rem;
}

/* Stats Cards */
.stats-container {
    display: grid; 
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 1rem; 
    margin: 2rem 0;
}

.stats-card {
    background: var(--card); 
    padding: 1.2rem 1rem;
    border-radius: 8px; 
    text-align: center;
    box-shadow: 0 4px 10px var(--shadow);
    border: 1px solid var(--border);
    transition: var(--transition);
}

.stats-card:hover {
    transform: translateY(-3px);
    box-shadow: 0 6px 15px var(--shadow);
}

.stats-card .fa { 
    font-size: 1.5rem; 
    margin-bottom: 0.5rem; 
    color: var(--highlight); 
}

.stats-card h4 { 
    margin: 0; 
    font-size: 0.85rem; 
    color: #bbb; 
    font-weight: 500;
}

.stats-card p { 
    margin: 0.5rem 0 0; 
    font-size: 1.3rem; 
    font-weight: 700; 
}

.positive { color: var(--positive); }
.negative { color: var(--negative); }

/* Chart */
.chart-container {
    display: none;
    position: relative;
    width: 100%;
    height: 400px;
    margin: 2rem 0;
}

#return-chart {
    background: var(--card); 
    border-radius: 8px;
    box-shadow: 0 4px 10px var(--shadow);
    border: 1px solid var(--border);
    padding: 1rem;
}

/* Toast Notification */
.toast {
    position: fixed; 
    bottom: 1rem; 
    right: 1rem;
    background: #27ae60; 
    color: #fff; 
    padding: 0.75rem 1.2rem;
    border-radius: 6px; 
    opacity: 0; 
    pointer-events: none;
    transition: opacity 0.3s;
    font-size: 0.9rem;
    z-index: 1000;
    max-width: calc(100vw - 2rem);
    box-shadow: 0 4px 12px rgba(0,0,0,0.3);
}

.toast.show { 
    opacity: 1; 
    pointer-events: auto; 
}

/* Disclaimer */
.disclaimer {
    margin: 2rem 0 1rem; 
    font-size: 0.8rem; 
    color: #888; 
    text-align: center;
    line-height: 1.6;
}

/* Estilo personalizado para os tooltips do Chart.js */
.chartjs-tooltip {
    backdrop-filter: blur(4px);
    border-radius: 6px !important;
    box-shadow: 0 4px 12px rgba(0,0,0,0.3) !important;
    opacity: 0.95 !important;
    transition: all 0.2s ease !important;
    background: rgba(30, 30, 30, 0.95) !important;
    border: 1px solid var(--highlight) !important;
    padding: 12px !important;
    color: #fff !important;
}

.chartjs-tooltip-key {
    display: none !important;
}

.chartjs-tooltip-body {
    margin: 0 !important;
    font-weight: 600 !important;
}

.chartjs-tooltip-header {
    margin-bottom: 6px !important;
    font-weight: 500 !important;
    opacity: 0.9 !important;
}

/* Responsive Adjustments */
@media (max-width: 768px) {
    .stats-container { 
        grid-template-columns: 1fr 1fr; 
        gap: 0.8rem;
    }
    
    .form-group {
        flex: 1 1 100%;
    }
    
    .chart-container {
        height: 350px;
    }
}

@media (max-width: 480px) {
    .stats-container { 
        grid-template-columns: 1fr; 
    }
    
    .rent-calc-modern {
        padding: 0 0.75rem;
    }
    
    .row {
        gap: 0.75rem;
    }
    
    button#calculate {
        padding: 0.75rem;
    }
    
    .chart-container {
        height: 300px;
        padding: 0;
    }
    
    #return-chart {
        padding: 0.5rem;
    }
}