/* ============================================================
   Clinicorp Bot - Web Panel Styles
   ============================================================ */

:root {
  --sidebar-bg: #1a1a2e;
  --sidebar-hover: #16213e;
  --sidebar-active: #0f3460;
  --sidebar-text: #a8a8b3;
  --sidebar-text-active: #ffffff;
  --sidebar-width: 260px;
  --sidebar-collapsed: 0px;
  --accent: #0f3460;
  --accent-light: #e2e8f0;
  --success: #22c55e;
  --warning: #eab308;
  --danger: #ef4444;
  --body-bg: #f1f5f9;
  --card-shadow: 0 1px 3px rgba(0, 0, 0, 0.08), 0 1px 2px rgba(0, 0, 0, 0.06);
  --transition-speed: 0.25s;
}

/* ---- Reset & Base ---- */
html, body {
  height: 100%;
  margin: 0;
  padding: 0;
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--body-bg);
  color: #1e293b;
  font-size: 14px;
}

/* ---- Layout ---- */
.wrapper {
  display: flex;
  min-height: 100vh;
}

/* ---- Sidebar ---- */
.sidebar {
  width: var(--sidebar-width);
  min-height: 100vh;
  background: var(--sidebar-bg);
  color: var(--sidebar-text);
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  z-index: 1040;
  transition: transform var(--transition-speed) ease;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
}

.sidebar-brand {
  padding: 1.25rem 1.5rem;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  text-decoration: none;
  color: #fff;
  font-size: 1.15rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  white-space: nowrap;
}

.sidebar-brand i {
  font-size: 1.5rem;
  color: #60a5fa;
}

.sidebar-nav {
  list-style: none;
  padding: 0.75rem 0;
  margin: 0;
  flex: 1;
}

.sidebar-nav li {}

.sidebar-nav .nav-link {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.7rem 1.5rem;
  color: var(--sidebar-text);
  text-decoration: none;
  font-size: 0.9rem;
  font-weight: 500;
  border-left: 3px solid transparent;
  transition: all var(--transition-speed) ease;
  cursor: pointer;
  white-space: nowrap;
}

.sidebar-nav .nav-link i {
  font-size: 1.1rem;
  width: 22px;
  text-align: center;
  flex-shrink: 0;
}

.sidebar-nav .nav-link:hover {
  background: var(--sidebar-hover);
  color: #d1d5db;
}

.sidebar-nav .nav-link.active {
  background: var(--sidebar-active);
  color: var(--sidebar-text-active);
  border-left-color: #60a5fa;
}

.sidebar-footer {
  padding: 1rem 1.5rem;
  border-top: 1px solid rgba(255, 255, 255, 0.06);
  font-size: 0.75rem;
  color: rgba(255, 255, 255, 0.3);
  text-align: center;
}

/* ---- Main Content ---- */
.main-content {
  margin-left: var(--sidebar-width);
  flex: 1;
  min-height: 100vh;
  transition: margin-left var(--transition-speed) ease;
}

.topbar {
  background: #ffffff;
  border-bottom: 1px solid #e2e8f0;
  padding: 0.75rem 1.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 1030;
}

.topbar-title {
  font-size: 1.1rem;
  font-weight: 600;
  color: #1e293b;
  margin: 0;
}

.btn-sidebar-toggle {
  display: none;
  background: none;
  border: none;
  font-size: 1.4rem;
  color: #475569;
  cursor: pointer;
  padding: 0.25rem;
}

.content-area {
  padding: 1.5rem;
}

/* ---- Overlay (mobile) ---- */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 1035;
}

/* ---- Page Sections ---- */
.page-section {
  display: none;
  animation: fadeIn 0.2s ease;
}

