/* =============================================
   Admin Agentes — Custom CSS
   ============================================= */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800&display=swap');

:root {
  --bg-main:       #0f0f1a;
  --bg-sidebar:    #16162a;
  --bg-card:       #1e1e35;
  --bg-card-hover: #252540;
  --accent:        #6366f1;
  --accent-hover:  #4f52d9;
  --accent-2:      #8b5cf6;
  --gradient-hero: linear-gradient(135deg, #31406b, #4362b9, #4375ff);
  --text-main:     #f1f5f9;
  --text-muted:    #94a3b8;
  --border:        #2d2d4e;
  --success:       #10b981;
  --danger:        #ef4444;
  --warning:       #f59e0b;
  --sidebar-width: 240px;
}

* { box-sizing: border-box; }

body {
  font-family: 'Inter', sans-serif;
  background-color: var(--bg-main);
  color: var(--text-main);
  min-height: 100vh;
}

/* ── Scrollbar ── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: var(--bg-sidebar); }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--accent); }

/* =============================================
   AUTH LAYOUT
   ============================================= */

.auth-wrapper {
  display: flex;
  min-height: 100vh;
}

.auth-panel-left {
  width: 45%;
  background: url("/blue-business-background_G.jpg") no-repeat;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 3rem;
  position: relative;
  overflow: hidden;
}

.auth-panel-left::before {
  content: '';
  position: absolute;
  inset: 0;
}

.auth-panel-right {
  width: 55%;
  background: var(--bg-main);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 3rem;
}

.auth-form-box {
  width: 100%;
  max-width: 420px;
}

.logo-login-prime{
  display: none; 
}

@media (max-width: 768px) {
  .logo-login-prime  { display: block; }
  .auth-panel-left { display: none; }
  .auth-panel-right { width: 100%; }
}

/* =============================================
   APP LAYOUT — SIDEBAR
   ============================================= */

.app-wrapper {
  display: flex;
  min-height: 100vh;
}

.sidebar {
  width: var(--sidebar-width);
  background: var(--bg-sidebar);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  z-index: 100;
  transition: transform 0.3s ease;
}

.sidebar-logo {
  padding: 1.5rem 1.25rem;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.sidebar-logo-icon {
  width: 36px;
  height: 36px;
  background: var(--gradient-hero);
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
  flex-shrink: 0;
}

.sidebar-logo-text {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text-main);
  line-height: 1.2;
}

.sidebar-logo-text small {
  display: block;
  font-size: 0.7rem;
  font-weight: 400;
  color: var(--text-muted);
}

.sidebar-nav {
  flex: 1;
  padding: 1rem 0.75rem;
  overflow-y: auto;
}

.nav-section-label {
  font-size: 0.65rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  padding: 0.75rem 0.5rem 0.25rem;
}

.sidebar-link {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.6rem 0.75rem;
  border-radius: 8px;
  color: var(--text-muted);
  text-decoration: none;
  font-size: 0.875rem;
  font-weight: 500;
  transition: all 0.15s ease;
  margin-bottom: 2px;
}

.sidebar-link:hover {
  background: var(--bg-card);
  color: var(--text-main);
}

.sidebar-link.active {
  background: rgba(99, 102, 241, 0.15);
  color: var(--accent);
  font-weight: 600;
}

.sidebar-link.active .sidebar-icon {
  color: var(--accent);
}

.sidebar-icon {
  width: 18px;
  text-align: center;
  font-size: 1rem;
  flex-shrink: 0;
}

.sidebar-footer {
  padding: 1rem 0.75rem;
  border-top: 1px solid var(--border);
}

.sidebar-user {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.5rem;
  border-radius: 8px;
}

.sidebar-avatar {
  width: 34px;
  height: 34px;
  background: var(--gradient-hero);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.8rem;
  font-weight: 700;
  color: white;
  flex-shrink: 0;
}

.sidebar-user-info {
  flex: 1;
  min-width: 0;
}

.sidebar-user-name {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-main);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sidebar-user-role {
  font-size: 0.7rem;
  color: var(--text-muted);
}

/* =============================================
   APP LAYOUT — MAIN
   ============================================= */

.main-wrapper {
  margin-left: var(--sidebar-width);
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.topbar {
  height: 60px;
  background: var(--bg-sidebar);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 1.5rem;
  gap: 1rem;
  position: sticky;
  top: 0;
  z-index: 50;
}

.topbar-breadcrumb {
  flex: 1;
}

.topbar-breadcrumb .breadcrumb {
  margin: 0;
  font-size: 0.8rem;
}

.topbar-breadcrumb .breadcrumb-item a {
  color: var(--text-muted);
  text-decoration: none;
}

.topbar-breadcrumb .breadcrumb-item.active {
  color: var(--text-main);
  font-weight: 600;
}

.topbar-breadcrumb .breadcrumb-item + .breadcrumb-item::before {
  color: var(--border);
  content: "/";
}

.page-content {
  flex: 1;
  padding: 1.75rem 1.5rem;
}

/* =============================================
   CARDS
   ============================================= */

.admin-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
}

.admin-card-header {
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.admin-card-body {
  padding: 1.5rem;
}

/* Stat Cards */
.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1.25rem 1.5rem;
  position: relative;
  overflow: hidden;
  transition: border-color 0.2s;
}

.stat-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 2px;
  background: var(--gradient-hero);
}

