:root {
  --sidebar-width: 248px;
  --sidebar-bg: #1d2433;
  --sidebar-fg: rgba(255, 255, 255, .78);
  --sidebar-active: #00838a; /* turquesa Sintesy (escurecido para contraste com texto branco) */
}

body { background: var(--bs-tertiary-bg); }
[data-bs-theme="dark"] body { background: #12161f; }

.min-w-0 { min-width: 0; }
.text-pre { white-space: pre-wrap; }

/* ---------- Layout ---------- */
.app { display: flex; min-height: 100vh; }
.app-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.app-content { padding: 1.25rem; max-width: 1400px; width: 100%; }
@media (min-width: 992px) { .app-content { padding: 1.75rem 2rem; } }

.app-topbar {
  position: sticky; top: 0; z-index: 1020;
  display: flex; align-items: center; gap: .75rem;
  padding: .75rem 1.25rem; min-height: 60px;
  background: var(--bs-body-bg); border-bottom: 1px solid var(--bs-border-color);
}

.app-sidebar {
  --bs-offcanvas-width: var(--sidebar-width);
  background: var(--sidebar-bg) !important; color: var(--sidebar-fg);
  display: flex; flex-direction: column;
}
@media (min-width: 992px) {
  .app-sidebar { width: var(--sidebar-width); flex-shrink: 0; position: sticky; top: 0; height: 100vh; }
}
.sidebar-brand { display: flex; align-items: center; gap: .75rem; padding: 1.1rem 1.25rem; color: #fff; border-bottom: 1px solid rgba(255,255,255,.08); }
.sidebar-logo img { height: 44px; width: auto; display: block; }
.sidebar-nav { flex: 1; overflow-y: auto; padding: .75rem .5rem; }
.sidebar-title { font-size: .7rem; text-transform: uppercase; letter-spacing: .08em; color: rgba(255,255,255,.4); padding: 1rem .9rem .4rem; }
.app-sidebar .nav-link {
  display: flex; align-items: center; gap: .75rem; color: var(--sidebar-fg);
  border-radius: .5rem; padding: .6rem .9rem; margin-bottom: 2px;
}
.app-sidebar .nav-link .bi { font-size: 1.1rem; width: 1.25rem; text-align: center; }
.app-sidebar .nav-link:hover { color: #fff; background: rgba(255,255,255,.06); }
.app-sidebar .nav-link.active { color: #fff; background: var(--sidebar-active); }
.sidebar-footer { padding: .5rem; border-top: 1px solid rgba(255,255,255,.08); }
.sidebar-footer span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------- Componentes ---------- */
.card { border-color: var(--bs-border-color-translucent); box-shadow: 0 1px 2px rgba(0,0,0,.04); }
.card-header { background: transparent; }

.stat { text-decoration: none; color: inherit; transition: transform .1s; }
a.stat:hover { transform: translateY(-2px); }
.stat-label { font-size: .8rem; color: var(--bs-secondary-color); text-transform: uppercase; letter-spacing: .04em; }
.stat-value { font-size: 2rem; font-weight: 700; line-height: 1.2; }
.stat-sub { font-size: .8rem; color: var(--bs-secondary-color); }

tr.clickable { cursor: pointer; }
.avatar-cell { width: 56px; }
.avatar { width: 44px; height: 44px; border-radius: 50%; object-fit: cover; background: var(--bs-secondary-bg); }

.resident-photo { aspect-ratio: 4 / 3; object-fit: cover; background: var(--bs-secondary-bg); }
.package-photo { max-height: 460px; object-fit: contain; background: var(--bs-secondary-bg); }
.package-photo-empty { height: 260px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: .5rem; color: var(--bs-secondary-color); font-size: 3rem; background: var(--bs-secondary-bg); }
.package-photo-empty span { font-size: 1rem; }
.package-thumb { width: 64px; height: 64px; border-radius: .5rem; overflow: hidden; background: var(--bs-secondary-bg); display: flex; align-items: center; justify-content: center; font-size: 1.6rem; color: var(--bs-warning); flex-shrink: 0; }
.package-thumb img { width: 100%; height: 100%; object-fit: cover; }

/* Câmera */
.camera-stage { position: relative; aspect-ratio: 4 / 3; border-radius: .5rem; overflow: hidden; background: var(--bs-secondary-bg); }
.camera-stage video, .camera-stage img { width: 100%; height: 100%; object-fit: cover; display: block; }
.camera-empty { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; color: var(--bs-secondary-color); gap: .25rem; }

/* Busca de morador (encomendas) */
.picker-results { position: absolute; z-index: 1050; left: 0; right: 0; max-height: 320px; overflow-y: auto; box-shadow: 0 .5rem 1rem rgba(0,0,0,.15); }

.structure-list { max-height: 60vh; overflow-y: auto; }

.sticky-actions { position: sticky; bottom: 0; padding: .75rem 0; background: linear-gradient(to top, var(--bs-tertiary-bg) 70%, transparent); }
[data-bs-theme="dark"] .sticky-actions { background: linear-gradient(to top, #12161f 70%, transparent); }

/* ---------- Login ---------- */
.login-page { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 1rem;
  background: linear-gradient(135deg, #1d2433 0%, #2c3e66 100%); }
.login-card { width: 100%; max-width: 420px; border: 0; }
.login-logo { height: 84px; width: auto; max-width: 100%; }
.logo-on-dark { display: none; }
[data-bs-theme="dark"] .logo-on-light { display: none; }
[data-bs-theme="dark"] .logo-on-dark { display: inline; }

/* ---------- WhatsApp ---------- */
.btn-whatsapp { --bs-btn-color: #fff; --bs-btn-bg: #25d366; --bs-btn-border-color: #25d366;
  --bs-btn-hover-color: #fff; --bs-btn-hover-bg: #1ebe5b; --bs-btn-hover-border-color: #1ebe5b;
  --bs-btn-active-color: #fff; --bs-btn-active-bg: #189d4b; --bs-btn-active-border-color: #189d4b; }
.btn-whatsapp.notified { --bs-btn-bg: #128c7e; --bs-btn-border-color: #128c7e; }

/* ---------- Linha do tempo da encomenda ---------- */
.timeline { padding: 1rem 1rem 1rem 2.25rem; }
.timeline li { position: relative; padding-bottom: 1rem; }
.timeline li:last-child { padding-bottom: 0; }
.timeline li::before { content: ''; position: absolute; left: -1.5rem; top: .3rem; width: .85rem; height: .85rem;
  border-radius: 50%; border: 2px solid var(--bs-secondary-color); background: var(--bs-body-bg); }
.timeline li.done::before { border-color: var(--bs-success); background: var(--bs-success); }
.timeline li:not(:last-child)::after { content: ''; position: absolute; left: calc(-1.5rem + .38rem); top: 1.25rem; bottom: 0;
  width: 2px; background: var(--bs-border-color); }

details.card > summary { cursor: pointer; list-style: none; }
details.card > summary::before { content: '▸ '; }
details.card[open] > summary::before { content: '▾ '; }
details.card > summary::-webkit-details-marker { display: none; }

.sidebar-condo { padding: .75rem 1.25rem; border-bottom: 1px solid rgba(255,255,255,.08); }
.sidebar-condo label { color: rgba(255,255,255,.5); }

/* ---------- Dispositivos ---------- */
.device-card { border-left-width: 5px !important; transition: transform .1s, box-shadow .1s; }
.device-card:hover { transform: translateY(-2px); box-shadow: 0 .25rem .75rem rgba(0,0,0,.08); }

/* ---------- Campo de seleção com digitação (combo.js) ---------- */
.combo-list { position: absolute; z-index: 1060; left: 0; right: 0; top: 100%; max-height: 280px; overflow-y: auto;
  box-shadow: 0 .5rem 1rem rgba(0,0,0,.15); }
.combo-input { background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3e%3cpath fill='none' stroke='%236c757d' stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='m2 5 6 6 6-6'/%3e%3c/svg%3e");
  background-repeat: no-repeat; background-position: right .75rem center; background-size: 16px 12px; padding-right: 2.25rem; }

/* ---------- Seleção de morador do apartamento ---------- */
.resident-pick .list-group-item { cursor: pointer; }
.resident-pick .list-group-item:has(input:checked) { background: var(--bs-primary-bg-subtle); border-color: var(--bs-primary-border-subtle); }

.notice-text { font-size: 1.05rem; }
.template-preview { max-height: 5.5em; overflow: hidden; }

/* ---------- Mapa de acesso ---------- */
.device-map { max-height: 75vh; }
.device-map thead th { background: var(--bs-body-bg); }
.device-map td.map-changed { background: var(--bs-warning-bg-subtle); }

/* ---------- Botões da câmera: mesma altura, sem esticar ---------- */
.camera-actions { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem; }
.camera-actions .btn { flex: 0 0 auto; white-space: nowrap; }
.camera-actions [data-camera-capture] { flex: 1 1 auto; font-weight: 600; }
