/* ==========================================================================
   Waydroid — painel operacional multi-tenant
   Estático, sem build step. Parte do Ecossistema WayIA.
   ========================================================================== */

:root{
  --bg:#0A0D10;
  --surface:#12161B;
  --surface-2:#181D24;
  --surface-3:#1F252D;
  --surface-raised:#20262F;
  --border:#242A32;
  --border-soft:#1B2027;
  --text:#E7ECEF;
  --text-muted:#8A94A0;
  --text-dim:#5B6470;
  --green:#34D399;
  --green-bright:#3FE0AC;
  --green-dim:#1B3A30;
  --amber:#F5A623;
  --amber-dim:#3A2E14;
  --red:#EF6461;
  --red-dim:#3A1F1E;
  --shadow-sm:0 1px 2px rgba(0,0,0,.24);
  --shadow-md:0 6px 20px -6px rgba(0,0,0,.45);
  --shadow-panel:-16px 0 40px -12px rgba(0,0,0,.55);
  --radius-sm:6px;
  --radius-md:9px;
  --radius-lg:12px;
  --font-display:'Space Grotesk', sans-serif;
  --font-body:'Inter', sans-serif;
  --font-mono:'JetBrains Mono', monospace;
}

*{box-sizing:border-box; margin:0; padding:0;}
html{-webkit-font-smoothing:antialiased; text-rendering:optimizeLegibility;}
body{
  background:var(--bg); color:var(--text); font-family:var(--font-body);
  display:flex; height:100vh; overflow:hidden; font-size:14px; line-height:1.45;
}
::selection{background:var(--green-dim); color:var(--green);}
a{color:inherit;}
button, input, select, textarea{font:inherit;}
:focus-visible{outline:2px solid var(--green); outline-offset:2px; border-radius:4px;}

/* ---------- SIDEBAR ---------- */
.sidebar{
  width:228px; background:var(--surface); border-right:1px solid var(--border);
  display:flex; flex-direction:column; flex-shrink:0;
}
.brand{
  display:flex; align-items:center; gap:11px; padding:22px 18px 19px;
  border-bottom:1px solid var(--border);
}
.brand-mark{
  width:28px; height:28px; border-radius:7px;
  background:linear-gradient(155deg, var(--green-bright), var(--green) 65%);
  display:flex; align-items:center; justify-content:center;
  font-family:var(--font-display); font-weight:700; color:#06110C; font-size:14px;
  box-shadow:0 2px 8px -1px rgba(52,211,153,.35);
}
.brand-name{font-family:var(--font-display); font-weight:600; font-size:16.5px; letter-spacing:-0.01em;}
.brand-sub{font-size:10px; color:var(--text-dim); font-family:var(--font-mono); text-transform:uppercase; letter-spacing:.07em; margin-top:1px;}

.nav{flex:1; padding:16px 10px; display:flex; flex-direction:column; gap:2px; overflow-y:auto;}
.nav-label{font-size:10px; text-transform:uppercase; letter-spacing:.09em; color:var(--text-dim); padding:16px 10px 7px; font-weight:600;}
.nav-label:first-child{padding-top:4px;}
.nav-item{
  display:flex; align-items:center; gap:10px; padding:8.5px 10px; border-radius:7px;
  color:var(--text-muted); cursor:pointer; font-size:13px; font-weight:500; transition:background .12s, color .12s;
  border:none; background:none; width:100%; text-align:left; font-family:var(--font-body);
}
.nav-item:hover{background:var(--surface-2); color:var(--text);}
.nav-item.active{background:var(--green-dim); color:var(--green);}
.nav-item svg{width:16px; height:16px; flex-shrink:0;}

