/* CSS Variables - Premium Slate & Neon Palette */
:root {
  --font-sans: 'Outfit', sans-serif;
  --font-mono: 'Space Mono', monospace;

  /* Colors */
  --bg-dark: #090d16;
  --panel-bg: rgba(15, 23, 42, 0.6);
  --border-glass: rgba(255, 255, 255, 0.08);
  --text-primary: #f8fafc;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;
  
  --primary: #3b82f6;       /* Sapphire Blue */
  --primary-hover: #2563eb;
  --primary-glow: rgba(59, 130, 246, 0.35);

  --accent-emerald: #10b981; /* Success Green */
  --accent-emerald-glow: rgba(16, 185, 129, 0.3);
  --accent-amber: #f59e0b;   /* Warning Amber */
  --accent-rose: #f43f5e;    /* Error Red */
  --accent-purple: #a855f7;  /* System Violet */

  --card-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.37);
  --radius-lg: 16px;
  --radius-md: 10px;
  --radius-sm: 6px;
  
  --transition-smooth: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Global Reset */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  background-color: var(--bg-dark);
  color: var(--text-primary);
  font-family: var(--font-sans);
  min-height: 100vh;
  position: relative;
  overflow-x: hidden;
  padding: 2rem 1rem;
}

/* Background Glowing Gradients */
.bg-gradient {
  position: fixed;
  border-radius: 50%;
  filter: blur(120px);
  z-index: -1;
  opacity: 0.45;
  pointer-events: none;
}

.bg-1 {
  width: 500px;
  height: 500px;
  background: radial-gradient(circle, rgba(99, 102, 241, 0.3) 0%, rgba(59, 130, 246, 0.05) 70%);
  top: -100px;
  right: -100px;
}

.bg-2 {
  width: 600px;
  height: 600px;
  background: radial-gradient(circle, rgba(168, 85, 247, 0.25) 0%, rgba(244, 63, 94, 0.02) 75%);
  bottom: -200px;
  left: -150px;
}

/* Glassmorphism Card Style */
.glass-card {
  background: var(--panel-bg);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--border-glass);
  border-radius: var(--radius-lg);
  box-shadow: var(--card-shadow);
}

/* Page Layout */
.container {
  max-width: 1200px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

/* Header Bar */
.header-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1.25rem 2rem;
  flex-wrap: wrap;
  gap: 1rem;
}

.logo-area {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.logo-area h1 {
  font-size: 1.5rem;
  font-weight: 700;
  letter-spacing: -0.5px;
  background: linear-gradient(135deg, #ffffff 40%, #a5b4fc 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.logo-area .subtitle {
  font-size: 0.85rem;
  color: var(--text-secondary);
}

.status-indicator {
  position: relative;
  display: flex;
}

.status-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  display: inline-block;
}

.status-dot.active {
  background-color: var(--accent-emerald);
  box-shadow: 0 0 12px var(--accent-emerald-glow);
  animation: pulse-green 2s infinite;
}

.status-dot.idle {
  background-color: var(--text-muted);
}

.status-dot.dry-run {
  background-color: var(--accent-amber);
  box-shadow: 0 0 12px rgba(245, 158, 11, 0.4);
  animation: pulse-orange 2s infinite;
}

.header-controls {
  display: flex;
  align-items: center;
  gap: 1.5rem;
  flex-wrap: wrap;
}

.uptime-badge {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.05);
  padding: 0.5rem 0.85rem;
  border-radius: var(--radius-sm);
  font-family: var(--font-mono);
  font-size: 0.85rem;
}

.uptime-badge .label {
  color: var(--text-secondary);
  margin-right: 0.4rem;
}

/* Switch Toggle Button */
.toggle-container {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.toggle-label {
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--text-secondary);
}

.switch {
  position: relative;
  display: inline-block;
  width: 48px;
  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: rgba(255, 255, 255, 0.1);
  transition: .4s;
  border: 1px solid var(--border-glass);
}

.slider:before {
  position: absolute;
  content: "";
  height: 16px;
  width: 16px;
  left: 3px;
  bottom: 3px;
  background-color: white;
  transition: .4s;
}

input:checked + .slider {
  background-color: var(--accent-emerald);
  box-shadow: 0 0 10px rgba(16, 185, 129, 0.3);
}

input:focus + .slider {
  box-shadow: 0 0 1px var(--accent-emerald);
}

