:root{
  /* mesmas cores do theme claro já usado */
  --bg: #f6f8fb;
  --surface: #ffffff;
  --border: #e6ecf2;
  --text: #1a2433;
  --muted: #6e7b8f;
  --primary: #1f3b66;  /* azul */
  --accent: #b68c2e;   /* dourado */
  --sidebar: #0f1c2b;  /* azul profundo p/ menu */
  --sidebar-text: #eef3fb;
  --radius: 14px;
}

html, body { height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
}

/* App grid */
.app {
  display: grid;
  grid-template-columns: 260px 1fr;
  grid-template-rows: 64px 1fr;
  grid-template-areas:
    "sidebar topbar"
    "sidebar main";
  height: 100vh;
}

/* Sidebar */
.sidebar {
  grid-area: sidebar;
  background: var(--sidebar);
  color: var(--sidebar-text);
  border-right: 1px solid rgba(255,255,255,.08);
  display: flex;
  flex-direction: column;

  height: 100vh !important;
  max-height: 100vh !important;

  overflow-y: auto !important;
  overflow-x: hidden !important;

  scrollbar-width: thin;
  scrollbar-color: #475569 #0f1c2b;
}

/* Scrollbar Webkit (Chrome, Edge, Safari) */
.sidebar::-webkit-scrollbar {
    width: 6px;
}
.sidebar::-webkit-scrollbar-thumb {
    background: #475569;
    border-radius: 4px;
}
.sidebar::-webkit-scrollbar-track {
    background: #0f1c2b;
}

.side-header {
  display: flex; align-items: center; gap: 12px;
  padding: 16px 18px;
  border-bottom: 1px solid rgba(255,255,255,.08);
}

/* Ajuste visual do logo no menu lateral */
.side-logo {
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 16px 12px;
  background: transparent;
}

/* Imagem do logo */
.side-logo img {
  display: block;                 /* evita espaçamentos estranhos */
  max-width: 85%;
  max-height: 80px;
  width: auto;
  height: auto;
  object-fit: contain;
  transition: transform 0.2s ease, opacity 0.2s ease;
}

/* Efeito sutil ao passar o mouse */
.side-logo img:hover {
  transform: scale(1.05);
  opacity: 0.95;
}

.side-title { font-weight: 700; letter-spacing:.2px; }

.nav {
  padding: 12px;
  overflow: visible !important;
}

.nav a {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  border-radius: 10px;
  color: var(--color-text-light);
  text-decoration: none;
  transition: background 0.2s ease;
}

.nav a i {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
  margin-top: 1px;
}

.nav a:hover { background: rgba(255,255,255,.06); }
.nav a.active {
  background: rgba(182,140,46,.15);
  border-color: rgba(182,140,46,.35);
  color: #fff;
}

.nav hr {
  border: none; border-top: 1px solid rgba(255,255,255,.08);
  margin: 10px 0;
}

/* Topbar */
.topbar {
  grid-area: topbar;
  display: flex; 
  align-items: center; 
  justify-content: space-between;
  padding: 0 18px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}
.topbar h1 { 
  font-size: 18px; 
  margin: 0; 
  font-weight: 700; 
  color: var(--primary); 
}
.user {
  font-size: 14px; color: var(--muted);
}

/* Main / iframe */
.main {
  grid-area: main;
  padding: 14px;
  min-height: 0;
}
.card {
  background: var(--surface); 
  border: 1px solid var(--border);
  border-radius: var(--radius); 
  padding: 12px;
}

iframe.app-frame {
  width: 100%; 
  height: calc(100vh - 64px - 28px);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: #fff;
}

/* Footer dentro do shell */
.site-footer{
  margin-top: 12px; 
  padding: 10px 12px; 
  text-align: center;
  font-size: 12px; 
  color: var(--muted);
  border-top: 1px solid var(--border); 
  background: var(--surface);
}

