:root {
  --bg: #0b0f19;
  --card-bg: rgba(30, 41, 59, 0.4);
  --glass-bg: rgba(255, 255, 255, 0.02);
  --glass-border: rgba(255, 255, 255, 0.06);
  --primary: #4f46e5;
  --primary-hover: #6366f1;
  --danger: #ef4444;
  --danger-hover: #f87171;
  --warning: #f59e0b;
  --warning-hover: #fbbf24;
  --success: #10b981;
  
  --text: #f3f4f6;
  --text-muted: #9ca3af;
  --font: 'Outfit', sans-serif;
}

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

body {
  font-family: var(--font);
  background: var(--bg);
  background-image: 
    radial-gradient(at 10% 20%, rgba(79, 70, 229, 0.08) 0px, transparent 50%),
    radial-gradient(at 90% 80%, rgba(16, 185, 129, 0.05) 0px, transparent 50%);
  color: var(--text);
  min-height: 100vh;
  padding: 2rem;
}

.dashboard-wrapper {
  max-width: 1400px;
  margin: 0 auto;
  position: relative;
}

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

.logo-text {
  font-size: 2.2rem;
  font-weight: 800;
  letter-spacing: -1px;
  background: linear-gradient(135deg, #a5b4fc, #6366f1, #34d399);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.subtitle {
  font-size: 0.95rem;
  color: var(--text-muted);
}

.session-info {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.role-badge {
  background: rgba(99, 102, 241, 0.15);
  border: 1px solid rgba(99, 102, 241, 0.3);
  color: #a5b4fc;
  padding: 0.4rem 0.8rem;
  border-radius: 20px;
  font-size: 0.8rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

/* Global Status Banner */
.global-status-banner {
  display: flex;
  align-items: center;
  gap: 1rem;
  background: rgba(30, 41, 59, 0.5);
  border: 1px solid var(--glass-border);
  padding: 1rem 1.5rem;
  border-radius: 16px;
  margin-bottom: 2rem;
  font-weight: 500;
}

.global-status-banner.healthy { border-color: rgba(16, 185, 129, 0.3); background: rgba(16, 185, 129, 0.05); }
.global-status-banner.warning { border-color: rgba(245, 158, 11, 0.3); background: rgba(245, 158, 11, 0.05); }
.global-status-banner.critical { border-color: rgba(239, 68, 68, 0.3); background: rgba(239, 68, 68, 0.05); }

.pulse-indicator {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--text-muted);
  position: relative;
}

.healthy .pulse-indicator { background: var(--success); }
.warning .pulse-indicator { background: var(--warning); }
.critical .pulse-indicator { background: var(--danger); }

.pulse-indicator::after {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0; bottom: 0;
  border-radius: 50%;
  animation: pulse 1.5s infinite;
  box-shadow: 0 0 0 0 rgba(255, 255, 255, 0.5);
}

.healthy .pulse-indicator::after { box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.7); }
.warning .pulse-indicator::after { box-shadow: 0 0 0 0 rgba(245, 158, 11, 0.7); }
.critical .pulse-indicator::after { box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.7); }

@keyframes pulse {
  0% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(255, 255, 255, 0.7); }
  70% { transform: scale(1); box-shadow: 0 0 0 8px rgba(255, 255, 255, 0); }
  100% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(255, 255, 255, 0); }
}

/* Dashboard Grid Layout */
.dashboard-grid {
  display: grid;
  grid-template-columns: repeat(12, 1fr);
  gap: 2rem;
}

