/* =========================================================
   Digi Idle — D-auto (automação Digimon · padrão Digivice)
   Layout flexível + Farm (regras, lure, skills, rotação)
   ========================================================= */

.dbot-root{
  display:none;
  position:fixed;
  inset:0;
  pointer-events:none;
  z-index:99990;
}
.dbot-root.is-open{ display:block; }
.dbot-root.is-open .dbot-panel{ pointer-events:auto; }

/* Esconde dock React legado do Bot */
.dock-float[data-dbot-suppressed="1"],
.dock-float:has(.bot-card){
  display:none !important;
}

.dbot-panel,
.dbot-panel.float-win,
.dbot-panel.devo-win{
  --dd-shell:#e88928;
  --dd-shell-2:#c45f12;
  --dd-shell-hi:#ffb45a;
  --dd-cyan:#3ecfff;
  --dd-lcd:#07141a;
  --dd-text:#d7f4ff;
  --dd-muted:#6f93a3;
  --dd-warn:#ffc14d;
  --dd-ok:#5dffb0;
  --dd-font:"Rajdhani","Segoe UI",system-ui,sans-serif;
  --dd-display:"Orbitron","Rajdhani",system-ui,sans-serif;

  position:fixed;
  display:flex !important;
  flex-direction:column !important;
  box-sizing:border-box !important;
  width:min(360px, calc(100vw - 20px));
  max-width:min(96vw, 520px);
  height:min(420px, calc(var(--vvh, 100dvh) - 24px));
  max-height:min(96vh, calc(var(--vvh, 100dvh) - 12px), 720px);
  min-width:min(260px, calc(100vw - 16px));
  min-height:min(200px, calc(var(--vvh, 100dvh) - 24px));
  font-family:var(--dd-font);
  color:var(--dd-text);
  background:
    radial-gradient(120% 80% at 12% 0%,rgba(255,180,90,.35),transparent 42%),
    linear-gradient(165deg,var(--dd-shell-hi) 0%,var(--dd-shell) 38%,var(--dd-shell-2) 100%);
  border:2px solid #8a4a10;
  border-radius:16px;
  box-shadow:
    0 0 0 1px rgba(255,220,160,.35) inset,
    0 0 0 4px rgba(0,0,0,.22) inset,
    0 18px 40px rgba(0,0,0,.5);
  overflow:hidden !important;
  container-type:size;
  container-name:dbot;
  user-select:none;
}
.dbot-panel input,
.dbot-panel select,
.dbot-panel textarea,
.dbot-panel .dbot-body{
  user-select:text;
}
.dbot-panel > *:not(.devo-resize-box){
  box-sizing:border-box;
  width:100%;
  max-width:100%;
  min-width:0;
}