.sidebar-foot{padding:14px; border-top:1px solid var(--border); display:flex; flex-direction:column; gap:12px;}
.host-card{
  background:var(--surface-2); border:1px solid var(--border); border-radius:var(--radius-md); padding:12px 13px;
  font-size:11.5px; color:var(--text-dim); line-height:1.5;
}
.host-card-row{display:flex; justify-content:space-between; align-items:center; gap:8px; padding:2px 0;}
.host-card-row b{color:var(--text-muted); font-weight:500; font-family:var(--font-body);}
.host-card-row span{font-family:var(--font-mono); color:var(--text-dim); max-width:150px; overflow:hidden; text-overflow:ellipsis; white-space:nowrap;}
.host-card-divider{height:1px; background:var(--border); margin:8px 0;}
.host-card-actions{display:flex; gap:12px; margin-top:8px;}
.link-btn{
  background:none; border:none; color:var(--text-dim); font-size:10.5px; cursor:pointer;
  padding:0; text-decoration:underline; text-underline-offset:2px; font-family:var(--font-body);
}
.link-btn:hover{color:var(--green);}
.signature{font-size:10.5px; color:var(--text-dim); text-align:center; letter-spacing:.01em;}
.signature strong{color:var(--text-muted); font-weight:600;}

/* ---------- MAIN ---------- */
.main{flex:1; display:flex; flex-direction:column; min-width:0;}
.topbar{
  height:64px; border-bottom:1px solid var(--border); display:flex; align-items:center;
  justify-content:space-between; padding:0 26px; flex-shrink:0; background:var(--bg);
}
.page-title{font-family:var(--font-display); font-size:17.5px; font-weight:600; letter-spacing:-.01em;}
.page-sub{font-size:12px; color:var(--text-dim); margin-top:2px;}
.topbar-actions{display:flex; gap:10px; align-items:center;}

