/* ==========================================================================
   DESIGN SYSTEM — PREFEITURA DO RIO (2025)
   Identidade Visual Oficial: Sidebar Azul (#13335a) + Content Main Claro (#eceded / #ffffff)
   ========================================================================== */

:root {
  /* Cores Institucionais */
  --color-primary: #13335a;           /* Azul Institucional */
  --color-primary-dark: #0d223d;
  --color-neutral-light: #eceded;     /* Cinza Claro */
  --color-neutral-bg: #f4f6f9;        /* Fundo do Content Main Claro */
  --color-white: #ffffff;             /* Fundo dos Cards */
  --color-text-dark: #13335a;         /* Texto Principal em Fundo Claro */
  --color-text-muted: #475569;        /* Texto Secundário */
  --color-border-light: rgba(19, 51, 90, 0.12);

  /* Acentuação e Degradê */
  --color-gradient-blue-mid: #2a688f;
  --color-accent-cyan: #42b9eb;        /* Ciano Vibrante / Ponto Final */
  --gradient-institucional: linear-gradient(135deg, #13335a 0%, #2a688f 100%);
  --gradient-cyan: linear-gradient(135deg, #2a688f 0%, #42b9eb 100%);

  /* Status Colors */
  --color-success: #10b981;
  --color-warning: #d97706;
  --color-danger: #ef4444;

  /* Tipografia */
  --font-family: 'Cera Pro', 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-heading: 'Cera Pro Black', 'Outfit', sans-serif;
  --tracking-display: -0.03em;

  /* Bordas e Sombras */
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;
  --shadow-main: 0 4px 20px rgba(19, 51, 90, 0.08);
  --shadow-hover: 0 8px 28px rgba(19, 51, 90, 0.14);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

/* --- BARRA DE ROLAGEM CUSTOMIZADA --- */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

::-webkit-scrollbar-track {
  background: #e2e8f0;
}

::-webkit-scrollbar-thumb {
  background: var(--color-gradient-blue-mid);
  border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--color-primary);
}

body {
  background-color: var(--color-neutral-bg);
  color: var(--color-text-dark);
  font-family: var(--font-family);
  min-height: 100vh;
  overflow-x: hidden;
}

.app-container {
  display: flex;
  min-height: 100vh;
}

/* --- SIDEBAR INSTITUCIONAL (AZUL PREFEITURA #13335a) --- */
.sidebar {
  width: 290px;
  background: var(--color-primary);
  border-right: 1px solid rgba(255, 255, 255, 0.1);
  padding: 28px 20px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  box-shadow: 4px 0 20px rgba(19, 51, 90, 0.2);
  z-index: 10;
}

.brand {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 28px;
}

.logo-icon {
  width: 48px;
  height: 48px;
  border-radius: var(--radius-md);
  background: var(--gradient-cyan);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.6rem;
  color: var(--color-white);
  box-shadow: 0 4px 14px rgba(66, 185, 235, 0.4);
}

.brand-text h2 {
  font-family: var(--font-heading);
  font-size: 1.3rem;
  font-weight: 900;
  letter-spacing: var(--tracking-display);
  text-transform: uppercase;
  color: var(--color-white);
}

.brand-text span {
  font-size: 0.72rem;
  color: var(--color-accent-cyan);
  text-transform: uppercase;
  letter-spacing: 1.2px;
  font-weight: 700;
}

.nav-menu {
  display: flex;
  flex-direction: column;
  gap: 8px;
  flex-grow: 1;
}

.nav-section-label {
  font-size: 0.7rem;
  font-weight: 800;
  color: rgba(255, 255, 255, 0.5);
  letter-spacing: 1px;
  text-transform: uppercase;
  margin-bottom: 4px;
  padding-left: 8px;
}

.nav-btn {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  background: transparent;
  border: none;
  color: var(--color-neutral-light);
  font-family: var(--font-family);
  font-size: 0.92rem;
  font-weight: 600;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.2s ease;
  text-align: left;
  opacity: 0.85;
}

.nav-btn:hover {
  background: rgba(255, 255, 255, 0.1);
  color: var(--color-white);
  opacity: 1;
}

.nav-btn.active {
  background: linear-gradient(90deg, rgba(66, 185, 235, 0.25), rgba(66, 185, 235, 0.05));
  color: var(--color-accent-cyan);
  border-left: 4px solid var(--color-accent-cyan);
  font-weight: 700;
  opacity: 1;
}

.bot-status-card {
  background: rgba(0, 0, 0, 0.25);
  border: 1px solid rgba(255, 255, 255, 0.15);
  padding: 16px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 20px;
}

.status-indicator {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: #94a3b8;
}

.status-indicator.online {
  background: var(--color-accent-cyan);
  box-shadow: 0 0 12px var(--color-accent-cyan);
}

.bot-status-info {
  display: flex;
  flex-direction: column;
}

.status-title {
  font-weight: 700;
  font-size: 0.9rem;
  color: var(--color-white);
}

.status-sub {
  font-size: 0.75rem;
  color: var(--color-accent-cyan);
}

/* --- MAIN CONTENT --- */
.main-content {
  flex-grow: 1;
  padding: 36px 44px;
  background-color: var(--color-neutral-bg);
  overflow-y: auto;
}

.top-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 28px;
}

.header-title h1 {
  font-family: var(--font-heading);
  font-size: 2.1rem;
  font-weight: 900;
  letter-spacing: var(--tracking-display);
  color: var(--color-primary);
  display: flex;
  align-items: center;
  gap: 8px;
}

.header-title p {
  color: var(--color-text-muted);
  font-size: 0.95rem;
  margin-top: 4px;
}

/* TRIÂNGULO "PONTO-FINAL" DA PREFEITURA DO RIO */
.triangulo-ponto {
  display: inline-block;
  width: 0;
  height: 0;
  border-left: 7px solid transparent;
  border-right: 7px solid transparent;
  border-bottom: 12px solid var(--color-accent-cyan);
  transform: rotate(90deg);
  margin-left: 4px;
}

/* --- WIZARD STEPPER BAR (PROGRESSO EM 3 PASSOS) --- */
.wizard-stepper {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--color-white);
  border: 1px solid var(--color-border-light);
  border-radius: var(--radius-lg);
  padding: 20px 32px;
  margin-bottom: 32px;
  box-shadow: var(--shadow-main);
}