/* —— Header —— */
.dbot-hinge{
  flex:0 0 auto;
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:8px;
  padding:7px 8px 7px 10px;
  background:linear-gradient(180deg,rgba(255,220,160,.22),rgba(0,0,0,.18));
  border-bottom:1px solid rgba(0,0,0,.28);
  cursor:grab;
  touch-action:none;
}
.dbot-hinge:active{ cursor:grabbing; }
.dbot-hinge-left{
  display:flex;
  align-items:center;
  gap:8px;
  min-width:0;
}
.dbot-badge{
  flex:0 0 auto;
  padding:2px 6px;
  border-radius:5px;
  border:1px solid rgba(0,0,0,.25);
  background:linear-gradient(180deg,#0c1f28,#07141a);
  color:var(--dd-cyan);
  font-family:var(--dd-display);
  font-size:8px;
  font-weight:700;
  letter-spacing:.12em;
}
.dbot-title{
  font-family:var(--dd-display);
  font-size:11px;
  font-weight:700;
  letter-spacing:.1em;
  text-transform:uppercase;
  color:#1a0e05;
  white-space:nowrap;
  overflow:hidden;
  text-overflow:ellipsis;
}
.dbot-close{
  flex:0 0 auto;
  width:28px;
  height:28px;
  border-radius:8px;
  border:1px solid #8a4a10;
  background:linear-gradient(180deg,#ffe0a8,#e88928);
  color:#1a0e05;
  font-size:15px;
  line-height:1;
  cursor:pointer;
}

/* —— Status chips —— */
.dbot-status{
  flex:0 0 auto;
  display:flex;
  flex-wrap:wrap;
  gap:4px;
  padding:5px 8px 0;
  max-height:52px;
  overflow:hidden;
}
.dbot-status span{
  padding:2px 6px;
  border-radius:999px;
  border:1px solid rgba(0,0,0,.22);
  background:rgba(7,20,26,.55);
  color:var(--dd-cyan);
  font:700 8px var(--dd-display);
  letter-spacing:.06em;
  text-transform:uppercase;
  white-space:nowrap;
}
.dbot-status.is-idle span{
  color:rgba(26,14,5,.55);
  background:rgba(255,255,255,.18);
  border-color:rgba(0,0,0,.12);
}

/* —— Tabs —— */
.dbot-tabs{
  flex:0 0 auto;
  display:grid;
  grid-template-columns:repeat(5, minmax(0,1fr));
  gap:3px;
  padding:6px 6px 0;
}
.dbot-tab{
  min-width:0;
  padding:6px 2px;
  border-radius:8px 8px 0 0;
  border:1px solid transparent;
  border-bottom:none;
  background:rgba(0,0,0,.28);
  color:rgba(26,14,5,.65);
  font-family:var(--dd-font);
  font-size:10px;
  font-weight:700;
  letter-spacing:.02em;
  text-transform:uppercase;
  cursor:pointer;
  white-space:nowrap;
  overflow:hidden;
  text-overflow:ellipsis;
}
.dbot-tab:hover{ color:#1a0e05; }
.dbot-tab.is-on{
  background:linear-gradient(180deg,#0c1f28,#07141a);
  color:var(--dd-cyan);
  border-color:rgba(0,0,0,.2);
}

/* —— Body (rola; cabeçalho/tabs fixos) —— */
.dbot-body{
  flex:1 1 auto !important;
  min-height:0 !important;
  min-width:0;
  width:100%;
  max-width:100%;
  overflow-x:hidden;
  overflow-y:auto;
  overscroll-behavior:contain;
  -webkit-overflow-scrolling:touch;
  padding:8px;
  display:flex;
  flex-direction:column;
  justify-content:flex-start;
  align-items:stretch;
  gap:8px;
  background:
    linear-gradient(180deg,rgba(7,20,26,.75),rgba(7,20,26,.94)),
    repeating-linear-gradient(0deg,transparent,transparent 2px,rgba(0,0,0,.1) 2px,rgba(0,0,0,.1) 3px),
    var(--dd-lcd);
  border-top:1px solid rgba(62,207,255,.12);
}

.dbot-farm,
.dbot-stack{
  display:flex;
  flex-direction:column;
  gap:8px;
  min-width:0;
  width:100%;
}

/* —— Cards —— */
.dbot-card{
  margin:0;
  padding:8px;
  border-radius:10px;
  border:1px solid rgba(62,207,255,.16);
  background:linear-gradient(180deg,rgba(16,36,48,.95),rgba(8,18,26,.98));
  min-width:0;
  max-width:100%;
  overflow:hidden;
  display:flex;
  flex-direction:column;
  gap:6px;
}
.dbot-card-head{
  display:flex;
  align-items:center;
  gap:8px;
  margin:0;
  min-width:0;
}
.dbot-card-titles{
  display:flex;
  align-items:center;
  gap:6px;
  flex:1 1 auto;
  flex-wrap:wrap;
  min-width:0;
}
.dbot-card-titles strong{
  font-family:var(--dd-display);
  font-size:11px;
  letter-spacing:.08em;
  text-transform:uppercase;
  color:var(--dd-text);
  line-height:1.2;
}
.dbot-tag{
  flex:0 0 auto;
  padding:2px 5px;
  border-radius:999px;
  border:1px solid rgba(62,207,255,.25);
  background:rgba(0,0,0,.28);
  color:var(--dd-cyan);
  font-size:8px;
  font-weight:700;
  letter-spacing:.08em;
  text-transform:uppercase;
  white-space:nowrap;
}
.dbot-desc{
  margin:0;
  font-size:11px;
  line-height:1.35;
  color:var(--dd-muted);
}
.dbot-desc b{ color:var(--dd-text); }
.dbot-empty{
  padding:8px;
  text-align:center;
  color:var(--dd-muted);
  font-size:11px;
  border:1px dashed rgba(62,207,255,.18);
  border-radius:8px;
}

/* —— Switch —— */
.dbot-switch{
  position:relative;
  flex:0 0 auto;
  width:40px;
  height:22px;
  border-radius:999px;
  border:1px solid rgba(62,207,255,.25);
  background:rgba(0,0,0,.4);
  cursor:pointer;
  padding:0;
}
.dbot-switch-knob{
  position:absolute;
  top:2px;
  left:2px;
  width:16px;
  height:16px;
  border-radius:50%;
  background:#6a7a8a;
  transition:transform .15s, background .15s;
}
.dbot-switch.is-on{
  background:rgba(93,255,176,.18);
  border-color:rgba(93,255,176,.45);
}
.dbot-switch.is-on .dbot-switch-knob{
  transform:translateX(18px);
  background:var(--dd-ok);
}

/* —— Rows (toggle + texto) —— */
.dbot-row{
  display:flex;
  align-items:flex-start;
  gap:8px;
  margin:0;
  min-width:0;
}
.dbot-row > div{
  flex:1 1 auto;
  min-width:0;
  display:flex;
  flex-direction:column;
  gap:2px;
}
.dbot-row.is-disabled{ opacity:.45; pointer-events:none; }
.dbot-inline-lbl{
  display:block;
  font-size:12px;
  font-weight:700;
  line-height:1.25;
  color:var(--dd-text);
}
.dbot-row .dbot-desc{ margin:0; }

/* —— Fields —— */
.dbot-field{
  display:flex;
  flex-direction:column;
  gap:4px;
  margin:0;
  font-size:10px;
  font-weight:700;
  letter-spacing:.06em;
  text-transform:uppercase;
  color:var(--dd-muted);
  min-width:0;
}
.dbot-field select,
.dbot-field input[type="number"],
.dbot-field input[type="text"]{
  box-sizing:border-box;
  width:100%;
  max-width:100%;
  min-width:0;
  font-family:var(--dd-font);
  font-size:12px;
  font-weight:600;
  letter-spacing:0;
  text-transform:none;
  color:var(--dd-text);
  background:rgba(0,0,0,.35);
  border:1px solid rgba(62,207,255,.2);
  border-radius:8px;
  padding:6px 8px;
}

/* —— Farm: regras de cura (grid estável) —— */
.dbot-rules{
  display:flex;
  flex-direction:column;
  gap:5px;
  min-width:0;
}
.dbot-rules.is-off{ opacity:.45; pointer-events:none; }
.dbot-rule{
  display:grid;
  grid-template-columns:auto auto minmax(44px,52px) auto minmax(0,1fr) auto;
  align-items:center;
  gap:4px 5px;
  padding:5px 6px;
  margin:0;
  border-radius:8px;
  background:rgba(0,0,0,.28);
  border:1px solid rgba(62,207,255,.12);
  min-width:0;
}
.dbot-rule > span{
  font-size:12px;
  font-weight:700;
  color:var(--dd-muted);
  line-height:1;
}
.dbot-rule input[type="checkbox"]{
  width:16px;
  height:16px;
  margin:0;
  accent-color:var(--dd-cyan);
  cursor:pointer;
}
.dbot-rule .dbot-pct,
.dbot-rule input.dbot-pct{
  width:100% !important;
  max-width:52px;
  min-width:0;
  box-sizing:border-box;
  text-align:center;
  font-family:var(--dd-font);
  font-size:12px;
  font-weight:700;
  color:var(--dd-text);
  background:rgba(0,0,0,.35);
  border:1px solid rgba(62,207,255,.2);
  border-radius:7px;
  padding:5px 4px;
}
.dbot-rule select{
  width:100%;
  min-width:0;
  max-width:100%;
  box-sizing:border-box;
  font-family:var(--dd-font);
  font-size:11px;
  font-weight:600;
  color:var(--dd-text);
  background:rgba(0,0,0,.35);
  border:1px solid rgba(62,207,255,.2);
  border-radius:7px;
  padding:5px 6px;
}
.dbot-rules .dbot-btn{
  align-self:flex-start;
  margin-top:2px;
}

/* —— Segmented (lure 1–5) —— */
.dbot-seg{
  display:grid;
  grid-template-columns:repeat(5, minmax(0,1fr));
  gap:4px;
  margin:0;
  width:100%;
}
.dbot-seg-btn{
  min-width:0;
  padding:7px 0;
  border-radius:8px;
  border:1px solid rgba(62,207,255,.16);
  background:rgba(0,0,0,.32);
  color:var(--dd-muted);
  font-weight:700;
  font-size:12px;
  cursor:pointer;
}
.dbot-seg-btn.is-on{
  color:#1a0e05;
  background:linear-gradient(180deg,#ffe0a8,#e88928 55%,#c45f12);
  border-color:#8a4a10;
}

/* —— Buttons —— */
.dbot-btn{
  margin:0;
  padding:6px 10px;
  border-radius:8px;
  border:1px solid #1a7a9a;
  background:linear-gradient(180deg,#c8e8ff,#3ecfff 55%,#1a9ec4);
  color:#061018;
  font-family:var(--dd-font);
  font-size:10px;
  font-weight:700;
  letter-spacing:.06em;
  text-transform:uppercase;
  cursor:pointer;
  width:fit-content;
  max-width:100%;
}
.dbot-btn--ghost{
  background:rgba(0,0,0,.28);
  border-color:rgba(62,207,255,.25);
  color:var(--dd-cyan);
}
.dbot-icon-btn{
  flex:0 0 auto;
  width:26px;
  height:26px;
  border-radius:7px;
  border:1px solid rgba(255,107,90,.35);
  background:rgba(255,107,90,.12);
  color:#ff8a7a;
  cursor:pointer;
  line-height:1;
  padding:0;
}

/* —— Spell / hunt lists —— */
.dbot-spell-list,
.dbot-hunt-order{
  display:flex;
  flex-direction:column;
  gap:5px;
  margin:0;
  min-width:0;
}
.dbot-spell,
.dbot-hunt-row{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:8px;
  padding:6px 8px;
  border-radius:8px;
  background:rgba(0,0,0,.28);
  border:1px solid rgba(62,207,255,.12);
  min-width:0;
}
.dbot-spell-name,
.dbot-hunt-row > .dbot-hunt-label{
  flex:1 1 auto;
  min-width:0;
  font-size:12px;
  font-weight:700;
  overflow:hidden;
  text-overflow:ellipsis;
  white-space:nowrap;
  color:var(--dd-text);
}
.dbot-spell-btns{
  display:flex;
  flex:0 0 auto;
  gap:3px;
}
.dbot-spell-btns button{
  width:26px;
  height:26px;
  border-radius:7px;
  border:1px solid rgba(62,207,255,.22);
  background:rgba(12,28,40,.9);
  color:var(--dd-text);
  cursor:pointer;
  padding:0;
  line-height:1;
}
.dbot-spell-btns button:disabled{ opacity:.35; cursor:not-allowed; }

/* —— Container queries —— */
@container dbot (max-width: 320px){
  .dbot-tabs{ grid-template-columns:repeat(3, minmax(0,1fr)); }
  .dbot-tab{ font-size:9px; padding:5px 1px; }
  .dbot-rule{
    grid-template-columns:auto auto minmax(40px,48px) auto auto;
    grid-template-areas:
      "chk le pct unit del"
      "sel sel sel sel sel";
  }
  .dbot-rule input[type="checkbox"]{ grid-area:chk; }
  .dbot-rule > span:nth-of-type(1){ grid-area:le; }
  .dbot-rule .dbot-pct{ grid-area:pct; }
  .dbot-rule > span:nth-of-type(2){ grid-area:unit; }
  .dbot-rule select{ grid-area:sel; }
  .dbot-rule .dbot-icon-btn{ grid-area:del; }
  .dbot-card{ padding:6px; gap:5px; }
  .dbot-card-titles strong{ font-size:10px; }
  .dbot-desc{ font-size:10px; }
  .dbot-body{ padding:6px; gap:6px; }
}

@container dbot (max-width: 280px){
  .dbot-hinge{ padding:5px 6px; }
  .dbot-title{ font-size:10px; }
  .dbot-badge{ font-size:7px; padding:2px 4px; }
  .dbot-close{ width:24px; height:24px; font-size:13px; }
  .dbot-status{ padding:4px 6px 0; max-height:40px; }
  .dbot-seg-btn{ padding:5px 0; font-size:11px; }
}

@container dbot (max-height: 320px){
  .dbot-status{ max-height:28px; padding-top:3px; }
  .dbot-tabs{ padding-top:4px; }
  .dbot-tab{ padding:4px 1px; font-size:9px; }
  .dbot-body{ padding:6px; gap:6px; }
  .dbot-card{ padding:6px; gap:4px; }
}

@container dbot (max-height: 240px){
  .dbot-status{ display:none; }
  .dbot-desc{ display:none; }
  .dbot-tag{ display:none; }
}

@media (max-width: 420px){
  .dbot-panel,
  .dbot-panel.float-win,
  .dbot-panel.devo-win{
    width:min(100vw - 12px, 380px) !important;
    max-width:calc(100vw - 12px) !important;
    max-height:min(calc(var(--vvh, 100dvh) - 12px), 560px);
  }
}

@media (hover:none) and (pointer:coarse){
  .dbot-switch{ width:44px; height:26px; }
  .dbot-switch-knob{ width:18px; height:18px; top:3px; left:3px; }
  .dbot-switch.is-on .dbot-switch-knob{ transform:translateX(18px); }
  .dbot-spell-btns button,
  .dbot-icon-btn{
    width:30px;
    height:30px;
  }
  .dbot-tab{ min-height:32px; }
}
