﻿/* ============================================================
   Sistema de Gestão de Energia — Penta Engenharia
   style.css — Estilos compartilhados
   ============================================================ */

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --primary:       #1a5c2a;
  --primary-light: #2d8042;
  --primary-dark:  #0d3d1c;
  --accent:        #e07b0a;
  --accent-light:  #f59e2a;
  --text:          #1a1a2e;
  --text-muted:    #64748b;
  --border:        #e2e8f0;
  --bg:            #f1f5f9;
  --white:         #ffffff;
  --success:       #15803d;
  --success-bg:    #dcfce7;
  --warning:       #b45309;
  --warning-bg:    #fef3c7;
  --danger:        #b91c1c;
  --danger-bg:     #fee2e2;
  --info:          #1d4ed8;
  --info-bg:       #dbeafe;
  --sidebar-w:     248px;
  --topbar-h:      56px;
  --radius:        8px;
  --shadow:        0 1px 4px rgba(0,0,0,.08);
  --shadow-md:     0 4px 16px rgba(0,0,0,.12);
}

body {
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
  display: flex;
  min-height: 100vh;
}

/* ── SIDEBAR ── */
.sidebar {
  width: var(--sidebar-w);
  background: var(--primary-dark);
  color: #fff;
  position: fixed;
  top: 0; left: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  z-index: 200;
  overflow-y: auto;
}

.sidebar-brand {
  padding: 18px 16px 16px;
  border-bottom: 1px solid rgba(255,255,255,.08);
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
}

.brand-icon {
  width: 44px; height: 44px;
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  overflow: hidden;
  background: #fff;
  padding: 2px;
}
.brand-icon img { width: 100%; height: 100%; object-fit: contain; }

