/* Reset e configurações básicas */
* {
    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: #f5f5f5;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
    background-color: white;
    box-shadow: 0 0 10px rgba(0,0,0,0.1);
    border-radius: 8px;
}

/* Header */
header {
    text-align: center;
    margin-bottom: 30px;
    padding-bottom: 20px;
    border-bottom: 2px solid #e0e0e0;
}

header h1 {
    color: #2c3e50;
    margin-bottom: 10px;
    font-size: 2.5em;
}

.language-selector {
    margin: 15px 0;
}

.language-selector label {
    margin-right: 10px;
    font-weight: bold;
}

.language-selector select {
    padding: 5px 10px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 14px;
}

header p {
    color: #666;
    font-size: 1.1em;
}

/* Seções */
section {
    margin-bottom: 30px;
    padding: 20px;
    background-color: #fafafa;
    border-radius: 8px;
    border: 1px solid #e0e0e0;
}

section h2 {
    color: #2c3e50;
    margin-bottom: 20px;
    font-size: 1.8em;
    border-bottom: 2px solid #3498db;
    padding-bottom: 10px;
}

/* Fieldsets */
fieldset {
    border: 2px solid #3498db;
    border-radius: 8px;
    padding: 20px;
    margin-bottom: 20px;
    background-color: white;
}

fieldset legend {
    font-weight: bold;
    color: #2c3e50;
    padding: 0 10px;
    font-size: 1.2em;
}

/* Formulários */
.form-group {
    margin-bottom: 15px;
}

.form-group label {
    display: block;
    margin-bottom: 5px;
    font-weight: bold;
    color: #2c3e50;
}

/* Ícones de informação e tooltips */
.info-icon {
    display: inline-block;
    margin-left: 8px;
    cursor: pointer;
    font-size: 14px;
    color: #3498db;
    transition: color 0.3s ease;
    user-select: none;
}

.info-icon:hover {
    color: #2980b9;
}

.tooltip {
    position: absolute;
    background-color: #2c3e50;
    color: white;
    padding: 12px 16px;
    border-radius: 8px;
    font-size: 14px;
    line-height: 1.4;
    max-width: 300px;
    z-index: 1000;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    pointer-events: none;
}

.tooltip::before {
    content: '';
    position: absolute;
    top: -8px;
    left: 50%;
    transform: translateX(-50%);
    border-left: 8px solid transparent;
    border-right: 8px solid transparent;
    border-bottom: 8px solid #2c3e50;
}

.tooltip.show {
    opacity: 1;
    visibility: visible;
}

.tooltip.bottom::before {
    top: auto;
    bottom: -8px;
    border-bottom: none;
    border-top: 8px solid #2c3e50;
}

.tooltip.left::before {
    top: 50%;
    left: -8px;
    transform: translateY(-50%);
    border-left: none;
    border-right: 8px solid #2c3e50;
    border-top: 8px solid transparent;
    border-bottom: 8px solid transparent;
}

.tooltip.right::before {
    top: 50%;
    left: auto;
    right: -8px;
    transform: translateY(-50%);
    border-right: none;
    border-left: 8px solid #2c3e50;
    border-top: 8px solid transparent;
    border-bottom: 8px solid transparent;
}

/* Campos de entrada (amarelo/laranja claro) */
.input-field, input[type="text"]:not([readonly]), input[type="number"]:not([readonly]), 
input[type="email"], input[type="tel"], input[type="date"], textarea, select {
    width: 100%;
    padding: 10px;
    border: 2px solid #f39c12;
    border-radius: 4px;
    font-size: 14px;
    background-color: #fef9e7;
    transition: border-color 0.3s ease;
}

.input-field:focus, input[type="text"]:not([readonly]):focus, 
input[type="number"]:not([readonly]):focus, input[type="email"]:focus, 
input[type="tel"]:focus, input[type="date"]:focus, textarea:focus {
    outline: none;
    border-color: #e67e22;
    box-shadow: 0 0 5px rgba(230, 126, 34, 0.3);
}

/* Campos calculados (azul claro) */
.calculated-field, input[readonly]:not(.final-price) {
    width: 100%;
    padding: 10px;
    border: 2px solid #3498db;
    border-radius: 4px;
    font-size: 14px;
    background-color: #ebf3fd;
    color: #2c3e50;
    font-weight: bold;
}

/* Preço final (verde) */
.final-price {
    width: 100%;
    padding: 12px;
    border: 3px solid #27ae60;
    border-radius: 4px;
    font-size: 16px;
    background-color: #d5f4e6;
    color: #1e8449;
    font-weight: bold;
    text-align: center;
}