.wizard-step-item {
  display: flex;
  align-items: center;
  gap: 14px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.step-badge {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: #e2e8f0;
  color: var(--color-text-muted);
  font-family: var(--font-heading);
  font-weight: 900;
  font-size: 1.1rem;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.3s ease;
}

.step-info {
  display: flex;
  flex-direction: column;
}

.step-title {
  font-family: var(--font-heading);
  font-size: 0.95rem;
  font-weight: 800;
  color: var(--color-text-muted);
  transition: color 0.2s ease;
}

.step-sub {
  font-size: 0.78rem;
  color: var(--color-text-muted);
}

.wizard-step-item.active .step-badge {
  background: var(--gradient-cyan);
  color: var(--color-white);
  box-shadow: 0 4px 14px rgba(66, 185, 235, 0.4);
}

.wizard-step-item.active .step-title {
  color: var(--color-primary);
}

.wizard-step-item.completed .step-badge {
  background: var(--color-success);
  color: var(--color-white);
}

.wizard-step-item.completed .step-title {
  color: var(--color-primary);
}

.step-connector {
  flex-grow: 1;
  height: 3px;
  background: #e2e8f0;
  margin: 0 20px;
  border-radius: 2px;
}

.step-connector.active {
  background: var(--color-accent-cyan);
}

/* WIZARD PANELS */
.wizard-panel {
  display: none;
  animation: fadeIn 0.3s ease;
}

.wizard-panel.active {
  display: block;
}

.wizard-actions {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 28px;
  padding-top: 20px;
  border-top: 1px solid var(--color-border-light);
}

/* --- TABS --- */
.tab-content {
  display: none;
  animation: fadeIn 0.3s ease;
}

.tab-content.active {
  display: block;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

/* --- STATS GRID --- */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 20px;
  margin-bottom: 32px;
}

.stat-card {
  background: var(--color-white);
  border: 1px solid var(--color-border-light);
  padding: 24px;
  border-radius: var(--radius-lg);
  display: flex;
  align-items: center;
  gap: 20px;
  box-shadow: var(--shadow-main);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.stat-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-hover);
}

.stat-icon {
  width: 56px;
  height: 56px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
}

.stat-icon.purple { background: rgba(19, 51, 90, 0.08); color: var(--color-primary); }
.stat-icon.cyan { background: rgba(66, 185, 235, 0.12); color: var(--color-gradient-blue-mid); }
.stat-icon.green { background: rgba(16, 185, 129, 0.12); color: var(--color-success); }

.stat-value {
  font-family: var(--font-heading);
  font-size: 1.8rem;
  font-weight: 900;
  letter-spacing: var(--tracking-display);
  color: var(--color-primary);
  display: block;
}

.stat-label {
  font-size: 0.85rem;
  color: var(--color-text-muted);
}

/* --- CONTENT CARD --- */
.content-card {
  background: var(--color-white);
  border: 1px solid var(--color-border-light);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-main);
  overflow: hidden;
  margin-bottom: 32px;
}