.brand-texts { display: flex; flex-direction: column; }
.brand-name  { font-size: 16px; font-weight: 800; color: #fff; letter-spacing: .5px; }
.brand-sub   { font-size: 10px; color: rgba(255,255,255,.45); text-transform: uppercase; letter-spacing: 1px; }

.nav-section { padding: 10px 0 4px; }

.nav-label {
  font-size: 9.5px; font-weight: 700;
  color: rgba(255,255,255,.35);
  text-transform: uppercase; letter-spacing: 1.5px;
  padding: 6px 18px 2px;
}

.nav-link {
  display: flex; align-items: center; gap: 9px;
  padding: 9px 18px;
  color: rgba(255,255,255,.7);
  text-decoration: none;
  font-size: 13.5px;
  border-left: 3px solid transparent;
  transition: all .15s;
}
.nav-link:hover { background: rgba(255,255,255,.06); color: #fff; }
.nav-link.active { background: rgba(255,255,255,.1); color: #fff; border-left-color: var(--accent); }
.nav-link .ni { font-size: 15px; width: 18px; text-align: center; flex-shrink: 0; }

.sidebar-user {
  margin: 8px 12px 4px;
  padding: 10px 12px;
  background: rgba(255,255,255,.07);
  border-radius: 8px;
  border: 1px solid rgba(255,255,255,.1);
}
.su-name  { font-size: 13px; font-weight: 700; color: #fff; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.su-role  { font-size: 11px; color: rgba(255,255,255,.5); margin-top: 1px; }
.su-logout {
  margin-top: 6px;
  background: none;
  border: 1px solid rgba(255,255,255,.2);
  border-radius: 4px;
  color: rgba(255,255,255,.6);
  font-size: 11px;
  padding: 2px 10px;
  cursor: pointer;
  transition: .15s;
}
.su-logout:hover { background: rgba(255,255,255,.1); color: #fff; }

.sidebar-footer {
  margin-top: auto;
  padding: 12px 16px;
  border-top: 1px solid rgba(255,255,255,.08);
  font-size: 11px;
  color: rgba(255,255,255,.35);
}

/* ── MAIN ── */
.main {
  margin-left: var(--sidebar-w);
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.topbar {
  height: var(--topbar-h);
  background: var(--white);
  border-bottom: 1px solid var(--border);
  padding: 0 28px;
  display: flex; align-items: center; justify-content: space-between;
  position: sticky; top: 0; z-index: 100;
}
.topbar-title { font-size: 15px; font-weight: 600; }
.topbar-right { display: flex; align-items: center; gap: 10px; }

.content { padding: 24px 28px; flex: 1; }

/* ── PAGE HEADER ── */
.page-header {
  display: flex; align-items: flex-start; justify-content: space-between;
  margin-bottom: 24px;
}
.page-header-left h1 { font-size: 22px; font-weight: 700; color: var(--text); }
.page-header-left p  { color: var(--text-muted); font-size: 13px; margin-top: 2px; }

/* ── STATS ── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.stat-card {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 20px;
  box-shadow: var(--shadow);
  display: flex; flex-direction: column; gap: 2px;
}
.stat-label { font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .5px; color: var(--text-muted); }
.stat-value { font-size: 26px; font-weight: 700; color: var(--primary); line-height: 1.2; }
.stat-sub   { font-size: 11.5px; color: var(--text-muted); }
.stat-card.accent  .stat-value { color: var(--accent); }
.stat-card.success .stat-value { color: var(--success); }
.stat-card.warning .stat-value { color: var(--warning); }

/* ── CARDS ── */
.card {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.card-header {
  padding: 14px 20px;
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
}
.card-title { font-size: 14px; font-weight: 600; }
.card-body  { padding: 20px; }
.card-footer {
  padding: 12px 20px;
  border-top: 1px solid var(--border);
  display: flex; align-items: center; justify-content: flex-end; gap: 10px;
}

/* ── GRID LAYOUTS ── */
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 20px; }

/* ── BUTTONS ── */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 16px;
  border-radius: 6px;
  font-size: 13.5px; font-weight: 500;
  cursor: pointer; border: none;
  transition: all .15s;
  text-decoration: none;
  white-space: nowrap;
  font-family: inherit;
}
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-light); }
.btn-accent  { background: var(--accent); color: #fff; }
.btn-accent:hover { background: var(--accent-light); }
.btn-success { background: var(--success); color: #fff; }
.btn-success:hover { opacity: .88; }
.btn-danger  { background: var(--danger); color: #fff; }
.btn-danger:hover { opacity: .88; }
.btn-outline {
  background: transparent;
  color: var(--primary);
  border: 1.5px solid var(--primary);
}
.btn-outline:hover { background: var(--primary); color: #fff; }
.btn-ghost {
  background: transparent;
  color: var(--text-muted);
  border: 1px solid var(--border);
}
.btn-ghost:hover { background: var(--bg); color: var(--text); }
.btn-sm { padding: 5px 11px; font-size: 12px; }
.btn-lg { padding: 11px 24px; font-size: 15px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

/* ── FORMS ── */
.form-group { margin-bottom: 16px; }
.form-label {
  display: block;
  font-size: 12.5px; font-weight: 600;
  color: var(--text);
  margin-bottom: 5px;
}
.form-label span.req { color: var(--danger); margin-left: 2px; }
.form-control {
  width: 100%;
  padding: 8px 12px;
  border: 1.5px solid var(--border);
  border-radius: 6px;
  font-size: 14px;
  color: var(--text);
  background: var(--white);
  transition: border-color .15s, box-shadow .15s;
  font-family: inherit;
}
.form-control:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(15,45,94,.1);
}
.form-control.readonly { background: var(--bg); color: var(--text-muted); }
select.form-control { cursor: pointer; }
.form-hint { font-size: 11px; color: var(--text-muted); margin-top: 4px; }
.form-error { font-size: 11px; color: var(--danger); margin-top: 4px; }
.form-row { display: grid; gap: 16px; }
.form-row.c2 { grid-template-columns: 1fr 1fr; }
.form-row.c3 { grid-template-columns: 1fr 1fr 1fr; }
.form-row.c4 { grid-template-columns: 1fr 1fr 1fr 1fr; }
.form-section-title {
  font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: 1px;
  color: var(--text-muted); margin: 20px 0 12px;
  padding-bottom: 6px; border-bottom: 1px solid var(--border);
}

/* ── TABLES ── */
.table-wrapper { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
thead tr { background: var(--bg); }
th {
  padding: 9px 14px;
  text-align: left;
  font-size: 11px; font-weight: 700;
  color: var(--text-muted); text-transform: uppercase; letter-spacing: .5px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
td {
  padding: 11px 14px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
tr:last-child td { border-bottom: none; }
tbody tr:hover td { background: #f8fafc; }
td.actions { display: flex; gap: 6px; }

/* ── BADGES ── */
.badge {
  display: inline-flex; align-items: center;
  padding: 2px 9px; border-radius: 100px;
  font-size: 11px; font-weight: 700; white-space: nowrap;
}
.badge-success { background: var(--success-bg); color: var(--success); }
.badge-warning { background: var(--warning-bg); color: var(--warning); }
.badge-danger  { background: var(--danger-bg);  color: var(--danger); }
.badge-info    { background: var(--info-bg);    color: var(--info); }
.badge-gray    { background: #f1f5f9;           color: var(--text-muted); }
.badge-primary { background: #dbeafe;           color: var(--primary); }

/* ── ALERTS ── */
.alert {
  padding: 12px 16px; border-radius: 8px; font-size: 13.5px;
  display: flex; align-items: flex-start; gap: 10px; margin-bottom: 16px;
}
.alert-info    { background: var(--info-bg);    color: #1e3a8a; border: 1px solid #bfdbfe; }
.alert-success { background: var(--success-bg); color: #14532d; border: 1px solid #86efac; }
.alert-warning { background: var(--warning-bg); color: #78350f; border: 1px solid #fde68a; }
.alert-danger  { background: var(--danger-bg);  color: #7f1d1d; border: 1px solid #fca5a5; }

/* ── DROP ZONE ── */
.drop-zone {
  border: 2px dashed var(--border);
  border-radius: 12px; padding: 40px 24px;
  text-align: center; cursor: pointer;
  transition: all .2s; background: #fafbfd;
}
.drop-zone:hover, .drop-zone.dragover {
  border-color: var(--primary);
  background: rgba(15,45,94,.04);
}
.drop-zone.has-file { border-color: var(--success); background: var(--success-bg); }
.drop-zone .dz-icon { font-size: 42px; display: block; margin-bottom: 10px; }
.drop-zone .dz-title { font-size: 15px; font-weight: 600; color: var(--text); margin-bottom: 4px; }
.drop-zone .dz-sub   { font-size: 12.5px; color: var(--text-muted); }

/* ── MODAL ── */
.modal-overlay {
  display: none;
  position: fixed; inset: 0;
  background: rgba(0,0,0,.48);
  z-index: 500;
  align-items: center; justify-content: center;
  padding: 16px;
}
.modal-overlay.open { display: flex; }
.modal {
  background: var(--white);
  border-radius: 12px;
  box-shadow: var(--shadow-md);
  width: 100%; max-width: 560px;
  max-height: 90vh;
  display: flex; flex-direction: column;
}
.modal.modal-lg { max-width: 760px; }
.modal-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
}
.modal-header h3 { font-size: 15px; font-weight: 700; }
.modal-close {
  background: none; border: none; font-size: 22px;
  cursor: pointer; color: var(--text-muted); line-height: 1;
  padding: 0 4px;
}
.modal-close:hover { color: var(--text); }
.modal-body { padding: 20px; overflow-y: auto; flex: 1; }
.modal-footer {
  padding: 14px 20px;
  border-top: 1px solid var(--border);
  display: flex; justify-content: flex-end; gap: 10px;
}

/* ── TABS ── */
.tabs { display: flex; border-bottom: 1px solid var(--border); margin-bottom: 20px; }
.tab-btn {
  padding: 10px 20px; font-size: 13.5px; font-weight: 500;
  color: var(--text-muted); cursor: pointer;
  border-bottom: 2.5px solid transparent; background: none; border-top: none;
  border-left: none; border-right: none; transition: all .15s; font-family: inherit;
}
.tab-btn:hover { color: var(--text); }
.tab-btn.active { color: var(--primary); border-bottom-color: var(--primary); font-weight: 600; }
.tab-pane { display: none; }
.tab-pane.active { display: block; }

/* ── EMPTY STATE ── */
.empty-state { text-align: center; padding: 52px 24px; color: var(--text-muted); }
.empty-state .es-icon { font-size: 52px; margin-bottom: 14px; display: block; }
.empty-state h3 { font-size: 16px; font-weight: 600; color: var(--text); margin-bottom: 6px; }
.empty-state p  { font-size: 13.5px; }

/* ── MISC ── */
.separator  { height: 1px; background: var(--border); margin: 20px 0; }
.text-right  { text-align: right; }
.text-center { text-align: center; }
.text-muted  { color: var(--text-muted); }
.text-success{ color: var(--success); }
.text-danger { color: var(--danger); }
.text-warning{ color: var(--warning); }
.fw-bold     { font-weight: 700; }
.fw-600      { font-weight: 600; }
.fs-12       { font-size: 12px; }
.fs-13       { font-size: 13px; }
.mb-4  { margin-bottom: 4px; }
.mb-8  { margin-bottom: 8px; }
.mb-12 { margin-bottom: 12px; }
.mb-16 { margin-bottom: 16px; }
.mb-20 { margin-bottom: 20px; }
.mb-24 { margin-bottom: 24px; }
.mt-4  { margin-top: 4px; }
.mt-8  { margin-top: 8px; }
.mt-16 { margin-top: 16px; }
.flex  { display: flex; }
.items-center { align-items: center; }
.gap-8  { gap: 8px; }
.gap-12 { gap: 12px; }
.gap-16 { gap: 16px; }
.justify-between { justify-content: space-between; }
.justify-end     { justify-content: flex-end; }
.w-full { width: 100%; }

/* ── LOADING / SPINNER ── */
.spinner {
  width: 20px; height: 20px;
  border: 2.5px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin .7s linear infinite;
  display: inline-block;
}
@keyframes spin { to { transform: rotate(360deg); } }

.loading-overlay {
  display: none;
  position: fixed; inset: 0;
  background: rgba(255,255,255,.75);
  z-index: 400;
  align-items: center; justify-content: center;
  flex-direction: column; gap: 12px;
  font-size: 14px; color: var(--text-muted);
}
.loading-overlay.open { display: flex; }

/* ── TOTAL ROW ── */
.total-row td { font-weight: 700; background: #f8fafc; border-top: 2px solid var(--border) !important; }

/* ── PILL TIPO ── */
.tipo-energisa    { background: #fee2e2; color: #991b1b; }
.tipo-mercado     { background: #dbeafe; color: #1e40af; }

/* ════════════════════════════════════════════════════
   CONTA IMPRESSA — isolada do resto
   ════════════════════════════════════════════════════ */
.conta-print {
  display: none; /* só aparece na impressão ou no painel de preview */
  width: 210mm;
  min-height: 148mm;
  font-family: Arial, Helvetica, sans-serif;
  font-size: 11pt;
  color: #000;
  background: #fff;
  padding: 12mm;
  border: 1px solid #ccc;
  border-radius: 8px;
  margin: 0 auto;
}

.conta-print.preview-mode { display: block; }

.cp-header {
  display: flex; align-items: flex-start; justify-content: space-between;
  margin-bottom: 8mm; padding-bottom: 4mm;
  border-bottom: 3px solid #1a5c2a;
}
.cp-logo-box { display: flex; flex-direction: column; }
.cp-logo-name { font-size: 20pt; font-weight: 900; color: #1a5c2a; letter-spacing: 1px; }
.cp-logo-sub  { font-size: 7.5pt; color: #64748b; text-transform: uppercase; letter-spacing: 1.5px; }

.cp-fatura-info { text-align: right; }
.cp-fatura-info .cp-ref  { font-size: 14pt; font-weight: 700; color: #1a5c2a; }
.cp-fatura-info .cp-venc { font-size: 9pt; color: #64748b; }

.cp-parties {
  display: grid; grid-template-columns: 1fr 1fr; gap: 8mm;
  margin-bottom: 6mm;
}
.cp-party { }
.cp-party-label { font-size: 8pt; font-weight: 700; text-transform: uppercase; color: #64748b; letter-spacing: .8px; margin-bottom: 2mm; }
.cp-party-name  { font-size: 11pt; font-weight: 700; color: #1a5c2a; }
.cp-party-sub   { font-size: 9pt; color: #374151; line-height: 1.4; }

.cp-items { width: 100%; border-collapse: collapse; margin-bottom: 4mm; }
.cp-items th {
  background: #1a5c2a; color: #fff;
  padding: 3mm 4mm; font-size: 9pt;
  text-align: left;
}
.cp-items td { padding: 2.5mm 4mm; font-size: 10pt; border-bottom: 1px solid #e5e7eb; }
.cp-items .num { text-align: right; }
.cp-items tr.rateio-row td { color: #64748b; font-size: 9.5pt; }
.cp-items tr.total-row td {
  font-weight: 700; font-size: 11pt;
  background: #f1f5f9;
  border-top: 2px solid #1a5c2a;
}

.cp-total-box {
  display: flex; justify-content: flex-end;
  margin-bottom: 6mm;
}
.cp-total-inner {
  background: #1a5c2a; color: #fff;
  border-radius: 6px; padding: 4mm 8mm;
  text-align: right;
}
.cp-total-inner .cp-total-label { font-size: 9pt; opacity: .8; }
.cp-total-inner .cp-total-val   { font-size: 20pt; font-weight: 900; }

.cp-obs { font-size: 8.5pt; color: #64748b; border-top: 1px solid #e5e7eb; padding-top: 4mm; }

.cp-footer {
  margin-top: 4mm; font-size: 8pt; color: #94a3b8;
  text-align: center; border-top: 1px solid #f1f5f9; padding-top: 3mm;
}

/* ── PRINT ── */
@media print {
  .sidebar, .topbar, .no-print, .page-header, .card-header .btn { display: none !important; }
  .main { margin-left: 0 !important; }
  .content { padding: 0 !important; }
  body { background: white !important; }
  .conta-print { display: block !important; border: none; padding: 8mm; }
  .preview-wrapper { box-shadow: none !important; }
}
