/* --- 1. CONFIGURAÇÕES GLOBAIS --- */
:root {
    /* Tema Claro */
    --cor-fundo-light: #fbfbf5;
    --cor-fundo-widget-light: #ffffff;
    --cor-texto-principal-light: #333333;
    --cor-texto-secundario-light: #555555;
    --cor-borda-light: #eeeeee;

    /* Tema Escuro */
    --cor-fundo-dark: #121212;
    --cor-fundo-widget-dark: #1e1e1e;
    --cor-texto-principal-dark: #f1f1f1;
    --cor-texto-secundario-dark: #aaaaaa;
    --cor-borda-dark: #333333;

    /* Cores da Marca */
    --cor-verde-escuro: #3b523b;
    --cor-verde-medio: #5a7d5a;
    --cor-verde-claro: #e6ede6;
    
    --sombra: 0 4px 12px rgba(0, 0, 0, 0.05);
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    margin: 0;
    display: flex;
    min-height: 100vh;
    transition: background-color 0.3s ease;
}

/* --- TEMAS E NAVEGAÇÃO --- */
body.theme-light {
    background-color: var(--cor-fundo-light);
    color: var(--cor-texto-principal-light);
}
body.theme-light .sidebar {
    background-color: var(--cor-fundo-widget-light);
    border-right: 1px solid var(--cor-borda-light);
}
body.theme-light .sidebar nav a { color: var(--cor-texto-secundario-light); }
body.theme-light .sidebar nav a:hover { background-color: var(--cor-verde-claro); color: var(--cor-verde-escuro); }
body.theme-light .sidebar nav a.active { background-color: var(--cor-verde-medio); color: white; }

body.theme-dark {
    background-color: var(--cor-fundo-dark);
    color: var(--cor-texto-principal-dark);
}
body.theme-dark .sidebar {
    background-color: var(--cor-fundo-widget-dark);
    border-right: 1px solid var(--cor-borda-dark);
}
body.theme-dark .sidebar nav a { color: var(--cor-texto-secundario-dark); }
body.theme-dark .sidebar nav a:hover { background-color: #333; color: white; }
body.theme-dark .sidebar nav a.active { background-color: var(--cor-verde-medio); color: white; }

/* Layout Principal */
.content-wrapper { flex: 1; height: 100vh; overflow-y: auto; }
.page { display: none; padding: 32px 48px; }
.page.active { display: block; }

.sidebar {
    width: 240px; padding: 24px; display: flex; flex-direction: column; box-sizing: border-box; flex-shrink: 0; transition: background-color 0.3s ease;
}
.sidebar-header { display: flex; align-items: center; gap: 10px; font-size: 1.4rem; font-weight: 600; color: var(--cor-verde-escuro); margin-bottom: 32px; }
.sidebar-header .material-icons-outlined { font-size: 2rem; color: var(--cor-verde-medio); }
.sidebar nav { display: flex; flex-direction: column; gap: 8px; }
.sidebar nav a { text-decoration: none; padding: 12px 16px; border-radius: 8px; display: flex; align-items: center; gap: 12px; font-weight: 500; transition: all 0.2s ease; cursor: pointer; }
.sidebar nav a .material-icons-outlined { font-size: 1.4rem; }
.sidebar .profile { margin-top: auto; display: flex; align-items: center; gap: 12px; padding: 12px; border-radius: 8px; }
.profile-avatar { width: 40px; height: 40px; border-radius: 50%; background-color: var(--cor-verde-escuro); color: white; display: flex; align-items: center; justify-content: center; font-weight: 600; }

h1 { font-size: 2.5rem; font-weight: 700; margin: 0 0 24px 0; }
h2 { font-size: 1.3rem; font-weight: 600; }

/* --- DASHBOARD --- */
.dashboard-summary { display: grid; grid-template-columns: repeat(4, 1fr); gap: 24px; margin-bottom: 24px; }
.widget { background-color: var(--cor-fundo-widget-light); padding: 24px; border-radius: 12px; box-shadow: var(--sombra); border: 1px solid var(--cor-borda-light); }
.widget-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; }
.widget-header h3 { margin: 0; font-size: 1rem; font-weight: 600; color: var(--cor-texto-secundario-light); }
.widget-header .material-icons-outlined { color: var(--cor-verde-medio); }
.widget-value { font-size: 1.8rem; font-weight: 700; }
.widget-value-small { font-size: 1.5rem; }
.widget-value span { font-size: 1rem; font-weight: 500; color: var(--cor-texto-secundario-light); margin-left: 4px; }