.card {
  background: var(--card-bg);
  border: 1px solid var(--glass-border);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-radius: 20px;
  padding: 1.8rem;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
  transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.card:hover {
  transform: translateY(-2px);
  box-shadow: 0 15px 35px rgba(0, 0, 0, 0.3);
}

.card h2 {
  font-size: 1.25rem;
  font-weight: 700;
  margin-bottom: 1.5rem;
  border-left: 4px solid var(--primary);
  padding-left: 0.75rem;
  color: var(--text);
}

/* Span Configs inside Grid */
.vps-metrics { grid-column: span 4; }
.cecilia-funnel { grid-column: span 8; }
.bots-status { grid-column: span 12; }
.evolution-status { grid-column: span 12; }
.chatwoot-status { grid-column: span 12; }
.freshness-status { grid-column: span 12; }
.admin-controls { grid-column: span 12; }

@media (max-width: 1024px) {
  .vps-metrics, .cecilia-funnel { grid-column: span 12; }
}

/* Buttons */
.btn {
  font-family: inherit;
  font-size: 0.9rem;
  font-weight: 600;
  padding: 0.6rem 1.2rem;
  border-radius: 10px;
  border: none;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  transition: all 0.3s ease;
}

.btn-primary { background: var(--primary); color: white; }
.btn-primary:hover { background: var(--primary-hover); transform: translateY(-1px); }
.btn-secondary { background: rgba(255, 255, 255, 0.08); border: 1px solid var(--glass-border); color: var(--text); }
.btn-secondary:hover { background: rgba(255, 255, 255, 0.12); }
.btn-danger { background: var(--danger); color: white; }
.btn-danger:hover { background: var(--danger-hover); }
.btn-warning { background: var(--warning); color: white; }
.btn-warning:hover { background: var(--warning-hover); }

/* Table styling */
.table-responsive {
  width: 100%;
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
}

th, td {
  padding: 0.9rem 1.2rem;
  border-bottom: 1px solid var(--glass-border);
  font-size: 0.9rem;
}

th {
  color: var(--text-muted);
  font-weight: 600;
  text-transform: uppercase;
  font-size: 0.75rem;
  letter-spacing: 0.5px;
}

tr:last-child td { border-bottom: none; }

/* Status tags in tables */
.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.8rem;
  font-weight: 600;
  padding: 0.25rem 0.6rem;
  border-radius: 12px;
  text-transform: uppercase;
}

.status-badge.up, .status-badge.open, .status-badge.healthy {
  background: rgba(16, 185, 129, 0.15); color: #6ee7b7; border: 1px solid rgba(16, 185, 129, 0.3);
}
.status-badge.down, .status-badge.closed, .status-badge.critical {
  background: rgba(239, 68, 68, 0.15); color: #fca5a5; border: 1px solid rgba(239, 68, 68, 0.3);
}
.status-badge.warning, .status-badge.degraded {
  background: rgba(245, 158, 11, 0.15); color: #fde047; border: 1px solid rgba(245, 158, 11, 0.3);
}

/* Card metrics styling */
.metrics-grid {
  display: flex;
  align-items: center;
  gap: 2rem;
}

.metric-circle-wrapper {
  position: relative;
  width: 110px;
  height: 110px;
}

.metric-label {
  position: absolute;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  font-size: 1rem;
  font-weight: 700;
}

.metric-details {
  flex-grow: 1;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.detail-item {
  display: flex;
  justify-content: space-between;
  font-size: 0.95rem;
}

.detail-item .label { color: var(--text-muted); }
.detail-item .value { font-weight: 600; }

/* Nudges Summary */
.nudges-summary {
  margin-top: 1.5rem;
  padding-top: 1.25rem;
  border-top: 1px solid var(--glass-border);
}

.nudges-summary h3 {
  font-size: 0.95rem;
  color: var(--text-muted);
  margin-bottom: 1rem;
}

.nudges-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1rem;
  text-align: center;
}

.nudge-item {
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid var(--glass-border);
  padding: 0.8rem;
  border-radius: 12px;
}

.nudge-count {
  display: block;
  font-size: 1.6rem;
  font-weight: 700;
  color: var(--primary-hover);
  margin-bottom: 0.25rem;
}

.nudge-label {
  font-size: 0.75rem;
  color: var(--text-muted);
  font-weight: 500;
}

/* Control Panel Section */
.controls-grid {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.control-group h3 {
  font-size: 1rem;
  color: var(--text-muted);
  margin-bottom: 0.75rem;
}

.buttons-row {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
}

/* Freshness details styling */
.freshness-details {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 1.5rem;
}

.freshness-item {
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid var(--glass-border);
  padding: 1.2rem;
  border-radius: 16px;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.freshness-item .label {
  font-size: 0.85rem;
  color: var(--text-muted);
  font-weight: 600;
  text-transform: uppercase;
}

.freshness-item .value {
  font-size: 1.1rem;
  font-weight: 700;
  color: #a5b4fc;
}

/* Loader Overlay */
.loader-overlay {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(11, 15, 25, 0.85);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 1.5rem;
  z-index: 1000;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
}

.loader-overlay.active {
  opacity: 1;
  pointer-events: auto;
}

.loader-spinner {
  width: 50px;
  height: 50px;
  border: 4px solid var(--glass-border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.card-header-flex {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1.5rem;
}

.card-header-flex h2 {
  margin-bottom: 0 !important;
}

.clean-select {
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--glass-border);
  color: var(--text-main);
  border-radius: 8px;
  padding: 0.4rem 0.8rem;
  font-size: 0.9rem;
  font-weight: 500;
  outline: none;
  cursor: pointer;
  transition: border-color 0.2s ease;
}

.clean-select:focus {
  border-color: var(--primary);
}

.clean-select option {
  background: #0b0f19;
  color: var(--text-main);
}