input:checked + .slider:before {
  transform: translateX(24px);
}

.slider.round {
  border-radius: 34px;
}

.slider.round:before {
  border-radius: 50%;
}

/* Button Styles */
.btn {
  font-family: var(--font-sans);
  font-weight: 600;
  font-size: 0.9rem;
  padding: 0.6rem 1.2rem;
  border-radius: var(--radius-md);
  border: 1px solid transparent;
  cursor: pointer;
  transition: var(--transition-smooth);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  text-decoration: none;
}

.btn-primary {
  background-color: var(--primary);
  color: white;
  box-shadow: 0 4px 14px var(--primary-glow);
}

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

.btn-secondary {
  background-color: rgba(255, 255, 255, 0.05);
  border-color: var(--border-glass);
  color: var(--text-primary);
}

.btn-secondary:hover {
  background-color: rgba(255, 255, 255, 0.1);
}

.btn-small {
  padding: 0.4rem 0.85rem;
  font-size: 0.8rem;
  border-radius: var(--radius-sm);
}

.btn-icon {
  padding: 0.6rem 0.9rem;
}

/* Metrics Grid */
.metrics-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 1.25rem;
}

.metric-card {
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  min-height: 140px;
  position: relative;
  overflow: hidden;
}

.metric-card:before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 4px;
  height: 100%;
}

#card-status:before { background-color: var(--primary); }
#card-db:before { background-color: var(--accent-purple); }
#card-cooldown:before { background-color: var(--accent-amber); }
#card-stats:before { background-color: var(--accent-emerald); }

.metric-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  color: var(--text-secondary);
  font-size: 0.85rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.metric-header .icon {
  font-size: 1.2rem;
  opacity: 0.8;
}

.metric-value {
  font-size: 1.8rem;
  font-weight: 700;
  margin: 0.5rem 0;
  color: var(--text-primary);
  letter-spacing: -0.5px;
}

.metric-footer {
  font-size: 0.8rem;
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.stats-mini-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.5rem;
  text-align: center;
  margin-top: 0.5rem;
}

.stat-item {
  display: flex;
  flex-direction: column;
}

.stat-num {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--text-primary);
}

.stat-lbl {
  font-size: 0.65rem;
  text-transform: uppercase;
  color: var(--text-secondary);
  margin-top: 0.15rem;
}

.text-danger .stat-num {
  color: var(--accent-rose);
}

/* Content Body */
.content-body {
  display: grid;
  grid-template-columns: 1.1fr 0.9fr;
  gap: 1.5rem;
}

@media (max-width: 900px) {
  .content-body {
    grid-template-columns: 1fr;
  }
}

/* Tabs System */
.config-panel {
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.tabs {
  display: flex;
  border-bottom: 1px solid var(--border-glass);
  background: rgba(0, 0, 0, 0.15);
}

.tab-btn {
  background: none;
  border: none;
  color: var(--text-secondary);
  font-family: var(--font-sans);
  font-size: 0.9rem;
  font-weight: 600;
  padding: 1.25rem 1.5rem;
  cursor: pointer;
  transition: var(--transition-smooth);
  position: relative;
}

.tab-btn:hover {
  color: var(--text-primary);
  background: rgba(255, 255, 255, 0.02);
}

.tab-btn.active {
  color: var(--primary);
}

.tab-btn.active:after {
  content: '';
  position: absolute;
  bottom: -1px;
  left: 0;
  width: 100%;
  height: 2px;
  background-color: var(--primary);
  box-shadow: 0 0 10px var(--primary-glow);
}

/* Form Styling */
.tab-content-container {
  padding: 1.75rem;
  flex-grow: 1;
  display: flex;
  flex-direction: column;
}

.tab-content {
  display: none;
  flex-direction: column;
  gap: 1rem;
}

.tab-content.active {
  display: flex;
}

.tab-content h3 {
  font-size: 1.15rem;
  font-weight: 600;
}

.tab-desc {
  font-size: 0.85rem;
  color: var(--text-secondary);
  margin-bottom: 0.75rem;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 1.25rem;
}

.input-group {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.input-group.full-width {
  grid-column: span 2;
}

@media (max-width: 600px) {
  .form-grid {
    grid-template-columns: 1fr;
  }
  .input-group.full-width {
    grid-column: span 1;
  }
}

.input-group label {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.input-group input[type="text"],
.input-group input[type="password"],
.input-group input[type="number"],
.input-group input[type="url"],
.input-group textarea {
  background: rgba(0, 0, 0, 0.25);
  border: 1px solid var(--border-glass);
  border-radius: var(--radius-md);
  padding: 0.75rem 1rem;
  color: var(--text-primary);
  font-family: var(--font-sans);
  font-size: 0.9rem;
  transition: var(--transition-smooth);
}

.input-group textarea {
  resize: vertical;
}

.input-group input:focus,
.input-group textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.15);
  background: rgba(0, 0, 0, 0.35);
}

/* Styled Checkbox */
.checkbox-container {
  display: flex;
  align-items: center;
  position: relative;
  cursor: pointer;
  padding-left: 2rem;
  user-select: none;
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--text-primary);
}