/* Responsivo: colapsa o menu */
.toggle { display: none; }
@media (max-width: 1000px) {
  .app {
    grid-template-columns: 1fr;
    grid-template-rows: 56px calc(100vh - 56px);
    grid-template-areas:
      "topbar"
      "main";
  }
  .sidebar {
    position: fixed; inset: 0 auto 0 0; width: 260px;
    transform: translateX(-100%);
    transition: transform .25s ease; 
    z-index: 50;
  }
  .sidebar.open { transform: translateX(0); }
  .toggle { display: inline-flex; align-items:center; gap:8px; }
}

/* Avatar + dropdown */
.userbox {
  display: flex;
  align-items: center;
  gap: 10px;
  position: relative;
}
.userbox .avatar {
  width: 60px; height: 60px;
  border-radius: 50%; overflow: hidden;
  border: 2px solid var(--border);
  background: #fff;
  flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
}
.userbox .avatar img {
  width: 100%; height: 100%; 
  object-fit: cover; border-radius: 50%;
}
.userbox .name {
  font-size: 15px; font-weight: 600; color: var(--text);
}
.userbox button.menu{
  background:transparent;border:0;cursor:pointer;
  font-size:16px;line-height:1;padding:4px 6px;color:var(--muted)
}
.dropdown{
  position:absolute;right:0;top:42px;min-width:220px;
  background:#fff;border:1px solid var(--border);border-radius:12px;
  box-shadow:0 10px 24px rgba(28,48,74,.10);display:none;z-index:20;overflow:hidden;
}
.dropdown.open{display:block}
.dropdown a, .dropdown button{
  display:block;width:100%;text-align:left;background:none;border:0;
  cursor:pointer;padding:10px 12px;font-size:14px;color:var(--text);
  text-decoration:none;
}
.dropdown a:hover, .dropdown button:hover{background:#f6f8fb}
.dropdown .section{
  padding:8px 12px;font-size:12px;color:var(--muted);
  border-top:1px solid var(--border)
}

/* Submenu */
.nav .parent { position: relative; }
.nav .parent > a {
  display: flex; align-items: center; gap: 8px;
  padding: 10px 14px; border-radius: 10px;
  color: var(--color-text-light);
  text-decoration: none; transition: background 0.2s ease; 
}
.nav .submenu {
  display: none; 
  padding-left: 8px; 
  margin-top: 6px;
  max-height: 0;
  overflow: hidden;
  transition: max-height .5s ease, opacity .5s ease;
  opacity: 0;
}
.nav .submenu a {
  font-size: 14px; 
  opacity: .95; 
  padding: 8px 10px; 
  border-radius: 8px;
}
.nav .parent.open .submenu { 
  display: block; 
  max-height: 400px;
  opacity: 1;
}
.nav .caret { font-size: 12px; opacity: .8; }

/* Tooltips */
.tooltip { position: relative; display: inline-block; }
.tooltip .tooltiptext {
  visibility: hidden; width: max-content; max-width: 180px;
  background-color: var(--color-primary);
  color: #fff; text-align: center; border-radius: 6px;
  padding: 6px 8px; font-size: 12px;
  position: absolute; z-index: 999;
  bottom: 125%; left: 50%; transform: translateX(-50%);
  opacity: 0; transition: opacity 0.25s ease;
  white-space: nowrap;
  box-shadow: 0 2px 8px rgba(0,0,0,0.15);
}
.tooltip:hover .tooltiptext {
  visibility: visible; opacity: 1;
}

/* Cards grid */
.robos-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 20px;
  padding: 20px;
}
.card-robo {
  background: #fff;
  border-radius: 14px;
  padding: 18px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.08);
  text-align: center;
}
.card-robo h3 {
  font-size: 16px;
  color: var(--color-primary);
  margin-bottom: 8px;
}
.card-robo p {
  font-size: 14px;
  color: #555;
  min-height: 45px;
}
.card-robo .btn {
  margin-top: 10px;
  border-radius: 8px;
  background: var(--color-primary);
  color: #fff;
  padding: 8px 14px;
  border: none;
  cursor: pointer;
  transition: all 0.2s ease;
}
.card-robo .btn:hover {
  background: var(--color-accent);
}