.dashboard-controls { background-color: var(--cor-fundo-widget-light); padding: 20px 24px; border-radius: 12px; box-shadow: var(--sombra); border: 1px solid var(--cor-borda-light); display: flex; justify-content: space-between; align-items: center; margin-bottom: 24px; }
.dashboard-controls label { font-weight: 600; margin-right: 16px; }
.dashboard-controls select { padding: 8px 12px; border-radius: 8px; border: 1px solid #ccc; font-size: 1rem; font-weight: 500; background-color: #f9f9f9; }
.dashboard-controls p { margin: 0; font-size: 0.9rem; color: var(--cor-texto-secundario-light); }

.dashboard-chart { background-color: var(--cor-fundo-widget-light); padding: 24px; border-radius: 12px; box-shadow: var(--sombra); border: 1px solid var(--cor-borda-light); margin-bottom: 24px; }
.chart-header { display: flex; align-items: center; gap: 12px; margin-bottom: 4px; }
#btn-voltar-chart { background: #f0f0f0; border: none; border-radius: 50%; width: 32px; height: 32px; display: none; align-items: center; justify-content: center; cursor: pointer; }
#btn-voltar-chart:hover { background: #e0e0e0; }
.chart-container { position: relative; height: 350px; width: 100%; }

.dashboard-crud { background-color: var(--cor-fundo-widget-light); padding: 24px; border-radius: 12px; box-shadow: var(--sombra); border: 1px solid var(--cor-borda-light); }
.crud-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 16px; }

.btn-primary { background-color: var(--cor-verde-medio); color: white; padding: 10px 16px; border-radius: 8px; border: none; font-weight: 600; font-size: 0.9rem; cursor: pointer; display: flex; align-items: center; gap: 6px; transition: background-color 0.2s; }
.btn-primary:hover { background-color: var(--cor-verde-escuro); }

