/* ============================================================
   TEATia Painel — Shell (sidebar + topbar)
   Paleta mantém identidade roxa, visual renovado e organizado.
   ============================================================ */
:root {
  --brand: #7c5cbf;
  --brand-dark: #54388f;
  --brand-soft: #f1ebfb;
  --bg: #f5f3fa;
  --card: #ffffff;
  --border: #e7e3f0;
  --text: #241a3d;
  --muted: #6f6b87;
  --sidebar-bg: #221640;
  --sidebar-text: #cfc6e6;
  --sidebar-active: #8b6bd6;
  --ok: #166534; --ok-bg: #dcfce7;
  --warn: #92400e; --warn-bg: #fef3c7;
  --err: #991b1b; --err-bg: #fee2e2;
  --shadow: 0 4px 24px rgba(84, 56, 143, 0.10);
  --radius: 14px;
}
* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: Inter, system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

/* ---------- Shell layout ---------- */
.shell { display: flex; height: 100vh; overflow: hidden; }

/* ---------- Sidebar ---------- */
.sidebar {
  width: 276px;
  flex-shrink: 0;
  background: linear-gradient(180deg, #241740 0%, #1c1232 100%);
  color: var(--sidebar-text);
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  transition: transform 0.25s ease;
  z-index: 40;
}
.brand {
  display: flex; align-items: center; gap: 12px;
  padding: 20px 18px 16px;
  border-bottom: 1px solid rgba(255,255,255,0.08);
}
.brand-badge {
  width: 42px; height: 42px; border-radius: 12px;
  background: rgba(255,255,255,0.12);
  display: grid; place-items: center; font-size: 22px;
}
.brand strong { display: block; color: #fff; font-size: 15px; letter-spacing: .3px; }
.brand span { display: block; font-size: 12px; opacity: 0.75; }
.brand .icon-btn { margin-left: auto; }

.nav { padding: 12px 10px 8px; flex: 1; }
.nav-item {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 12px; border-radius: 12px;
  text-decoration: none; color: var(--sidebar-text);
  transition: background 0.15s, color 0.15s;
  margin-bottom: 2px;
}
.nav-item:hover { background: rgba(255,255,255,0.08); color: #fff; }
.nav-item.active { background: var(--sidebar-active); color: #fff; box-shadow: 0 4px 16px rgba(139,107,214,0.35); }
.nav-ico { font-size: 18px; width: 24px; text-align: center; flex-shrink: 0; }
.nav-txt { display: flex; flex-direction: column; min-width: 0; }
.nav-txt strong { font-size: 13.5px; font-weight: 600; }
.nav-txt small { font-size: 11px; opacity: 0.7; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.nav-item.active small { opacity: 0.92; }

.nav-group { margin-top: 14px; }
.nav-label {
  margin: 0 12px 6px;
  font-size: 10.5px; font-weight: 700; text-transform: uppercase;
  letter-spacing: 0.7px; opacity: 0.55;
}
.nav-home {
  margin-top: 4px;
  background: linear-gradient(135deg, rgba(139,107,214,0.28), rgba(255,255,255,0.06));
  border: 1px solid rgba(255,255,255,0.10);
}
.nav-home.active { border-color: transparent; }

.nav-advanced summary {
  list-style: none; cursor: pointer;
  display: flex; align-items: center; gap: 12px;
  padding: 10px 12px; border-radius: 12px; font-size: 13px; font-weight: 600;
}
.nav-advanced summary::-webkit-details-marker { display: none; }
.nav-advanced summary:hover { background: rgba(255,255,255,0.08); }
.nav-advanced[open] summary { margin-bottom: 4px; }
.nav-advanced summary::after { content: "▸"; margin-left: auto; opacity: .7; transition: transform .2s; }
.nav-advanced[open] summary::after { transform: rotate(90deg); }

.sidebar-foot { padding: 10px; border-top: 1px solid rgba(255,255,255,0.08); }

/* ---------- Main area ---------- */
.main { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.topbar {
  display: flex; align-items: center; gap: 14px;
  padding: 12px 22px;
  background: #fff;
  border-bottom: 1px solid var(--border);
  min-height: 60px;
}
.topbar-title h1 { margin: 0; font-size: 17px; color: var(--text); font-weight: 700; }
.topbar-title p { margin: 1px 0 0; font-size: 12.5px; color: var(--muted); }
.topbar-right { margin-left: auto; }
.user-chip {
  background: var(--brand-soft); color: var(--brand-dark);
  padding: 6px 14px; border-radius: 999px; font-size: 12.5px; font-weight: 600;
}
.content { flex: 1; min-height: 0; overflow: auto; padding: 0; background: var(--bg); }
#frame { width: 100%; height: 100%; border: 0; display: block; background: transparent; }

/* ---------- Buttons ---------- */
.icon-btn {
  width: 36px; height: 36px; border-radius: 10px; border: 0;
  background: transparent; color: inherit; cursor: pointer;
  font-size: 18px; display: grid; place-items: center;
}
.icon-btn:hover { background: rgba(255,255,255,0.12); }
#btn-sidebar-open { display: none; color: var(--text); }
#btn-sidebar-open:hover { background: var(--brand-soft); }
.sidebar-close { display: none; color: #fff; }

/* ---------- Mobile ---------- */
@media (max-width: 860px) {
  #btn-sidebar-open { display: grid; }
  .sidebar {
    position: fixed; top: 0; left: 0; bottom: 0;
    transform: translateX(-100%);
    box-shadow: 8px 0 30px rgba(0,0,0,0.25);
  }
  .sidebar.open { transform: translateX(0); }
  .sidebar-close { display: grid; }
  .scrim {
    position: fixed; inset: 0; background: rgba(20,12,40,0.5);
    opacity: 0; pointer-events: none; transition: opacity .2s; z-index: 30;
  }
  .scrim.show { opacity: 1; pointer-events: auto; }
}