.card-header {
  padding: 24px 28px;
  border-bottom: 1px solid var(--color-border-light);
  background: #fafbfc;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.card-header h3 {
  font-family: var(--font-heading);
  font-size: 1.25rem;
  font-weight: 800;
  color: var(--color-primary);
  display: flex;
  align-items: center;
  gap: 10px;
}

.card-header p {
  color: var(--color-text-muted);
  font-size: 0.88rem;
  margin-top: 4px;
}

.card-body {
  padding: 28px;
}

/* --- FORM GRID PAGE --- */
.form-grid-page {
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.form-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 20px;
}

.page-form-actions {
  display: flex;
  justify-content: flex-end;
  gap: 12px;
  margin-top: 24px;
  padding-top: 20px;
  border-top: 1px solid var(--color-border-light);
}

/* --- BUTTONS INSTITUCIONAIS --- */
.btn {
  padding: 11px 20px;
  font-family: var(--font-family);
  font-size: 0.88rem;
  font-weight: 700;
  border-radius: var(--radius-sm);
  cursor: pointer;
  border: none;
  transition: all 0.2s ease;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.btn-primary {
  background: var(--gradient-institucional);
  color: var(--color-white);
  box-shadow: 0 4px 14px rgba(19, 51, 90, 0.25);
}

.btn-primary:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 18px rgba(19, 51, 90, 0.35);
}

.btn-outline {
  background: var(--color-white);
  border: 1px solid rgba(19, 51, 90, 0.25);
  color: var(--color-primary);
}

.btn-outline:hover {
  background: rgba(19, 51, 90, 0.05);
  border-color: var(--color-primary);
}

.btn-danger {
  background: rgba(239, 68, 68, 0.1);
  color: #dc2626;
  border: 1px solid rgba(239, 68, 68, 0.25);
}

.btn-danger:hover {
  background: rgba(239, 68, 68, 0.2);
}

