/* ============================================================
   AYRA COCKPIT - extras (back btn, gear menu, stack blocks, lock)
   ============================================================ */

/* Back button no topo do cockpit */
.cp-back-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  background: rgba(0, 217, 255, 0.08);
  border: 1px solid rgba(0, 217, 255, 0.32);
  color: #d7f6ff;
  padding: 4px 10px;
  border-radius: 4px;
  font-size: 10.5px;
  cursor: pointer;
  font-family: inherit;
  letter-spacing: 0.06em;
  transition: all 0.15s ease;
}
.cp-back-btn:hover { background: rgba(0, 217, 255, 0.18); border-color: #00d9ff; box-shadow: 0 0 10px rgba(0, 217, 255, 0.4); }
.cp-back-btn svg { flex: 0 0 auto; }

/* Engrenagem */
.cp-gear {
  background: rgba(0, 217, 255, 0.06);
  border: 1px solid rgba(0, 217, 255, 0.22);
  color: #00d9ff;
  width: 30px; height: 30px;
  border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center;
  cursor: pointer;
  transition: all 0.15s ease;
}
.cp-gear:hover { background: rgba(0, 217, 255, 0.18); border-color: #00d9ff; transform: rotate(45deg); }

/* Dropdown da engrenagem */
.cp-gear-menu {
  position: fixed;
  top: 56px;
  right: 14px;
  width: 320px;
  max-width: calc(100vw - 28px);
  background: rgba(8, 18, 32, 0.96);
  border: 1px solid rgba(0, 217, 255, 0.35);
  border-radius: 8px;
  box-shadow: 0 10px 32px rgba(0, 0, 0, 0.55), 0 0 24px rgba(0, 217, 255, 0.12);
  z-index: 50;
  -webkit-backdrop-filter: blur(14px);
  backdrop-filter: blur(14px);
  font-family: 'JetBrains Mono', monospace;
}
.cp-gear-head {
  padding: 12px 14px;
  display: flex; justify-content: space-between; align-items: center;
  border-bottom: 1px solid rgba(0, 217, 255, 0.18);
  color: #d7f6ff;
  font-size: 12px;
  letter-spacing: 0.06em;
}
.cp-gear-body { padding: 12px 14px; display: flex; flex-direction: column; gap: 10px; }
.cp-gear-row {
  display: flex; align-items: flex-start; gap: 9px;
  font-size: 11.5px; color: #d7f6ff;
  cursor: pointer; line-height: 1.4;
}
.cp-gear-row input[type="checkbox"] {
  margin-top: 2px;
  accent-color: #00d9ff;
}
.cp-gear-divider { height: 1px; background: rgba(0, 217, 255, 0.14); margin: 4px 0; }
.cp-gear-link {
  color: #00d9ff;
  text-decoration: none;
  font-size: 11.5px;
  padding: 4px 0;
  letter-spacing: 0.04em;
}
.cp-gear-link:hover { color: #d7f6ff; }
.cp-gear-foot {
  padding: 12px 14px;
  border-top: 1px solid rgba(0, 217, 255, 0.18);
  background: rgba(0, 0, 0, 0.18);
  border-radius: 0 0 8px 8px;
}
.cp-lock-note {
  display: block;
  font-size: 11px;
  color: #d7f6ff;
  line-height: 1.55;
}
.cp-lock-note strong { color: #00d9ff; }
.cp-lock-note a { color: #00d9ff; text-decoration: underline; }

/* Lock banner inline no customizer */
.cp-lock-banner {
  padding: 10px 12px;
  background: rgba(255, 184, 77, 0.08);
  border: 1px solid rgba(255, 184, 77, 0.32);
  border-left: 3px solid #ffb84d;
  border-radius: 4px;
  color: #d7f6ff;
  font-size: 11.5px;
  line-height: 1.55;
  margin-bottom: 10px;
}
.cp-lock-banner strong { color: #ffb84d; }

/* Stack de blocos (Flex Wrap para permitir janelas lado a lado no desktop) */
.cp-stack {
  display: flex;
  flex-direction: row;
  flex-wrap: wrap;
  gap: 12px;
  padding: 12px;
  overflow-y: auto;
  max-height: calc(100vh - 44px);
  align-items: stretch;
}
.cp-block {
  background: rgba(8, 18, 32, 0.78);
  border: 1px solid rgba(0, 217, 255, 0.18);
  border-radius: 6px;
  overflow: hidden;
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
  box-shadow: 0 4px 18px rgba(0, 0, 0, 0.4);
  position: relative;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
  display: flex;
  flex-direction: column;
  min-height: 120px;
}
.cp-block::before, .cp-block::after {
  content: ""; position: absolute; width: 8px; height: 8px; pointer-events: none;
}
.cp-block::before { top: 0; left: 0; border-top: 2px solid #00d9ff; border-left: 2px solid #00d9ff; }
.cp-block::after { bottom: 0; right: 0; border-bottom: 2px solid #00d9ff; border-right: 2px solid #00d9ff; }
.cp-block.collapsed { border-color: rgba(0, 217, 255, 0.10); }
.cp-block.collapsed::before, .cp-block.collapsed::after { opacity: 0.35; }

/* === MODO EDIÇÃO DO COCKPIT === */
.cp-block.editing {
  border: 1px dashed #00d9ff !important;
  box-shadow: 0 0 15px rgba(0, 217, 255, 0.15) !important;
}
.cp-block-edit-bar {
  background: rgba(0, 217, 255, 0.08);
  border-bottom: 1px solid rgba(0, 217, 255, 0.25);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 12px;
  font-family: inherit;
}
.cp-edit-group {
  display: flex;
  align-items: center;
  gap: 6px;
}
.cp-edit-label {
  font-size: 9.5px;
  color: #7fa8b8;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
.cp-edit-btn {
  background: rgba(8, 18, 32, 0.8);
  border: 1px solid rgba(0, 217, 255, 0.3);
  color: #00d9ff;
  border-radius: 4px;
  padding: 3px 6px;
  font-size: 10px;
  font-family: inherit;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 3px;
  transition: all 0.15s ease;
}
.cp-edit-btn:hover {
  background: rgba(0, 217, 255, 0.15);
  border-color: #00d9ff;
  box-shadow: 0 0 8px rgba(0, 217, 255, 0.3);
}
.cp-edit-btn.active {
  background: #00d9ff;
  color: #05080d;
  font-weight: 700;
  border-color: #00d9ff;
}

/* Puxador para redimensionar */
.cp-resize-handle {
  position: absolute;
  bottom: 0;
  right: 0;
  width: 16px;
  height: 16px;
  cursor: se-resize;
  z-index: 10;
  background-image: linear-gradient(135deg, transparent 40%, rgba(0, 217, 255, 0.3) 40%, rgba(0, 217, 255, 0.3) 60%, transparent 60%, transparent 80%, rgba(0, 217, 255, 0.3) 80%);
  background-size: 4px 4px;
}
.cp-resize-handle:hover {
  background-image: linear-gradient(135deg, transparent 40%, #00d9ff 40%, #00d9ff 60%, transparent 60%, transparent 80%, #00d9ff 80%);
}

/* Barra superior com botões de Edição */
.cp-edit-topbar-btn {
  background: #00d9ff;
  border: 1px solid #00d9ff;
  color: #05080d;
  font-weight: 700;
  border-radius: 4px;
  padding: 4px 10px;
  font-size: 10px;
  cursor: pointer;
  letter-spacing: 0.08em;
  transition: all 0.15s ease;
}
.cp-edit-topbar-btn:hover {
  background: #00ecff;
  box-shadow: 0 0 10px rgba(0, 217, 255, 0.5);
}
.cp-edit-topbar-btn.cancel {
  background: transparent;
  border: 1px solid rgba(239, 68, 68, 0.6);
  color: #ef4444;
}
.cp-edit-topbar-btn.cancel:hover {
  background: rgba(239, 68, 68, 0.15);
  box-shadow: 0 0 10px rgba(239, 68, 68, 0.3);
}

.cp-block-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 16px;
  cursor: pointer;
  background: rgba(10, 18, 32, 0.5);
  border-bottom: 1px solid rgba(0, 217, 255, 0.14);
  transition: background 0.15s ease;
  user-select: none;
}
.cp-block-head:hover { background: rgba(0, 217, 255, 0.05); }
.cp-block.collapsed .cp-block-head { border-bottom: 0; }
.cp-block-title {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.1em;
  color: #00d9ff;
  text-transform: uppercase;
  display: inline-flex;
  align-items: center;
  gap: 8px;
}
.cp-block-sub {
  font-size: 10.5px;
  color: #7fa8b8;
  letter-spacing: 0.04em;
  display: inline-flex;
  align-items: center;
  gap: 8px;
}
.cp-block-sub strong { color: #d7f6ff; }
.cp-chevron {
  display: inline-block;
  color: #00d9ff;
  font-size: 13px;
  margin-left: 4px;
  transition: transform 0.2s ease;
}
.cp-block-body { padding: 0; }
.cp-block.cp-voice-block .cp-block-body { padding: 0 16px 16px; }
.cp-block.cp-agents-block .cp-block-body,
.cp-block.cp-advanced-block .cp-block-body { padding: 12px 14px; }
.cp-block.cp-ayra-block .cp-block-body { display: flex; flex-direction: column; min-height: 360px; }

/* Hint quando recursos estão escondidos */
.cp-hint {
  margin: 0 12px 12px;
  padding: 10px 12px;
  background: rgba(0, 217, 255, 0.04);
  border: 1px dashed rgba(0, 217, 255, 0.28);
  border-radius: 4px;
  font-size: 11.5px;
  color: #7fa8b8;
  line-height: 1.5;
}
.cp-hint strong { color: #00d9ff; }

/* Customizer colapsável (details/summary nativos) */
.cp-customizer-collapsible {
  margin-top: 10px;
  border-top: 1px dashed rgba(0, 217, 255, 0.18);
  padding-top: 10px;
}
.cp-customizer-collapsible summary {
  cursor: pointer;
  font-size: 11px;
  font-weight: 700;
  color: #00d9ff;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  padding: 6px 4px;
  list-style: none;
  display: flex;
  align-items: center;
  gap: 6px;
}
.cp-customizer-collapsible summary::before {
  content: "▸";
  display: inline-block;
  transition: transform 0.15s ease;
}
.cp-customizer-collapsible[open] summary::before { transform: rotate(90deg); }
.cp-customizer-collapsible .cp-customizer { padding-top: 8px; border-top: 0; }

/* Painel avançado: 3 cards de atalho */
.cp-advanced-quick {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-bottom: 14px;
}
.cp-adv-card {
  background: rgba(8, 18, 32, 0.7);
  border: 1px solid rgba(0, 217, 255, 0.2);
  border-radius: 5px;
  padding: 14px 12px;
  text-decoration: none;
  color: #d7f6ff;
  transition: all 0.2s ease;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.cp-adv-card:hover {
  border-color: #00d9ff;
  background: rgba(0, 217, 255, 0.08);
  transform: translateY(-2px);
}
.cp-adv-card strong {
  font-size: 12px;
  color: #00d9ff;
  letter-spacing: 0.08em;
}
.cp-adv-card span {
  font-size: 10.5px;
  color: #7fa8b8;
  line-height: 1.4;
}
.cp-advanced-block .cp-terminal { margin: 0; }

/* Mobile */
@media (max-width: 700px) {
  .cp-stack { padding: 8px; gap: 10px; max-height: none; }
  .cp-block { width: 100% !important; height: auto !important; order: unset !important; }
  .cp-resize-handle { display: none !important; }
  .cp-block-head { padding: 14px 14px; }
  .cp-block-title { font-size: 12.5px; }
  .cp-block-sub { font-size: 10px; }
  .cp-block.cp-ayra-block .cp-block-body { min-height: 320px; }
  .cp-advanced-quick { grid-template-columns: 1fr; }
  .cp-back-label { display: none; }
  .cp-gear-menu { right: 8px; width: calc(100vw - 16px); }
}

@media (max-width: 1024px) {
  .cp-grid { display: none; } /* desativa o grid antigo se ainda existir */
}