.stat-card:hover {
  border-color: var(--accent);
}

.stat-card-icon {
  width: 42px;
  height: 42px;
  background: rgba(99, 102, 241, 0.15);
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.2rem;
  margin-bottom: 1rem;
}

.stat-card-value {
  font-size: 2rem;
  font-weight: 800;
  color: var(--text-main);
  line-height: 1;
}

.stat-card-label {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-top: 0.25rem;
}

/* Agent Cards */
.agent-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
  transition: all 0.2s ease;
  height: 100%;
  display: flex;
  flex-direction: column;
}

.agent-card:hover {
  border-color: var(--accent);
  transform: translateY(-2px);
  box-shadow: 0 8px 32px rgba(99, 102, 241, 0.15);
}

.agent-card-cover {
  height: 120px;
  background: var(--gradient-hero);
  position: relative;
}

.agent-card-cover img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.agent-card-cover-overlay {
  position: absolute;
  inset: 0;
  background: linear-gradient(to bottom, transparent 40%, rgba(30,30,53,0.9));
}

.agent-card-emoji {
  position: absolute;
  bottom: -16px;
  left: 1rem;
  width: 40px;
  height: 40px;
  background: var(--bg-card);
  border: 2px solid var(--border);
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.2rem;
  z-index: 1;
}

.agent-card-body {
  padding: 1.25rem 1rem 1rem;
  flex: 1;
  display: flex;
  flex-direction: column;
}

.agent-card-category {
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 0.4rem;
}

.agent-card-title {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text-main);
  margin-bottom: 0.4rem;
  line-height: 1.3;
}

.agent-card-desc {
  font-size: 0.8rem;
  color: var(--text-muted);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  flex: 1;
  margin-bottom: 0.75rem;
}

.agent-card-meta {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
  margin-bottom: 0.75rem;
}

.agent-card-actions {
  display: flex;
  gap: 0.5rem;
  padding-top: 0.75rem;
  border-top: 1px solid var(--border);
}

/* =============================================
   BUTTONS
   ============================================= */

.btn-accent {
  background: var(--accent);
  color: #fff;
  border: none;
  padding: 0.5rem 1rem;
  border-radius: 8px;
  font-size: 0.875rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  text-decoration: none;
}

.btn-accent:hover {
  background: var(--accent-hover);
  color: #fff;
  transform: translateY(-1px);
}

.btn-ghost {
  background: transparent;
  color: var(--text-muted);
  border: 1px solid var(--border);
  padding: 0.5rem 1rem;
  border-radius: 8px;
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s;
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  text-decoration: none;
}

.btn-ghost:hover {
  background: var(--bg-card);
  color: var(--text-main);
  border-color: var(--accent);
}

.btn-danger-ghost {
  background: transparent;
  color: var(--danger);
  border: 1px solid transparent;
  padding: 0.4rem 0.75rem;
  border-radius: 6px;
  font-size: 0.8rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s;
}

.btn-danger-ghost:hover {
  background: rgba(239, 68, 68, 0.1);
  border-color: var(--danger);
}

/* =============================================
   FORMS
   ============================================= */

.form-control-dark,
.form-select-dark {
  background: var(--bg-main);
  border: 1px solid var(--border);
  color: var(--text-main);
  border-radius: 8px;
  padding: 0.6rem 0.9rem;
  font-size: 0.875rem;
  width: 100%;
  transition: border-color 0.15s;
}

.form-control-dark:focus,
.form-select-dark:focus {
  outline: none;
  border-color: var(--accent);
  background: var(--bg-main);
  color: var(--text-main);
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.15);
}

.form-control-dark::placeholder {
  color: var(--text-muted);
}