.page-section.active {
  display: block;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ---- Stat Cards ---- */
.stat-card {
  background: #ffffff;
  border-radius: 0.75rem;
  padding: 1.25rem 1.5rem;
  box-shadow: var(--card-shadow);
  border: 1px solid #e2e8f0;
  transition: box-shadow var(--transition-speed) ease;
}

.stat-card:hover {
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.stat-card .stat-icon {
  width: 48px;
  height: 48px;
  border-radius: 0.5rem;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.4rem;
  flex-shrink: 0;
}

.stat-card .stat-icon.bg-primary { background: rgba(59, 130, 246, 0.12); color: #3b82f6; }
.stat-card .stat-icon.bg-success { background: rgba(34, 197, 94, 0.12);  color: #22c55e; }
.stat-card .stat-icon.bg-warning { background: rgba(234, 179, 8, 0.12);  color: #ca8a04; }
.stat-card .stat-icon.bg-info    { background: rgba(6, 182, 212, 0.12);  color: #0891b2; }

.stat-card .stat-value {
  font-size: 1.75rem;
  font-weight: 700;
  line-height: 1.2;
  color: #0f172a;
}

.stat-card .stat-label {
  font-size: 0.8rem;
  color: #64748b;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

/* ---- Cards ---- */
.panel-card {
  background: #ffffff;
  border-radius: 0.75rem;
  box-shadow: var(--card-shadow);
  border: 1px solid #e2e8f0;
  overflow: hidden;
}

.panel-card .card-header-custom {
  background: #ffffff;
  padding: 1rem 1.25rem;
  border-bottom: 1px solid #e2e8f0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-weight: 600;
}

.panel-card .card-body {
  padding: 1.25rem;
}

/* ---- Tables ---- */
.table-panel {
  margin-bottom: 0;
}

.table-panel thead th {
  background: #f8fafc;
  border-bottom: 2px solid #e2e8f0;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: #64748b;
  font-weight: 600;
  padding: 0.75rem 1rem;
  white-space: nowrap;
}

.table-panel tbody td {
  padding: 0.75rem 1rem;
  vertical-align: middle;
  border-bottom: 1px solid #f1f5f9;
  font-size: 0.875rem;
}

.table-panel tbody tr:hover {
  background: #f8fafc;
}

/* ---- Status Badges ---- */
.badge-enviado {
  background: rgba(34, 197, 94, 0.12);
  color: #15803d;
  font-weight: 600;
  font-size: 0.75rem;
  padding: 0.3em 0.7em;
  border-radius: 999px;
}

.badge-dry_run {
  background: rgba(234, 179, 8, 0.12);
  color: #a16207;
  font-weight: 600;
  font-size: 0.75rem;
  padding: 0.3em 0.7em;
  border-radius: 999px;
}

.badge-erro {
  background: rgba(239, 68, 68, 0.12);
  color: #b91c1c;
  font-weight: 600;
  font-size: 0.75rem;
  padding: 0.3em 0.7em;
  border-radius: 999px;
}

.badge-ativo {
  background: rgba(34, 197, 94, 0.12);
  color: #15803d;
  font-weight: 600;
}

.badge-inativo {
  background: rgba(239, 68, 68, 0.12);
  color: #b91c1c;
  font-weight: 600;
}

/* ---- Buttons ---- */
.btn-primary {
  background: var(--accent);
  border-color: var(--accent);
}

.btn-primary:hover {
  background: #0c2d50;
  border-color: #0c2d50;
}

.btn-action {
  padding: 0.25rem 0.5rem;
  font-size: 0.8rem;
  border-radius: 0.375rem;
}

/* ---- Form Styles ---- */
.form-label {
  font-weight: 500;
  font-size: 0.85rem;
  color: #334155;
  margin-bottom: 0.35rem;
}

.form-control:focus,
.form-select:focus {
  border-color: #93c5fd;
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.15);
}

.form-control,
.form-select {
  font-size: 0.875rem;
  border-color: #cbd5e1;
  border-radius: 0.5rem;
}

textarea.form-control {
  min-height: 100px;
}

.variable-hints {
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 0.5rem;
  padding: 0.75rem 1rem;
  margin-bottom: 1rem;
}

.variable-hints code {
  background: #e2e8f0;
  padding: 0.15em 0.45em;
  border-radius: 0.25rem;
  font-size: 0.82rem;
  color: #0f3460;
  margin-right: 0.25rem;
}

/* ---- Agent Cards ---- */
.agent-card {
  border: 1px solid #e2e8f0;
  border-radius: 0.75rem;
  overflow: hidden;
  transition: box-shadow var(--transition-speed) ease;
}

.agent-card:hover {
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
}

.agent-card-header {
  padding: 1rem 1.25rem;
  background: #f8fafc;
  display: flex;
  align-items: center;
  justify-content: space-between;
  cursor: pointer;
  user-select: none;
}

.agent-card-header .agent-name {
  font-weight: 600;
  font-size: 0.95rem;
}

.agent-card-header .agent-meta {
  font-size: 0.8rem;
  color: #64748b;
}

.agent-card-body {
  padding: 1.25rem;
  border-top: 1px solid #e2e8f0;
  display: none;
}

.agent-card-body.show {
  display: block;
  animation: fadeIn 0.2s ease;
}

/* ---- Config Cards ---- */
.config-card {
  background: #ffffff;
  border: 1px solid #e2e8f0;
  border-radius: 0.75rem;
  overflow: hidden;
  margin-bottom: 1rem;
}

.config-card-header {
  padding: 0.85rem 1.25rem;
  background: #f8fafc;
  border-bottom: 1px solid #e2e8f0;
  font-weight: 600;
  font-size: 0.95rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.config-card-body {
  padding: 1.25rem;
}

/* ---- Filter Bar ---- */
.filter-bar {
  background: #ffffff;
  border: 1px solid #e2e8f0;
  border-radius: 0.75rem;
  padding: 1rem 1.25rem;
  margin-bottom: 1rem;
  box-shadow: var(--card-shadow);
}

/* ---- Pagination ---- */
.pagination .page-link {
  color: var(--accent);
  border-color: #e2e8f0;
  font-size: 0.85rem;
  padding: 0.4rem 0.75rem;
}

.pagination .page-item.active .page-link {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.pagination .page-link:hover {
  background: #f1f5f9;
}

/* ---- Toggle / Switch ---- */
.form-check-input:checked {
  background-color: var(--accent);
  border-color: var(--accent);
}

/* ---- Range Slider Label ---- */
.range-value {
  font-weight: 600;
  color: var(--accent);
  font-size: 0.9rem;
}

/* ---- Truncated Text ---- */
.text-truncate-cell {
  max-width: 250px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  display: inline-block;
  vertical-align: middle;
}

/* ---- Loader ---- */
.spinner-wrapper {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 3rem;
}

/* ---- Toast ---- */
.toast-container {
  position: fixed;
  top: 1rem;
  right: 1rem;
  z-index: 1100;
}

/* ---- Empty State ---- */
.empty-state {
  text-align: center;
  padding: 3rem 1rem;
  color: #94a3b8;
}

.empty-state i {
  font-size: 2.5rem;
  margin-bottom: 0.75rem;
  display: block;
}

/* ---- Responsive ---- */
@media (max-width: 991.98px) {
  .sidebar {
    transform: translateX(-100%);
  }

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

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

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

  .btn-sidebar-toggle {
    display: inline-block;
  }

  .content-area {
    padding: 1rem;
  }

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

@media (max-width: 575.98px) {
  .table-responsive {
    font-size: 0.8rem;
  }

  .topbar-title {
    font-size: 0.95rem;
  }
}

/* ---- Scrollbar ---- */
.sidebar::-webkit-scrollbar {
  width: 4px;
}

.sidebar::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.1);
  border-radius: 4px;
}

/* ---- Modal ---- */
.modal-header {
  background: #f8fafc;
  border-bottom: 1px solid #e2e8f0;
}

.modal-title {
  font-weight: 600;
  font-size: 1rem;
}

.modal-footer {
  background: #f8fafc;
  border-top: 1px solid #e2e8f0;
}

/* ---- Provider Card ---- */
.provider-card {
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 0.75rem;
  padding: 1.25rem;
}
