/* ============================================================
   CHATWOOT SIDE PANEL — arquivo isolado (não mexe no admin-styles.css)
   ============================================================ */

.cw-tab {
  position: fixed;
  top: 50%;
  right: 0;
  transform: translateY(-50%);
  width: 34px;
  height: 84px;
  background: var(--primary-color, #2563eb);
  border-radius: 10px 0 0 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  z-index: 999997;
  box-shadow: -2px 2px 10px rgba(0, 0, 0, 0.25);
  transition: width 0.2s ease, background 0.2s ease;
}

.cw-tab:hover {
  width: 40px;
  background: var(--primary-dark, #1d4ed8);
}

.cw-tab i {
  color: #fff;
  font-size: 18px;
  transition: transform 0.3s ease;
}

.cw-tab.cw-open i {
  transform: rotate(180deg);
}

.cw-tab .cw-badge {
  position: absolute;
  top: -6px;
  left: -6px;
  background: var(--danger-color, #dc2626);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  min-width: 18px;
  height: 18px;
  border-radius: 9px;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 0 4px;
}

.cw-panel {
  position: fixed;
  top: 0;
  right: 0;
  height: 100vh;
  width: 50vw;
  min-width: 320px;
  background: var(--card-bg, #fff);
  box-shadow: -4px 0 24px rgba(0, 0, 0, 0.25);
  z-index: 999998;
  display: flex;
  flex-direction: column;
  transform: translateX(100%);
  transition: transform 0.35s cubic-bezier(0.22, 1, 0.36, 1);
}

.cw-panel.cw-visible {
  transform: translateX(0);
}

.cw-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  background: var(--sidebar-header-bg, #f8fafc);
  border-bottom: 1px solid var(--light-border, #e2e8f0);
  flex-shrink: 0;
}

.cw-panel-header h4 {
  margin: 0;
  font-size: 15px;
  color: var(--text-color, #1e293b);
  display: flex;
  align-items: center;
  gap: 8px;
}

.cw-panel-header .cw-close-btn {
  background: transparent;
  border: none;
  color: var(--text-light, #475569);
  font-size: 20px;
  cursor: pointer;
  line-height: 1;
  padding: 4px 8px;
  border-radius: 6px;
}

.cw-panel-header .cw-close-btn:hover {
  background: var(--light-bg, #f1f5f9);
  color: var(--danger-color, #dc2626);
}

.cw-panel-header .cw-header-actions {
  display: flex;
  align-items: center;
  gap: 4px;
}

.cw-connect-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  background: var(--primary-color, #2563eb);
  color: #fff;
  border: none;
  border-radius: 6px;
  padding: 6px 12px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
}

.cw-connect-btn:hover {
  background: var(--primary-dark, #1d4ed8);
}

/* -------- overlay de conexão (login + QR), fica por cima do iframe -------- */
.cw-connect-overlay {
  position: absolute;
  inset: 0;
  background: rgba(15, 23, 42, 0.55);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 5;
  padding: 20px;
}

.cw-connect-overlay.cw-visible {
  display: flex;
}

.cw-connect-card {
  background: var(--card-bg, #fff);
  border-radius: 12px;
  width: 100%;
  max-width: 320px;
  padding: 24px 22px;
  text-align: center;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.25);
  position: relative;
}

.cw-connect-card .cw-connect-close {
  position: absolute;
  top: 8px;
  right: 10px;
  background: transparent;
  border: none;
  font-size: 18px;
  color: var(--text-light, #475569);
  cursor: pointer;
}

.cw-connect-card h5 {
  margin: 0 0 4px;
  font-size: 15px;
  color: var(--text-color, #1e293b);
}

.cw-connect-card p {
  margin: 0 0 16px;
  font-size: 12px;
  color: var(--text-light, #475569);
}

.cw-connect-card input {
  width: 100%;
  padding: 9px 11px;
  margin-bottom: 10px;
  border: 1px solid var(--light-border, #e2e8f0);
  border-radius: 7px;
  font-size: 13px;
}

.cw-connect-card button.cw-connect-submit {
  width: 100%;
  padding: 9px;
  border: none;
  border-radius: 7px;
  background: var(--primary-color, #2563eb);
  color: #fff;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}

.cw-connect-card button.cw-connect-submit:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.cw-connect-msg {
  font-size: 12px;
  margin-top: 10px;
  min-height: 14px;
}

.cw-connect-msg.cw-error { color: #dc2626; }
.cw-connect-msg.cw-ok { color: #16a34a; }

.cw-connect-qr img {
  width: 190px;
  height: 190px;
  border: 1px solid var(--light-border, #e2e8f0);
  border-radius: 8px;
  margin: 4px 0 10px;
}

.cw-connect-status {
  font-size: 12px;
  color: var(--text-light, #475569);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}

.cw-connect-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #f59e0b;
  animation: cwPulse 1s infinite;
}

@keyframes cwPulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.3; }
}

.cw-panel-body {
  flex: 1;
  position: relative;
  background: var(--light-bg, #f1f5f9);
}

.cw-panel-body iframe {
  width: 100%;
  height: 100%;
  border: none;
  display: block;
}

.cw-panel-loading {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 10px;
  color: var(--text-light, #475569);
  font-size: 14px;
}

.cw-panel-loading i {
  font-size: 22px;
  color: var(--primary-color, #2563eb);
}

@media (max-width: 900px) {
  .cw-panel {
    width: 100vw;
    min-width: 0;
  }
}