/* ─── tokens ──────────────────────────────────────────────────────────────── */
:root {
  --sidebar-w: 240px;
  --sidebar-collapsed-w: 56px;
  --bg: #f4f6f8;
  --card-bg: #ffffff;
  --border: #e6eaee;
  --radius: 8px;
  --blue: #0071bc;
  --blue-active: #1e5fa3;
  --active-bg: #e8f2fa;
  --text: #0d131c;
  --text-sm: #6b7280;
  --hover: #f2f4f6;
  --font: 'Inter', system-ui, -apple-system, sans-serif;

  --badge-aquecendo-bg: #fdf3e3;
  --badge-aquecendo-text: #b45309;
  --badge-pronto-bg: #e6f4ee;
  --badge-pronto-text: #15803d;
  --badge-caiu-bg: #fee2e2;
  --badge-caiu-text: #dc2626;
  --badge-pausado-bg: #f3f4f6;
  --badge-pausado-text: #6b7280;
  --badge-liberado-bg: #f3f4f6;
  --badge-liberado-text: #6b7280;
}

/* ─── reset ───────────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
body { font-family: var(--font); font-size: 14px; color: var(--text); background: var(--bg); }
a { text-decoration: none; color: inherit; }
button { cursor: pointer; font-family: inherit; }
input, textarea, select { font-family: inherit; font-size: 14px; }

/* ─── login ───────────────────────────────────────────────────────────────── */
#login-overlay {
  display: flex; align-items: center; justify-content: center;
  position: fixed; inset: 0; background: var(--bg); z-index: 1000;
}
.login-card {
  background: var(--card-bg); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 40px; width: 360px; display: flex; flex-direction: column; gap: 24px;
}
.login-card img { height: 36px; object-fit: contain; align-self: flex-start; }
.login-card h1 { font-size: 20px; font-weight: 600; }
.login-card p { color: var(--text-sm); font-size: 13px; }
.login-form { display: flex; flex-direction: column; gap: 12px; }
.login-form input {
  width: 100%; padding: 9px 12px;
  border: 1px solid var(--border); border-radius: var(--radius);
  outline: none; transition: border-color .15s;
}
.login-form input:focus { border-color: var(--blue-active); }
.login-error { color: #dc2626; font-size: 13px; display: none; }
.login-error.visible { display: block; }

/* ─── layout geral ────────────────────────────────────────────────────────── */
#app { display: flex; height: 100vh; overflow: hidden; }

/* ─── sidebar ─────────────────────────────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-w); min-width: var(--sidebar-w);
  background: var(--card-bg); border-right: 1px solid var(--border);
  display: flex; flex-direction: column; overflow: hidden;
  transition: width .2s, min-width .2s;
  flex-shrink: 0;
}
.sidebar.collapsed { width: var(--sidebar-collapsed-w); min-width: var(--sidebar-collapsed-w); }

.sidebar-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 12px 12px; border-bottom: 1px solid var(--border); height: 56px;
}
.sidebar-logo { height: 28px; object-fit: contain; flex: 1; min-width: 0; }
.sidebar-logo-text {
  font-size: 15px; font-weight: 700; color: var(--blue); letter-spacing: -.3px;
  white-space: nowrap; overflow: hidden;
}
.sidebar-toggle {
  background: none; border: none; padding: 4px; color: var(--text-sm);
  border-radius: 6px; flex-shrink: 0;
  display: flex; align-items: center;
}
.sidebar-toggle:hover { background: var(--hover); }
.sidebar.collapsed .sidebar-logo,
.sidebar.collapsed .sidebar-logo-text { display: none; }

.sidebar-nav { flex: 1; padding: 12px 8px; overflow-y: auto; display: flex; flex-direction: column; gap: 2px; }
.nav-section-label {
  font-size: 10.5px; font-weight: 600; color: var(--text-sm); letter-spacing: .8px;
  padding: 4px 8px 8px; text-transform: uppercase;
}
.sidebar.collapsed .nav-section-label { visibility: hidden; }

.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 10px; border-radius: var(--radius);
  color: var(--text); transition: background .1s, color .1s;
  white-space: nowrap; overflow: hidden;
}
.nav-item:hover { background: var(--hover); }
.nav-item.active { background: var(--active-bg); color: var(--blue-active); font-weight: 500; }
.nav-item svg { flex-shrink: 0; width: 17px; height: 17px; }
.nav-item span { overflow: hidden; }
.sidebar.collapsed .nav-item span { display: none; }
.sidebar.collapsed .nav-item { justify-content: center; padding: 8px; }

.sidebar-footer {
  border-top: 1px solid var(--border); padding: 12px;
}
.user-info {
  display: flex; align-items: center; gap: 10px;
  padding: 6px 4px; border-radius: var(--radius);
  overflow: hidden;
}
.user-avatar {
  width: 32px; height: 32px; border-radius: 50%;
  background: var(--blue-active); color: #fff;
  font-size: 12px; font-weight: 600; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
}
.user-details { overflow: hidden; }
.user-name { display: block; font-size: 13px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-role { display: block; font-size: 11px; color: var(--text-sm); }
.sidebar.collapsed .user-details,
.sidebar.collapsed .user-name,
.sidebar.collapsed .user-role { display: none; }
.sidebar.collapsed .user-info { justify-content: center; }

/* ─── conteúdo principal ──────────────────────────────────────────────────── */
.main-wrap { flex: 1; display: flex; flex-direction: column; overflow: hidden; min-width: 0; }

.top-bar {
  height: 56px; background: var(--card-bg); border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 24px; flex-shrink: 0;
}
.page-title { font-size: 15px; font-weight: 600; }
.top-search {
  position: relative; display: flex; align-items: center;
}
.top-search input {
  padding: 7px 12px 7px 34px; border: 1px solid var(--border);
  border-radius: var(--radius); background: var(--bg); outline: none;
  width: 220px; transition: border-color .15s;
}
.top-search input:focus { border-color: var(--blue-active); background: #fff; }
.top-search .search-icon {
  position: absolute; left: 10px; color: var(--text-sm); pointer-events: none;
}
.top-search .search-kbd {
  position: absolute; right: 8px; font-size: 10px; color: var(--text-sm);
  background: var(--hover); padding: 1px 5px; border-radius: 4px;
  border: 1px solid var(--border); pointer-events: none;
}

.page-body { flex: 1; overflow-y: auto; padding: 24px; }

/* ─── cards e grids ───────────────────────────────────────────────────────── */
.card {
  background: var(--card-bg); border: 1px solid var(--border);
  border-radius: var(--radius); overflow: hidden;
}
.card-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 16px; border-bottom: 1px solid var(--border);
}
.card-title { font-size: 14px; font-weight: 600; }
.card-body { padding: 16px; }

.metric-grid {
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px;
  margin-bottom: 24px;
}
@media (max-width: 900px) { .metric-grid { grid-template-columns: repeat(2, 1fr); } }

.metric-card {
  background: var(--card-bg); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 16px;
  display: flex; align-items: flex-start; gap: 12px;
}
.metric-icon {
  width: 36px; height: 36px; border-radius: 8px; background: var(--active-bg);
  color: var(--blue-active); display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.metric-label { font-size: 12px; color: var(--text-sm); margin-bottom: 4px; }
.metric-value { font-size: 26px; font-weight: 700; line-height: 1; }

/* ─── listas ──────────────────────────────────────────────────────────────── */
.list-item {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 16px; cursor: pointer; transition: background .1s;
}
.list-item:not(:last-child) { border-bottom: 1px solid var(--border); }
.list-item:hover { background: var(--hover); }
.list-item-main { flex: 1; min-width: 0; }
.list-item-title { font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.list-item-sub { font-size: 12px; color: var(--text-sm); margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.list-item-right { display: flex; align-items: center; gap: 8px; flex-shrink: 0; margin-left: 12px; }

/* ─── badges ──────────────────────────────────────────────────────────────── */
.badge {
  font-size: 11px; font-weight: 500; padding: 2px 8px;
  border-radius: 20px; white-space: nowrap;
}
.badge-aquecendo { background: var(--badge-aquecendo-bg); color: var(--badge-aquecendo-text); }
.badge-pronto    { background: var(--badge-pronto-bg);    color: var(--badge-pronto-text);    }
.badge-caiu      { background: var(--badge-caiu-bg);      color: var(--badge-caiu-text);      }
.badge-pausado   { background: var(--badge-pausado-bg);   color: var(--badge-pausado-text);   }
.badge-liberado  { background: var(--badge-liberado-bg);  color: var(--badge-liberado-text);  }

/* ─── barra de progresso ──────────────────────────────────────────────────── */
.progress-bar {
  height: 4px; background: var(--border); border-radius: 2px;
  overflow: hidden; width: 80px; display: inline-block; vertical-align: middle; margin-left: 6px;
}
.progress-fill { height: 100%; background: var(--blue-active); border-radius: 2px; transition: width .3s; }

/* ─── botões ──────────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 14px; border-radius: var(--radius); border: none;
  font-size: 13px; font-weight: 500; transition: opacity .1s, background .1s;
}
.btn:hover { opacity: .88; }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn-primary { background: var(--blue-active); color: #fff; }
.btn-outline { background: transparent; border: 1px solid var(--border); color: var(--text); }
.btn-outline:hover { background: var(--hover); }
.btn-danger  { background: #fee2e2; color: #dc2626; }
.btn-sm { padding: 5px 10px; font-size: 12px; }

/* ─── formulários ─────────────────────────────────────────────────────────── */
.form-group { display: flex; flex-direction: column; gap: 5px; }
.form-label { font-size: 12px; font-weight: 500; color: var(--text-sm); }
.form-input {
  padding: 8px 10px; border: 1px solid var(--border); border-radius: var(--radius);
  outline: none; transition: border-color .15s; background: #fff;
}
.form-input:focus { border-color: var(--blue-active); }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.form-actions { display: flex; gap: 8px; margin-top: 8px; }
.form-hint { font-size: 11px; color: var(--text-sm); }

/* ─── toggle switch ───────────────────────────────────────────────────────── */
.toggle-wrap { display: flex; align-items: center; gap: 10px; }
.toggle {
  position: relative; display: inline-block; width: 42px; height: 24px;
}
.toggle input { opacity: 0; width: 0; height: 0; }
.toggle-slider {
  position: absolute; inset: 0; background: #d1d5db; border-radius: 24px;
  cursor: pointer; transition: background .2s;
}
.toggle-slider::before {
  content: ''; position: absolute; width: 18px; height: 18px; background: #fff;
  border-radius: 50%; top: 3px; left: 3px; transition: transform .2s;
}
.toggle input:checked + .toggle-slider { background: var(--blue-active); }
.toggle input:checked + .toggle-slider::before { transform: translateX(18px); }

/* ─── QR code ─────────────────────────────────────────────────────────────── */
.qr-container {
  display: flex; flex-direction: column; align-items: center; gap: 16px;
  padding: 24px; text-align: center;
}
.qr-container img { width: 200px; height: 200px; border: 4px solid var(--border); border-radius: 8px; }
.pairing-code {
  font-size: 28px; font-weight: 700; letter-spacing: 4px;
  color: var(--blue-active); background: var(--active-bg);
  padding: 12px 24px; border-radius: var(--radius);
}

/* ─── atividade ───────────────────────────────────────────────────────────── */
.activity-item {
  display: flex; align-items: flex-start; gap: 10px;
  padding: 10px 16px; font-size: 13px;
}
.activity-item:not(:last-child) { border-bottom: 1px solid var(--border); }
.activity-dot {
  width: 8px; height: 8px; border-radius: 50%; background: var(--border);
  flex-shrink: 0; margin-top: 4px;
}
.activity-dot.verde   { background: var(--badge-pronto-text); }
.activity-dot.laranja { background: var(--badge-aquecendo-text); }
.activity-dot.vermelho{ background: #dc2626; }
.activity-text { flex: 1; }
.activity-time { font-size: 11px; color: var(--text-sm); flex-shrink: 0; }

/* ─── status indicator ────────────────────────────────────────────────────── */
.status-dot {
  display: inline-block; width: 8px; height: 8px; border-radius: 50%;
  background: var(--border); flex-shrink: 0;
}
.status-dot.on  { background: #22c55e; }
.status-dot.off { background: #6b7280; }

/* ─── top-bar com botões ──────────────────────────────────────────────────── */
.top-bar-actions { display: flex; align-items: center; gap: 12px; }

/* ─── modal simples ───────────────────────────────────────────────────────── */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,.35);
  display: flex; align-items: center; justify-content: center; z-index: 500;
}
.modal-box {
  background: var(--card-bg); border-radius: var(--radius); width: 440px;
  max-height: 90vh; overflow-y: auto;
}
.modal-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 16px; border-bottom: 1px solid var(--border);
}
.modal-title { font-weight: 600; font-size: 15px; }
.modal-close { background: none; border: none; color: var(--text-sm); padding: 4px; border-radius: 4px; }
.modal-close:hover { background: var(--hover); }
.modal-body { padding: 16px; display: flex; flex-direction: column; gap: 14px; }
.modal-footer { padding: 12px 16px; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: 8px; }

/* ─── utilitários ─────────────────────────────────────────────────────────── */
.flex { display: flex; }
.items-center { align-items: center; }
.gap-2 { gap: 8px; }
.gap-3 { gap: 12px; }
.text-sm { font-size: 12px; }
.text-muted { color: var(--text-sm); }
.font-600 { font-weight: 600; }
.mb-4 { margin-bottom: 16px; }
.mb-6 { margin-bottom: 24px; }
.mt-4 { margin-top: 16px; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.w-full { width: 100%; }
.hidden { display: none !important; }
.link { color: var(--blue-active); cursor: pointer; font-size: 12px; }
.link:hover { text-decoration: underline; }
.chip-check { display: flex; align-items: center; gap: 8px; padding: 8px; border: 1px solid var(--border); border-radius: var(--radius); cursor: pointer; }
.chip-check:hover { background: var(--hover); }
.chip-check.selected { border-color: var(--blue-active); background: var(--active-bg); }
.chip-checks-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 8px; }