.form-label-dark {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 0.4rem;
  display: block;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.form-control-dark.is-invalid {
  border-color: var(--danger);
}

/* Comportamento dentro de .input-group (igual ao .form-control do Bootstrap) */
.input-group > .form-control-dark,
.input-group > .form-select-dark {
  position: relative;
  flex: 1 1 auto;
  width: 1%;
  min-width: 0;
}

.input-group > .form-control-dark:not(:last-child),
.input-group > .form-select-dark:not(:last-child) {
  border-top-right-radius: 0;
  border-bottom-right-radius: 0;
}

.input-group > .form-control-dark:not(:first-child),
.input-group > .form-select-dark:not(:first-child) {
  border-top-left-radius: 0;
  border-bottom-left-radius: 0;
  margin-left: -1px;
}

.invalid-feedback-dark {
  color: var(--danger);
  font-size: 0.78rem;
  margin-top: 0.25rem;
}

/* Temperature Slider */
.temp-slider {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 6px;
  border-radius: 3px;
  background: linear-gradient(to right, #10b981, #6366f1, #8b5cf6, #ef4444);
  outline: none;
  cursor: pointer;
}

.temp-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #fff;
  border: 2px solid var(--accent);
  cursor: pointer;
  box-shadow: 0 2px 6px rgba(0,0,0,0.3);
}

.temp-labels {
  display: flex;
  justify-content: space-between;
  margin-top: 0.35rem;
}

.temp-label {
  font-size: 0.65rem;
  color: var(--text-muted);
  text-align: center;
}

/* Step form */
.step-section {
  position: relative;
  padding-left: 3.5rem;
  margin-bottom: 2.5rem;
}

.step-number {
  position: absolute;
  left: 0;
  top: 0;
  width: 36px;
  height: 36px;
  background: rgba(99, 102, 241, 0.15);
  border: 2px solid var(--accent);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--accent);
  flex-shrink: 0;
}

.step-connector {
  position: absolute;
  left: 17px;
  top: 36px;
  bottom: -16px;
  width: 2px;
  background: var(--border);
}

.step-title {
  font-size: 1rem;
  font-weight: 700;
  color: var(--text-main);
  margin-bottom: 0.25rem;
  line-height: 1;
  padding-top: 0.4rem;
}

.step-subtitle {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-bottom: 1.25rem;
}

/* =============================================
   BADGES & PILLS
   ============================================= */

.badge-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0.2rem 0.6rem;
  border-radius: 20px;
  font-size: 0.7rem;
  font-weight: 600;
}

.badge-active   { background: rgba(16,185,129,0.15); color: var(--success); }
.badge-inactive { background: rgba(148,163,184,0.1); color: var(--text-muted); }
.badge-model    { background: rgba(99,102,241,0.12); color: var(--accent); }

.status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  display: inline-block;
  flex-shrink: 0;
}

.status-dot.active   { background: var(--success); box-shadow: 0 0 6px var(--success); }
.status-dot.inactive { background: var(--text-muted); }

/* =============================================
   INSTANCE ROW
   ============================================= */

.instance-row {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 1rem 1.25rem;
  display: flex;
  align-items: center;
  gap: 1rem;
  transition: border-color 0.15s;
}

.instance-row:hover {
  border-color: var(--accent);
}

.instance-emoji {
  width: 38px;
  height: 38px;
  background: rgba(99,102,241,0.1);
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.2rem;
  flex-shrink: 0;
}

/* =============================================
   TOAST / ALERTS
   ============================================= */

.toast-container-fixed {
  position: fixed;
  top: 1.25rem;
  right: 1.25rem;
  z-index: 9999;
  min-width: 280px;
}

.toast-dark {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--text-main);
  box-shadow: 0 8px 32px rgba(0,0,0,0.4);
}

.toast-dark.success { border-left: 3px solid var(--success); }
.toast-dark.danger  { border-left: 3px solid var(--danger);  }

/* =============================================
   EMPTY STATES
   ============================================= */

.empty-state {
  text-align: center;
  padding: 3rem 1.5rem;
}

.empty-state-icon {
  font-size: 3rem;
  margin-bottom: 1rem;
  opacity: 0.4;
}

.empty-state-title {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text-main);
  margin-bottom: 0.5rem;
}

.empty-state-desc {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-bottom: 1.5rem;
}

/* =============================================
   MODAL DARK
   ============================================= */

.modal-dark .modal-content {
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--text-main);
}

.modal-dark .modal-header {
  border-bottom: 1px solid var(--border);
}

.modal-dark .modal-footer {
  border-top: 1px solid var(--border);
}