.btn{
  font-family:var(--font-body); font-size:13px; font-weight:500; padding:8px 14px; border-radius:7px;
  border:1px solid var(--border); background:var(--surface-2); color:var(--text); cursor:pointer;
  display:flex; align-items:center; gap:6px; transition:border-color .12s, background .12s, transform .08s;
}
.btn:hover{border-color:#333b45; background:var(--surface-3);}
.btn:active{transform:translateY(1px);}
.btn-primary{background:var(--green); color:#06110C; border-color:var(--green); font-weight:600;}
.btn-primary:hover{background:var(--green-bright); border-color:var(--green-bright);}
.btn-danger-ghost{color:var(--red); border-color:var(--red-dim); background:var(--red-dim);}
.btn-sm{padding:5px 10px; font-size:12px;}
.btn:disabled{opacity:.55; cursor:default;}

.search{
  background:var(--surface-2); border:1px solid var(--border); border-radius:7px; padding:8px 12px;
  font-size:13px; color:var(--text); width:230px; transition:border-color .12s;
}
.search::placeholder{color:var(--text-dim);}
.search:focus{outline:none; border-color:#333b45;}

/* data-source indicator */
.source-badge{
  display:flex; align-items:center; gap:6px; font-size:11.5px; font-family:var(--font-mono);
  color:var(--text-dim); padding:5px 10px; border-radius:20px; border:1px solid var(--border); background:var(--surface-2);
}
.source-badge .source-dot{width:6px; height:6px; border-radius:50%; background:var(--text-dim); flex-shrink:0;}
.source-badge[data-state="loading"] .source-dot{background:var(--text-dim); animation:pulse 1.2s ease-in-out infinite;}
.source-badge[data-state="live"]{color:var(--green); border-color:var(--green-dim);}
.source-badge[data-state="live"] .source-dot{background:var(--green); box-shadow:0 0 0 3px var(--green-dim);}
.source-badge[data-state="mock"]{color:var(--amber); border-color:var(--amber-dim);}
.source-badge[data-state="mock"] .source-dot{background:var(--amber); box-shadow:0 0 0 3px var(--amber-dim);}
@keyframes pulse{0%,100%{opacity:1;}50%{opacity:.35;}}

.content{flex:1; overflow-y:auto; padding:26px;}

/* error / mock banner */
.banner{
  display:flex; align-items:center; gap:9px; background:var(--amber-dim); border:1px solid #4a3a17;
  color:var(--amber); font-size:12.5px; padding:10px 14px; border-radius:var(--radius-md); margin-bottom:18px; line-height:1.4;
}
.banner.hidden{display:none;}
.banner svg{flex-shrink:0;}

/* stat row */
.stat-row{display:grid; grid-template-columns:repeat(4,1fr); gap:12px; margin-bottom:24px;}
.stat-card{
  background:var(--surface); border:1px solid var(--border); border-radius:var(--radius-lg); padding:16px 18px;
  box-shadow:var(--shadow-sm); transition:border-color .12s;
}
.stat-label{font-size:11px; color:var(--text-dim); text-transform:uppercase; letter-spacing:.06em; margin-bottom:7px; font-weight:600;}
.stat-value{font-family:var(--font-display); font-size:23px; font-weight:600; letter-spacing:-.01em;}
.stat-value.warn{color:var(--amber);}
.stat-value.ok{color:var(--green);}

/* instance grid */
.filters{display:flex; gap:8px; margin-bottom:18px; flex-wrap:wrap;}
.chip{
  font-size:12px; padding:5.5px 12px; border-radius:20px; border:1px solid var(--border);
  color:var(--text-muted); cursor:pointer; background:var(--surface); transition:border-color .12s, background .12s, color .12s;
  user-select:none;
}
.chip:hover{border-color:#333b45; color:var(--text);}
.chip.active{background:var(--surface-3); color:var(--text); border-color:#333b45; font-weight:500;}

.grid{display:grid; grid-template-columns:repeat(auto-fill, minmax(236px,1fr)); gap:14px;}
.card{
  background:var(--surface); border:1px solid var(--border); border-radius:var(--radius-lg); padding:17px;
  cursor:pointer; transition:border-color .14s, transform .12s, box-shadow .14s;
}
.card:hover{border-color:#333b45; transform:translateY(-2px); box-shadow:var(--shadow-md);}
.card.exposed{border-color:var(--red-dim);}
.card.exposed:hover{border-color:#5a2e2c;}
.card-top{display:flex; justify-content:space-between; align-items:flex-start; margin-bottom:11px; gap:8px;}
.card-name{font-family:var(--font-mono); font-size:13px; font-weight:500; word-break:break-word;}
.card-group{font-size:11px; color:var(--text-dim); margin-top:3px;}
.status-dot{width:8px; height:8px; border-radius:50%; display:inline-block; margin-right:6px; flex-shrink:0;}
.status-dot.running{background:var(--green); box-shadow:0 0 0 3px var(--green-dim);}
.status-dot.idle{background:var(--text-dim);}
.status-dot.error{background:var(--red); box-shadow:0 0 0 3px var(--red-dim);}
.status-pill{font-size:11px; padding:3.5px 9px; border-radius:20px; display:flex; align-items:center; font-weight:500; flex-shrink:0; white-space:nowrap;}
.status-pill.running{background:var(--green-dim); color:var(--green);}
.status-pill.idle{background:var(--surface-3); color:var(--text-dim);}
.status-pill.error{background:var(--red-dim); color:var(--red);}

.card-screen{
  height:66px; border-radius:8px; background:var(--surface-2); margin-bottom:11px;
  display:flex; align-items:center; justify-content:center; color:var(--text-dim);
  border:1px solid var(--border-soft);
}
a.card-screen{ text-decoration:none; cursor:pointer; }
a.card-screen:hover{ color:var(--text); border-color:var(--border); }
.card-meta{display:flex; justify-content:space-between; font-size:11.5px; color:var(--text-muted); margin-bottom:7px;}
.card-port{
  font-family:var(--font-mono); font-size:11.5px; display:flex; align-items:center; gap:5px;
  color:var(--text-dim); padding-top:9px; border-top:1px solid var(--border); margin-top:5px;
}
.card-port.exposed{color:var(--red); font-weight:500;}

/* loading skeletons */
.skeleton-card{
  height:174px; border-radius:var(--radius-lg); border:1px solid var(--border);
  background:linear-gradient(100deg, var(--surface) 30%, var(--surface-2) 50%, var(--surface) 70%);
  background-size:200% 100%; animation:shimmer 1.6s ease-in-out infinite;
}
@keyframes shimmer{0%{background-position:180% 0;}100%{background-position:-20% 0;}}

/* empty state */
.empty{
  display:flex; flex-direction:column; align-items:center; justify-content:center;
  padding:64px 20px; color:var(--text-dim); text-align:center;
}
.empty.hidden{display:none;}
.empty svg{width:42px; height:42px; margin-bottom:14px; opacity:.45;}
.empty-title{font-size:13.5px; color:var(--text-muted); margin-bottom:5px; font-weight:500;}
.empty-sub{font-size:12px; max-width:300px; line-height:1.55;}

table{width:100%; border-collapse:collapse; font-size:13px;}
th{text-align:left; font-size:11px; text-transform:uppercase; letter-spacing:.05em; color:var(--text-dim); padding:11px 12px; border-bottom:1px solid var(--border); font-weight:600;}
td{padding:12px; border-bottom:1px solid var(--border-soft); color:var(--text-muted);}
td.mono{font-family:var(--font-mono); color:var(--text);}
tr:hover td{background:var(--surface-2);}
tr:last-child td{border-bottom:none;}

/* ---------- SLIDE-OVER ---------- */
.overlay{
  position:fixed; inset:0; background:rgba(4,6,8,.65); backdrop-filter:blur(3px);
  display:none; z-index:40; opacity:0; transition:opacity .18s ease;
}
.overlay.show{display:block; opacity:1;}
.panel{
  position:fixed; top:0; right:0; height:100%; width:430px; background:var(--surface);
  border-left:1px solid var(--border); z-index:41; transform:translateX(100%);
  transition:transform .24s cubic-bezier(.2,.8,.25,1); display:flex; flex-direction:column;
  box-shadow:var(--shadow-panel);
}
.panel.show{transform:translateX(0);}
.panel-head{padding:20px 24px; border-bottom:1px solid var(--border); display:flex; justify-content:space-between; align-items:center;}
.panel-title{font-family:var(--font-display); font-size:15.5px; font-weight:600;}
.panel-close{cursor:pointer; color:var(--text-dim); background:none; border:none; font-size:17px; padding:4px; border-radius:5px; line-height:1; transition:color .12s, background .12s;}
.panel-close:hover{color:var(--text); background:var(--surface-2);}
.panel-body{flex:1; overflow-y:auto; padding:22px 24px; display:flex; flex-direction:column; gap:17px;}
.panel-foot{padding:16px 24px; border-top:1px solid var(--border); display:flex; gap:10px; justify-content:flex-end;}

.field label{display:block; font-size:12px; color:var(--text-muted); margin-bottom:6px; font-weight:500;}
.field input, .field select, .field textarea{
  width:100%; background:var(--surface-2); border:1px solid var(--border); border-radius:7px;
  padding:9.5px 11px; color:var(--text); font-size:13px; font-family:var(--font-body); transition:border-color .12s;
}
.field textarea{resize:vertical; font-family:var(--font-body);}
.field input:focus, .field select:focus, .field textarea:focus{outline:none; border-color:var(--green);}
.field-row{display:grid; grid-template-columns:1fr 1fr; gap:12px;}
.hint{font-size:11.5px; color:var(--text-dim); margin-top:6px; line-height:1.5;}

.toggle-group{display:flex; background:var(--surface-2); border:1px solid var(--border); border-radius:7px; padding:3px;}
.toggle-opt{flex:1; text-align:center; padding:7px; border-radius:5px; font-size:12.5px; cursor:pointer; color:var(--text-dim); transition:background .12s, color .12s;}
.toggle-opt:hover{color:var(--text-muted);}
.toggle-opt.active{background:var(--surface-3); color:var(--text); font-weight:500;}

.warn-box{
  background:var(--amber-dim); border:1px solid #4a3a17; border-radius:8px; padding:11px 13px;
  font-size:12px; color:var(--amber); display:flex; gap:9px; line-height:1.55;
}
.warn-box.hidden{display:none;}
.warn-box span:first-child{flex-shrink:0;}

.section-divider{font-size:11px; text-transform:uppercase; letter-spacing:.07em; color:var(--text-dim); padding-top:7px; border-top:1px solid var(--border); margin-top:3px; font-weight:600;}

.view{display:none;}
.view.active{display:block;}

::-webkit-scrollbar{width:9px; height:9px;}
::-webkit-scrollbar-track{background:transparent;}
::-webkit-scrollbar-thumb{background:var(--surface-3); border-radius:5px; border:2px solid var(--bg);}
::-webkit-scrollbar-thumb:hover{background:#333b45;}

@media (max-width: 900px){
  .sidebar{width:72px;}
  .brand-name, .brand-sub, .nav-item span, .nav-label, .host-card, .signature{display:none;}
  .nav-item{justify-content:center;}
  .stat-row{grid-template-columns:repeat(2,1fr);}
}
