:root {
    --primary-color: #007acc; --light-grey: #f4f7f9; --dark-grey: #333;
    --white: #ffffff; --border-color: #ddd; --success-color: #28a745;
    --warning-color: #e67e22; --dxf-color: #9b59b6; /* Usato anche per Ottimizza */
    --validate-color: #1abc9c;
    --import-color: #3498db;
}
body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif; margin: 0; 
    background-color: var(--light-grey); color: var(--dark-grey); font-size: 14px;
}
header { background-color: var(--primary-color); color: var(--white); padding: 1rem 2rem; text-align: center; box-shadow: 0 2px 4px rgba(0,0,0,0.1); }
.container { display: flex; gap: 1.5rem; padding: 1.5rem; max-width: 1800px; margin: 0 auto; }
hr { border: none; border-top: 1px solid #eee; margin: 1.5rem 0; }
.sidebar {
    flex: 0 0 320px; background-color: var(--white); padding: 1.5rem;
    border-radius: 8px; box-shadow: 0 2px 5px rgba(0,0,0,0.05); border: 1px solid var(--border-color);
    align-self: flex-start; max-height: calc(100vh - 120px); overflow-y: auto;
}
.main-content-area { flex-grow: 1; display: flex; flex-direction: column; gap: 1.5rem; }
.sidebar h2, .main-content-area h2 {
    font-size: 1.1em; color: var(--primary-color); margin-top: 0; padding-bottom: 0.5rem; border-bottom: 2px solid #eee;
}
.sidebar h3, .sidebar summary { font-size: 1em; color: #555; font-weight: bold; }
.sidebar summary { cursor: pointer; padding: 5px 0; }
.sidebar button {
    display: block; width: 100%; padding: 10px; margin-bottom: 8px;
    border: 1px solid var(--border-color); background-color: #f9f9f9; cursor: pointer;
    border-radius: 5px; text-align: left; transition: background-color 0.2s, border-color 0.2s;
}
.sidebar button:hover { background-color: #e9e9e9; }
.sidebar button:disabled { background-color: #f0f0f0; color: #aaa; cursor: not-allowed; }

.sidebar label { display: block; margin-bottom: 10px; font-size: 0.9em; font-weight: 500;}
.sidebar input, .sidebar select { width: 100%; padding: 8px; margin-top: 4px; border-radius: 4px; border: 1px solid #ccc; box-sizing: border-box; }

#component-search { margin-bottom: 1rem; }
.project-management .button-group, .export-controls .button-group { display: flex; gap: 10px; }
.project-management button, .export-controls button { text-align: center; flex: 1; color: var(--white); border: none; }
#save-project-btn { background-color: #5dade2; }
#load-project-btn { background-color: #76d7c4; }
.validate-btn { background-color: var(--validate-color); }
.import-btn { background-color: var(--import-color); }

.main-content-area > section { background: var(--white); padding: 1.5rem; border-radius: 8px; border: 1px solid var(--border-color); }
.project-components-list h3 { font-size: 1em; color: #555; padding-bottom: 5px; border-bottom: 1px solid #eee; margin-top: 1.5rem; margin-bottom: 0.5rem; }
.project-components-list h3:first-child { margin-top: 0; }

#project-list, #field-device-list {
    list-style: none; padding: 0; margin: 0; min-height: 50px; max-height: 150px; overflow-y: auto;
    border: 1px solid #eee; border-radius: 4px;
}
#project-list li, #field-device-list li { padding: 10px; cursor: pointer; border-bottom: 1px solid #eee; display: flex; justify-content: space-between; align-items: center; }
#project-list li { cursor: grab; }
#project-list li:active { cursor: grabbing; background-color: #d4e6f1; }
#project-list li.dragging { opacity: 0.5; background: #aed6f1; }
#project-list li:last-child, #field-device-list li:last-child { border-bottom: none; }
#project-list li:hover, #project-list li.selected, #field-device-list li:hover, #field-device-list li.selected { background-color: #eaf2f8; }
.placeholder { padding: 1rem; color: #888; text-align: center;}
#project-list button, #field-device-list button { width: auto; padding: 2px 8px; font-size: 0.8em; background-color: #fbebeb; color: #c00; border-color: #f5c6cb; border-style: solid; border-width: 1px; color: #c0392b; }
.annotation-panel { flex-grow: 1; }
.io-annotation-row, .connection-row { display: flex; align-items: center; gap: 1rem; margin-bottom: 0.5rem; padding: 5px 8px; border-radius: 4px; }
.io-annotation-row label, .connection-row label { flex: 0 0 150px; font-size: 0.9em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.connection-panel h5 { margin: 1rem 0 10px 0; color: var(--primary-color); border-top: 1px solid #eee; padding-top: 1rem; }
#generate-schema-btn { width: 100%; padding: 15px; font-size: 1.2em; font-weight: bold; background-color: var(--warning-color); color: var(--white); border: none; border-radius: 5px; transition: background-color 0.2s; }
#generate-schema-btn:hover { background-color: #d35400; }
#back-to-config-btn { background-color: #6c757d; }
#export-pdf-btn { background-color: var(--success-color); }
#export-dxf-btn { background-color: var(--dxf-color); }
#bom-table { width: 100%; border-collapse: collapse; }
#bom-table th, #bom-table td { text-align: left; padding: 8px; border-bottom: 1px solid var(--border-color); font-size: 0.9em; }
#bom-table tfoot th { text-align: right; }
#schematic-output-area { display: flex; flex-direction: column; gap: 1rem; background: var(--light-grey);}
.page-container { background-color: var(--white); padding: 20px; border-radius: 8px; box-shadow: 0 4px 12px rgba(0,0,0,0.1); position: relative; border: 1px solid var(--border-color); display: none;}
.page-container.active { display: block; }
.schematic-nav { display: flex; gap: 5px; margin-bottom: -1px; }
.schematic-nav button { padding: 10px 20px; border: 1px solid var(--border-color); border-bottom: none; background-color: #f0f0f0; border-radius: 8px 8px 0 0; cursor: pointer; }
.schematic-nav button.active { background-color: var(--white); font-weight: bold; border-bottom: 1px solid var(--white); }
.project-info-grid { display: grid; grid-template-columns: 100px 1fr; gap: 10px; align-items: center; }
.project-info-grid label { font-weight: normal; }
.optimize-btn { 
    background-color: var(--dxf-color); /* Usiamo il colore viola (dxf) */
    color: var(--white); 
    font-weight: bold; 
    border: none;
    margin-top: 10px;
}

#brand-filters {
    margin-bottom: 15px;
    padding-left: 10px;
}

.brand-filter-item label {
    display: inline;
    margin-left: 5px;
}