.checkbox-container.small {
  font-size: 0.8rem;
  color: var(--text-secondary);
}

.checkbox-container input {
  position: absolute;
  opacity: 0;
  cursor: pointer;
  height: 0;
  width: 0;
}

.checkmark {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  left: 0;
  height: 18px;
  width: 18px;
  background-color: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border-glass);
  border-radius: var(--radius-sm);
  transition: var(--transition-smooth);
}

.checkbox-container:hover input ~ .checkmark {
  background-color: rgba(255, 255, 255, 0.1);
}

.checkbox-container input:checked ~ .checkmark {
  background-color: var(--primary);
  border-color: var(--primary);
}

.checkmark:after {
  content: "";
  position: absolute;
  display: none;
}

.checkbox-container input:checked ~ .checkmark:after {
  display: block;
}

.checkbox-container .checkmark:after {
  left: 6px;
  top: 2px;
  width: 4px;
  height: 8px;
  border: solid white;
  border-width: 0 2px 2px 0;
  transform: rotate(45deg);
}

.check-group {
  justify-content: center;
}

/* Form Footer */
.form-footer {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 1.5rem;
  margin-top: 2rem;
  padding-top: 1.25rem;
  border-top: 1px solid var(--border-glass);
}

.save-status-msg {
  font-size: 0.85rem;
  font-weight: 600;
}

.save-status-msg.success { color: var(--accent-emerald); }
.save-status-msg.error { color: var(--accent-rose); }

/* Live Logs Console */
.logs-panel {
  display: flex;
  flex-direction: column;
  max-height: 576px;
}

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

.title-with-pulse {
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

.pulse-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background-color: var(--accent-rose);
  animation: pulse-red 1.5s infinite;
}

.logs-controls {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.logs-console {
  background: rgba(4, 6, 10, 0.7);
  flex-grow: 1;
  padding: 1.25rem;
  font-family: var(--font-mono);
  font-size: 0.8rem;
  line-height: 1.5;
  overflow-y: auto;
  min-height: 380px;
  max-height: 480px;
  border-bottom-left-radius: var(--radius-lg);
  border-bottom-right-radius: var(--radius-lg);
}

.log-line {
  margin-bottom: 0.5rem;
  white-space: pre-wrap;
  word-break: break-all;
}

.log-line.info { color: #e2e8f0; }
.log-line.warn { color: var(--accent-amber); }
.log-line.error { color: var(--accent-rose); font-weight: bold; }
.log-line.system { color: var(--accent-purple); }

/* Overlay & Login Modal */
.overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(9, 13, 22, 0.85);
  backdrop-filter: blur(10px);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition-smooth);
}

.login-card {
  width: 100%;
  max-width: 400px;
  padding: 2.5rem;
  text-align: center;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.login-card h2 {
  font-size: 1.5rem;
  font-weight: 700;
}

.login-card p {
  font-size: 0.9rem;
  color: var(--text-secondary);
  line-height: 1.4;
}

.login-card form {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
  text-align: left;
}

.error-text {
  font-size: 0.8rem;
  color: var(--accent-rose);
  font-weight: 600;
  text-align: center;
}

.hidden {
  display: none !important;
}

/* Animations */
@keyframes pulse-green {
  0% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.7); }
  70% { transform: scale(1); box-shadow: 0 0 0 6px rgba(16, 185, 129, 0); }
  100% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(16, 185, 129, 0); }
}