/* Grids */
.client-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 15px;
}

.client-grid .full-width {
    grid-column: 1 / -1;
}

.labor-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 15px;
}

.summary-content {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 30px;
    align-items: start;
}

.summary-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 15px;
}

/* Tabelas */
table {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: 15px;
    background-color: white;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

table th {
    background-color: #3498db;
    color: white;
    padding: 12px;
    text-align: left;
    font-weight: bold;
}

table td {
    padding: 10px 12px;
    border-bottom: 1px solid #e0e0e0;
}

table tbody tr:hover {
    background-color: #f8f9fa;
}

table tfoot td {
    background-color: #ecf0f1;
    font-weight: bold;
    border-top: 2px solid #3498db;
}

table input {
    border: 1px solid #ddd;
    padding: 5px;
    border-radius: 3px;
    width: 100%;
}

/* Botões */
button {
    background-color: #3498db;
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
    font-weight: bold;
    transition: background-color 0.3s ease;
}

button:hover {
    background-color: #2980b9;
}

.remove-btn {
    background-color: #e74c3c;
    padding: 5px 10px;
    font-size: 12px;
}

.remove-btn:hover {
    background-color: #c0392b;
}

/* Gráfico */
.chart-container {
    position: relative;
    height: 400px;
    width: 100%;
}

/* Mensagem de erro */
.error-message {
    background-color: #f8d7da;
    color: #721c24;
    padding: 15px;
    border: 1px solid #f5c6cb;
    border-radius: 4px;
    margin-top: 15px;
    font-weight: bold;
}

/* Responsividade */
@media (max-width: 768px) {
    .container {
        padding: 10px;
        margin: 10px;
    }
    
    header h1 {
        font-size: 2em;
    }
    
    /* Cliente info em coluna única */
    .client-grid {
        grid-template-columns: 1fr;
    }
    
    /* Tabelas como cards */
    .materials-table, .expenses-table {
        border: 0;
    }
    
    .materials-table thead, .expenses-table thead {
        display: none;
    }
    
    .materials-table tbody tr, .expenses-table tbody tr {
        display: block;
        border: 1px solid #ddd;
        border-radius: 8px;
        margin-bottom: 15px;
        padding: 15px;
        background-color: white;
        box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    }
    
    .materials-table tbody td, .expenses-table tbody td {
        display: block;
        border: none;
        padding: 5px 0;
        text-align: left;
    }
    
    .materials-table tbody td:before, .expenses-table tbody td:before {
        content: attr(data-label) ": ";
        font-weight: bold;
        color: #2c3e50;
    }
    
    .materials-table tfoot, .expenses-table tfoot {
        display: block;
        margin-top: 15px;
    }
    
    .materials-table tfoot tr, .expenses-table tfoot tr {
        display: block;
        background-color: #ecf0f1;
        padding: 15px;
        border-radius: 8px;
        border: 2px solid #3498db;
    }
    
    .materials-table tfoot td, .expenses-table tfoot td {
        display: inline;
        border: none;
        padding: 0;
    }
    
    /* Mão de obra em coluna */
    .labor-grid {
        grid-template-columns: 1fr;
    }
    
    /* Resumo em coluna */
    .summary-content {
        grid-template-columns: 1fr;
    }
    
    .chart-container {
        height: 300px;
        margin-top: 20px;
    }
    
    /* Botões largura total */
    button {
        width: 100%;
        margin-bottom: 10px;
    }
    
    /* Tooltips responsivos */
    .tooltip {
        max-width: 250px;
        font-size: 13px;
        padding: 10px 14px;
    }
    
    .info-icon {
        font-size: 16px;
        margin-left: 6px;
    }
}

@media (max-width: 480px) {
    header h1 {
        font-size: 1.5em;
    }
    
    section {
        padding: 15px;
    }
    
    .chart-container {
        height: 250px;
    }
    
    .tooltip {
        max-width: 200px;
        font-size: 12px;
        padding: 8px 12px;
    }
    
    .info-icon {
        font-size: 18px;
        margin-left: 4px;
    }
}

/* Animações */
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}

.materials-table tbody tr, .expenses-table tbody tr {
    animation: fadeIn 0.3s ease;
}

/* Textarea */
textarea {
    min-height: 80px;
    resize: vertical;
}

/* Melhorias visuais */
.form-group input:invalid {
    border-color: #e74c3c;
}

.form-group input:valid {
    border-color: #27ae60;
}

/* Loading state para o gráfico */
.chart-loading {
    display: flex;
    justify-content: center;
    align-items: center;
    height: 400px;
    color: #666;
    font-style: italic;
}