/* --- RULES LIST --- */
.rules-list {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.rule-item {
  background: #f8fafc;
  border: 1px solid var(--color-border-light);
  border-radius: var(--radius-md);
  padding: 20px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  transition: border-color 0.2s ease;
}

.rule-item:hover {
  border-color: var(--color-gradient-blue-mid);
}

.rule-info h4 {
  font-family: var(--font-heading);
  font-size: 1.1rem;
  font-weight: 800;
  color: var(--color-primary);
  display: flex;
  align-items: center;
  gap: 10px;
}

.rule-info p {
  color: var(--color-text-muted);
  font-size: 0.85rem;
  margin-top: 4px;
}

.rule-tags {
  display: flex;
  gap: 8px;
  margin-top: 10px;
  flex-wrap: wrap;
}

.badge {
  padding: 4px 12px;
  border-radius: 20px;
  font-size: 0.75rem;
  font-weight: 700;
  background: #e2e8f0;
  color: var(--color-primary);
  text-transform: uppercase;
}

.badge.badge-success { background: rgba(16, 185, 129, 0.15); color: #047857; }
.badge.badge-warning { background: rgba(217, 119, 6, 0.15); color: #b45309; }
.badge.badge-purple { background: rgba(19, 51, 90, 0.1); color: var(--color-primary); }
.badge.badge-cyan { background: rgba(66, 185, 235, 0.15); color: #0284c7; }

.rule-actions {
  display: flex;
  gap: 8px;
}

/* URA BOX & MULTI-LEVEL CARDS */
.ivr-box {
  background: #f8fafc;
  border: 1px solid var(--color-border-light);
  border-radius: var(--radius-md);
  padding: 22px;
  margin-top: 14px;
}

.ivr-box h4 {
  font-family: var(--font-heading);
  font-size: 1.05rem;
  color: var(--color-primary);
  margin-bottom: 6px;
}

.ivr-option-card {
  background: var(--color-white);
  border: 1px solid var(--color-border-light);
  border-radius: var(--radius-sm);
  padding: 18px;
  margin-top: 14px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.03);
}

.ivr-option-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.95rem;
  color: var(--color-primary);
}

.suboptions-box {
  background: rgba(66, 185, 235, 0.08);
  border-left: 4px solid var(--color-gradient-blue-mid);
  border-radius: var(--radius-sm);
  padding: 16px;
  margin-top: 12px;
}

.suboptions-box h5 {
  font-family: var(--font-heading);
  font-size: 0.9rem;
  color: var(--color-primary);
  margin-bottom: 10px;
}

/* INPUTS & FORMULÁRIOS CLAROS */
input[type="text"], input[type="number"], textarea, select {
  width: 100%;
  padding: 12px 16px;
  background: var(--color-white);
  border: 1px solid rgba(19, 51, 90, 0.2);
  border-radius: var(--radius-sm);
  color: var(--color-primary);
  font-family: var(--font-family);
  font-size: 0.95rem;
  font-weight: 500;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

input[type="text"]:focus, input[type="number"]:focus, textarea:focus, select:focus {
  outline: none;
  border-color: var(--color-gradient-blue-mid);
  box-shadow: 0 0 0 3px rgba(42, 104, 143, 0.2);
}

.table-responsive {
  overflow-x: auto;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
}

.data-table th, .data-table td {
  padding: 14px 18px;
  border-bottom: 1px solid var(--color-border-light);
  font-size: 0.9rem;
}

.data-table th {
  color: var(--color-primary);
  font-family: var(--font-heading);
  font-weight: 800;
  text-transform: uppercase;
  font-size: 0.75rem;
  letter-spacing: 0.8px;
  background: #f1f5f9;
}

.data-table tr:hover {
  background: rgba(19, 51, 90, 0.02);
}

.form-grid {
  display: flex;
  flex-direction: column;
  gap: 20px;
  max-width: 600px;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.form-group label {
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--color-primary);
}

.form-group small {
  color: var(--color-text-muted);
  font-size: 0.78rem;
}

.checkbox-group {
  flex-direction: row;
  align-items: center;
  gap: 12px;
}

/* Switch Toggle */
.switch {
  position: relative;
  display: inline-block;
  width: 44px;
  height: 24px;
}

.switch input { opacity: 0; width: 0; height: 0; }

.slider {
  position: absolute;
  cursor: pointer;
  top: 0; left: 0; right: 0; bottom: 0;
  background-color: #cbd5e1;
  transition: .3s;
  border-radius: 24px;
}

.slider:before {
  position: absolute;
  content: "";
  height: 18px; width: 18px;
  left: 3px; bottom: 3px;
  background-color: white;
  transition: .3s;
  border-radius: 50%;
}

input:checked + .slider { background-color: var(--color-primary); }
input:checked + .slider:before { transform: translateX(20px); }

/* CARTÃO DE SESSÃO AUTENTICADA (barra lateral) */
.session-card {
  margin-top: 12px;
  padding: 12px 14px;
  border-radius: var(--radius-md);
  background: rgba(255, 255, 255, .07);
  border: 1px solid rgba(255, 255, 255, .12);
}

.session-info {
  display: flex;
  align-items: center;
  gap: 8px;
  color: rgba(255, 255, 255, .92);
  font-size: .8rem;
  margin-bottom: 8px;
  overflow: hidden;
}

.session-info span {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.session-logout {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: rgba(255, 255, 255, .7);
  font-size: .78rem;
  font-weight: 700;
  text-decoration: none;
  transition: color .2s;
}

.session-logout:hover { color: #fca5a5; }

/* WIZARD "QUANDO" — CARTÕES DE GATILHO (SELEÇÃO ÚNICA) */
.trigger-option {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  padding: 18px 20px;
  margin-bottom: 14px;
  background: #f8fafc;
  border: 2px solid var(--color-border-light);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: border-color .2s, background-color .2s;
}

.trigger-option:hover { border-color: var(--color-gradient-blue-mid); }

.trigger-option input[type="radio"] {
  width: 18px;
  height: 18px;
  margin-top: 3px;
  accent-color: var(--color-primary);
  cursor: pointer;
  flex-shrink: 0;
}

.trigger-option:has(input[type="radio"]:checked) {
  border-color: var(--color-primary);
  background: #eff6ff;
}

.trigger-title {
  display: block;
  font-weight: 800;
  color: var(--color-primary);
  margin-bottom: 4px;
}

.trigger-desc {
  display: block;
  color: var(--color-text-muted);
  font-size: 0.82rem;
  line-height: 1.5;
}

/* WIZARD "ENTÃO" — BLOCOS DE CONSEQUÊNCIA */
.action-block {
  background: #f8fafc;
  padding: 20px;
  border-radius: var(--radius-md);
  border: 1px solid var(--color-border-light);
  margin-bottom: 20px;
}

/* Campos desativados quando a consequência correspondente está desligada */
.action-fields-disabled {
  opacity: 0.45;
  pointer-events: none;
}

/* TOAST */
.toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  padding: 14px 24px;
  border-radius: var(--radius-md);
  background: var(--color-primary);
  color: white;
  box-shadow: 0 10px 25px rgba(0,0,0,0.25);
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 600;
  transform: translateY(100px);
  opacity: 0;
  transition: all 0.3s ease;
  z-index: 2000;
}

.toast.show {
  transform: translateY(0);
  opacity: 1;
}

.toast.success { border-left: 4px solid var(--color-accent-cyan); }
.toast.error { border-left: 4px solid var(--color-danger); }