/* Acordeão e Listas */
.comodo-item { border: 1px solid var(--cor-borda-light); border-radius: 8px; margin-bottom: 12px; overflow: hidden; }
.comodo-header { display: flex; justify-content: space-between; align-items: center; padding: 16px; background-color: #fdfdfd; cursor: pointer; }
.comodo-header:hover { background-color: #f9f9f9; }
.comodo-header h3 { margin: 0; font-size: 1.1rem; font-weight: 600; text-transform: capitalize; }
.comodo-summary { display: flex; align-items: center; gap: 24px; }
.comodo-summary span { font-size: 1rem; font-weight: 500; }
.comodo-summary span.consumo { color: var(--cor-texto-secundario-light); }
.comodo-summary span.custo { color: var(--cor-verde-escuro); font-weight: 600; }
.comodo-summary .material-icons-outlined { transition: transform 0.2s ease; }

.comodo-details { max-height: 0; overflow: hidden; transition: max-height 0.3s ease-out; background-color: white; }
.comodo-details.expanded { max-height: 500px; transition: max-height 0.5s ease-in; }

.aparelho-list { padding: 0 16px 16px 16px; border-top: 1px solid var(--cor-borda-light); }
.aparelho-item { display: flex; justify-content: space-between; align-items: center; padding: 12px 0; border-bottom: 1px solid #f5f5f5; }
.aparelho-item:last-child { border-bottom: none; }
.aparelho-info { display: flex; align-items: center; gap: 12px; }
.aparelho-info .material-icons-outlined { color: var(--cor-texto-secundario-light); }
.aparelho-info span { font-weight: 500; color: var(--cor-texto-secundario-light); font-size: 0.9rem; }
.aparelho-info strong { font-size: 1rem; font-weight: 600; }
.aparelho-valores { text-align: right; }
.aparelho-valores div:first-child { font-weight: 500; color: var(--cor-texto-secundario-light); font-size: 0.9rem; }
.aparelho-valores div:last-child { font-weight: 600; color: var(--cor-verde-escuro); font-size: 0.9rem; }
.aparelho-actions { display: flex; gap: 8px; }
.btn-icon { background: none; border: none; cursor: pointer; color: var(--cor-texto-secundario-light); }
.btn-icon.delete:hover { color: #d9534f; }
.btn-icon.edit:hover { color: var(--cor-verde-medio); }
.comodo-footer { padding: 16px; border-top: 1px solid var(--cor-borda-light); background-color: #fdfdfd; display: flex; justify-content: space-between; }
.btn-link { background: none; border: none; cursor: pointer; color: var(--cor-verde-medio); font-weight: 600; font-size: 0.9rem; display: flex; align-items: center; gap: 4px; }
.btn-link:hover { color: var(--cor-verde-escuro); }
.btn-danger { background: none; border: none; cursor: pointer; color: #d9534f; font-weight: 600; font-size: 0.9rem; display: flex; align-items: center; gap: 4px; }
.btn-danger:hover { color: #a94442; }

/* --- PLANTA --- */
body.theme-dark h1, body.theme-dark h2, body.theme-dark h3 { color: var(--cor-texto-principal-dark); }
.planta-container-wrapper { background-color: var(--cor-fundo-widget-dark); border: 1px solid var(--cor-borda-dark); border-radius: 12px; padding: 24px; box-sizing: border-box; }
.planta-container { position: relative; width: 100%; height: 700px; background-color: #2a2a2a; border-radius: 8px; overflow: hidden; background-image: linear-gradient(to right, #333 1px, transparent 1px), linear-gradient(to bottom, #333 1px, transparent 1px); background-size: 20px 20px; }

.comodo-bloco { position: absolute; background-color: var(--cor-fundo-widget-dark); border: 2px solid var(--cor-verde-medio); border-radius: 8px; box-shadow: 0 4px 10px rgba(0,0,0,0.3); padding: 12px; box-sizing: border-box; cursor: pointer; transition: all 0.2s ease; }
.comodo-bloco:hover { transform: scale(1.02); border-color: #8bc34a; }
.comodo-bloco-header { display: flex; justify-content: space-between; align-items: center; border-bottom: 1px solid var(--cor-borda-dark); padding-bottom: 8px; margin-bottom: 8px; }
.comodo-bloco-header h3 { font-size: 1rem; font-weight: 600; margin: 0; color: var(--cor-texto-principal-dark); text-transform: capitalize; }
.comodo-bloco-header .icon { font-size: 1.2rem; color: var(--cor-texto-secundario-dark); }
.comodo-bloco-body span { display: block; font-size: 0.9rem; color: var(--cor-texto-secundario-dark); }
.comodo-bloco-body strong { font-size: 1.1rem; font-weight: 600; color: #fff; }
.comodo-bloco-body .custo { color: var(--cor-verde-medio); font-weight: 600; }

.modal-overlay { position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: rgba(0,0,0,0.7); display: none; align-items: center; justify-content: center; z-index: 1000; }
.modal-overlay.active { display: flex; }
.modal-content { background: var(--cor-fundo-widget-dark); border: 1px solid var(--cor-borda-dark); padding: 24px; border-radius: 12px; width: 90%; max-width: 500px; box-shadow: 0 10px 30px rgba(0,0,0,0.5); }
.modal-header { display: flex; justify-content: space-between; align-items: center; border-bottom: 1px solid var(--cor-borda-dark); padding-bottom: 16px; margin-bottom: 16px; }
.modal-header h2 { margin: 0; text-transform: capitalize; }
.modal-header .btn-close { background: none; border: none; color: var(--cor-texto-secundario-dark); font-size: 2rem; cursor: pointer; }
.modal-body .aparelho-list { padding: 0; border: none; }
body.theme-dark .aparelho-item { border-bottom: 1px solid var(--cor-borda-dark); }
body.theme-dark .aparelho-info .material-icons-outlined, body.theme-dark .aparelho-info span { color: var(--cor-texto-secundario-dark); }
body.theme-dark .aparelho-info strong { color: var(--cor-texto-principal-dark); }
body.theme-dark .aparelho-valores div:first-child { color: var(--cor-texto-secundario-dark); }

/* --- FICHAS --- */
.fichas-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 24px; }
.fichas-header .filtro-comodo { display: flex; align-items: center; gap: 10px; }
.fichas-header label { font-weight: 600; font-size: 1rem; color: var(--cor-texto-secundario-dark); }
.fichas-header select { background-color: var(--cor-fundo-widget-dark); color: var(--cor-texto-principal-dark); border: 1px solid var(--cor-borda-dark); padding: 8px 12px; border-radius: 8px; font-size: 1rem; }
.fichas-section h2 { font-size: 1.5rem; font-weight: 600; text-transform: capitalize; border-bottom: 2px solid var(--cor-verde-medio); padding-bottom: 8px; margin-top: 32px; margin-bottom: 16px; }
.fichas-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 24px; }
.ficha-card { background-color: var(--cor-fundo-widget-dark); border: 1px solid var(--cor-borda-dark); border-radius: 12px; padding: 20px; box-shadow: 0 4px 12px rgba(0,0,0,0.2); }
.ficha-header { display: flex; align-items: center; gap: 16px; margin-bottom: 16px; }
.ficha-icon { font-size: 2.5rem; color: var(--cor-verde-medio); }
.ficha-header h3 { margin: 0; font-size: 1.2rem; font-weight: 600; color: var(--cor-texto-principal-dark); }
.ficha-body { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.ficha-data-item { background-color: var(--cor-fundo-dark); padding: 10px; border-radius: 6px; border: 1px solid var(--cor-borda-dark); }
.ficha-data-item label { display: block; font-size: 0.85rem; font-weight: 500; color: var(--cor-texto-secundario-dark); margin-bottom: 4px; }
.ficha-data-item span { font-size: 1rem; font-weight: 600; color: var(--cor-texto-principal-dark); }
.ficha-data-item.custo { grid-column: 1 / -1; background-color: var(--cor-verde-claro); border-color: var(--cor-verde-medio); }
.ficha-data-item.custo label { color: var(--cor-verde-escuro); }
.ficha-data-item.custo span { font-size: 1.2rem; font-weight: 700; color: var(--cor-verde-escuro); }

/* --- DICAS --- */
.dicas-container { background-color: var(--cor-fundo-widget-light); border: 1px solid var(--cor-borda-light); border-radius: 12px; padding: 32px; max-width: 900px; margin: 0 auto; }
.dica-categoria { font-size: 1.5rem; font-weight: 600; color: var(--cor-verde-escuro); border-bottom: 2px solid var(--cor-verde-claro); padding-bottom: 8px; margin-top: 24px; margin-bottom: 16px; display: flex; align-items: center; gap: 12px; }
.dica-categoria:first-of-type { margin-top: 0; }
.dica-item { font-size: 1rem; line-height: 1.6; color: var(--cor-texto-secundario-light); margin-bottom: 12px; padding-left: 28px; position: relative; }
.dica-item::before { content: 'check_circle'; font-family: 'Material Icons Outlined'; font-size: 1.2rem; color: var(--cor-verde-medio); position: absolute; left: 0; top: 4px; }