@keyframes pulse-orange {
  0% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(245, 158, 11, 0.7); }
  70% { transform: scale(1); box-shadow: 0 0 0 6px rgba(245, 158, 11, 0); }
  100% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(245, 158, 11, 0); }
}

@keyframes pulse-red {
  0% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(244, 63, 94, 0.7); }
  70% { transform: scale(1); box-shadow: 0 0 0 6px rgba(244, 63, 94, 0); }
  100% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(244, 63, 94, 0); }
}

/* Right Column wrapper */
.right-column {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

/* Instances Panel */
.instances-panel {
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

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

.instances-controls {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.title-with-icon {
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

.title-with-icon h3 {
  font-size: 1.1rem;
  font-weight: 600;
}

#instances-count-badge {
  background: rgba(59, 130, 246, 0.1);
  border-color: rgba(59, 130, 246, 0.2);
  color: var(--primary);
}

.instances-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 1rem;
  padding: 1.5rem;
  max-height: 280px;
  overflow-y: auto;
}

.instance-card {
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid rgba(255, 255, 255, 0.04);
  border-radius: var(--radius-md);
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  transition: var(--transition-smooth);
}

.instance-card:hover {
  background: rgba(255, 255, 255, 0.04);
  border-color: rgba(255, 255, 255, 0.08);
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.instance-card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.5rem;
}

.instance-name {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.instance-perfil {
  font-size: 0.75rem;
  color: var(--text-secondary);
  font-weight: 500;
}

.instance-number {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 0.25rem;
}

.instance-status-badge {
  font-size: 0.65rem;
  padding: 0.15rem 0.4rem;
  border-radius: var(--radius-sm);
  font-weight: 700;
  text-transform: uppercase;
}

.instance-status-badge.apta {
  background: rgba(16, 185, 129, 0.1);
  color: var(--accent-emerald);
  border: 1px solid rgba(16, 185, 129, 0.2);
}

.instance-status-badge.inativa {
  background: rgba(244, 63, 94, 0.1);
  color: var(--accent-rose);
  border: 1px solid rgba(244, 63, 94, 0.2);
}

.instance-status-badge.ativo {
  background: rgba(59, 130, 246, 0.15);
  color: var(--primary);
  border: 1px solid rgba(59, 130, 246, 0.25);
}

.instance-status-badge.inativo-estado {
  background: rgba(255, 255, 255, 0.05);
  color: var(--text-muted);
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.disabled-card {
  opacity: 0.55;
  filter: grayscale(30%);
}

.disabled-card:hover {
  opacity: 0.8;
  filter: grayscale(0%);
}

.instance-restriction {
  font-family: var(--font-mono);
  font-size: 0.65rem;
  color: var(--accent-amber);
  margin-top: 0.2rem;
  background: rgba(245, 158, 11, 0.05);
  padding: 0.25rem;
  border-radius: var(--radius-sm);
  border: 1px dashed rgba(245, 158, 11, 0.2);
}

.instance-placeholder {
  grid-column: 1 / -1;
  text-align: center;
  color: var(--text-muted);
  font-size: 0.85rem;
  padding: 2rem;
}

/* Small switch for instances */
.switch.small {
  width: 36px;
  height: 20px;
}

.switch.small .slider:before {
  height: 14px;
  width: 14px;
  left: 2px;
  bottom: 2px;
}

.switch.small input:checked + .slider:before {
  transform: translateX(16px);
}

/* Modal Overlay & Card styling */
.modal-card {
  width: 90%;
  max-width: 650px;
  padding: 2rem;
  border-radius: var(--radius-lg);
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
  position: relative;
  max-height: 90vh;
  overflow-y: auto;
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.modal-header h2 {
  font-size: 1.35rem;
  font-weight: 700;
  background: linear-gradient(135deg, #ffffff 40%, #a5b4fc 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.modal-desc {
  font-size: 0.85rem;
  color: var(--text-secondary);
  line-height: 1.4;
}

.close-btn {
  background: none;
  border: none;
  color: var(--text-secondary);
  font-size: 1.75rem;
  cursor: pointer;
  transition: var(--transition-smooth);
  padding: 0.2rem;
  line-height: 1;
}

.close-btn:hover {
  color: var(--accent-rose);
  transform: scale(1.1);
}

.instances-modal-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
  gap: 1rem;
  max-height: 55vh;
  overflow-y: auto;
  padding-right: 0.25rem;
  margin-top: 0.5rem;
}