.modal-dark .btn-close {
  filter: invert(1);
}

/* =============================================
   DROPDOWN DARK
   ============================================= */

.dropdown-menu {
  background: var(--bg-card) !important;
  border: 1px solid var(--border) !important;
}

.dropdown-item {
  color: var(--text-main) !important;
  font-size: .82rem;
  background: transparent !important;
  transition: background .12s;
}

.dropdown-item:hover {
  background: rgba(99,102,241,.1) !important;
}

.dropdown-divider {
  border-color: var(--border) !important;
}

/* =============================================
   SPINNER / LOADING
   ============================================= */

.spinner-border-sm {
  width: .85rem;
  height: .85rem;
  border-width: 2px;
}

/* =============================================
   FORM VALIDATION BOOTSTRAP OVERRIDE
   ============================================= */

.form-select-dark option {
  background: var(--bg-card);
  color: var(--text-main);
}

/* Focus ring global */
*:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* =============================================
   RESPONSIVE
   ============================================= */

@media (max-width: 991px) {
  .sidebar {
    transform: translateX(-100%);
  }

  .sidebar.open {
    transform: translateX(0);
  }

  .main-wrapper {
    margin-left: 0;
  }

  .sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    z-index: 99;
  }

  .sidebar-overlay.active {
    display: block;
  }
}

@media (max-width: 768px) {
  .page-content {
    padding: 1rem .875rem;
  }

  .admin-card-header {
    flex-wrap: wrap;
    gap: .5rem;
  }

  .stat-card-value {
    font-size: 1.6rem;
  }

  .agent-card-actions {
    gap: .35rem;
  }

  /* Topbar compacto */
  .topbar {
    padding: 0 .875rem;
  }

  /* Fork: empilha os painéis no mobile */
  .fork-left-panel {
    position: static !important;
  }
}

/* =============================================
   UTILITIES
   ============================================= */

.text-accent  { color: var(--accent) !important; }
.text-muted-custom { color: var(--text-muted) !important; }
.border-dark-custom { border-color: var(--border) !important; }
.bg-card-custom { background: var(--bg-card) !important; }

.gradient-text {
  background: var(--gradient-hero);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

/* Login animation */
@keyframes float {
  0%, 100% { transform: translateY(0px); }
  50%       { transform: translateY(-10px); }
}

.float-anim { animation: float 4s ease-in-out infinite; }

@keyframes gradient-shift {
  0%   { background-position: 0% 50%; }
  50%  { background-position: 100% 50%; }
  100% { background-position: 0% 50%; }
}

.gradient-animated {
  background-size: 200% 200%;
  animation: gradient-shift 6s ease infinite;
}

/* =============================================
   Portal do Cliente — canais de WhatsApp
   ============================================= */

/* ── Status da sessão ── */
.badge-connected    { background: rgba(16,185,129,0.15); color: var(--success); }
.badge-connecting   { background: rgba(245,158,11,0.15); color: var(--warning); }
.badge-disconnected { background: rgba(148,163,184,0.1); color: var(--text-muted); }

/* ── Cartões de escolha de provedor ── */
.provider-option {
  display: block;
  position: relative;
  background: var(--bg-main);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: .9rem 1rem;
  cursor: pointer;
  transition: all .18s ease;
}

.provider-option:hover { border-color: var(--accent); background: var(--bg-card-hover); }

.provider-option input { position: absolute; opacity: 0; pointer-events: none; }

.provider-option:has(input:checked) {
  border-color: var(--accent);
  background: rgba(99,102,241,0.08);
  box-shadow: 0 0 0 1px var(--accent);
}

.provider-option.disabled {
  opacity: .45;
  cursor: not-allowed;
}

.provider-option.disabled:hover { border-color: var(--border); background: var(--bg-main); }

.provider-option-name {
  font-size: .88rem;
  font-weight: 700;
  color: var(--text-main);
}

.provider-option-desc {
  font-size: .74rem;
  color: var(--text-muted);
  margin-top: .15rem;
}

/* ── QR Code ── */
.qr-frame {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 268px;
  height: 268px;
  padding: .75rem;
  background: #fff;
  border-radius: 12px;
  margin: 0 auto;
}

.qr-frame img { width: 100%; height: 100%; object-fit: contain; }

.qr-placeholder {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: .5rem;
  width: 268px;
  height: 268px;
  margin: 0 auto;
  border: 1px dashed var(--border);
  border-radius: 12px;
  color: var(--text-muted);
  font-size: .78rem;
  text-align: center;
  padding: 1rem;
}
