:root {
  /* Primary & Brand Colors */
  --primary-color: #4f46e5; /* Indigo 600 */
  --primary-hover: #4338ca; /* Indigo 700 */
  --secondary-color: #ecf4ff;
  --accent-color: #0ea5e9; /* Sky 500 */

  /* Text Colors */
  --text-main: #1f2937; /* Gray 800 */
  --text-secondary: #6b7280; /* Gray 500 */
  --text-light: #9ca3af; /* Gray 400 */

  /* Status Colors */
  --status-online: #10b981; /* Emerald 500 */
  --status-offline: #ef4444; /* Red 500 */
  --status-paused: #f59e0b; /* Amber 500 */

  /* Layout & Spacing */
  --sidebar-width: 260px;
  --header-height: 70px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-full: 999px;

  /* Effects */
  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
  --shadow-md:
    0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
  --shadow-lg:
    0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
  --glass-bg: rgba(255, 255, 255, 0.95);
  --glass-border: 1px solid rgba(255, 255, 255, 0.2);
  --transition-base: all 0.2s ease-in-out;
}

body {
  background-color: #f3f4f6; /* Gray 100 */
  font-family:
    "Inter",
    "Segoe UI",
    system-ui,
    -apple-system,
    sans-serif;
  color: var(--text-main);
  overflow-x: hidden;
  line-height: 1.5;
}

/* ================== SIDEBAR ================== */
.sidebar {
  width: var(--sidebar-width);
  height: 100vh;
  position: fixed;
  top: 0;
  left: 0;
  z-index: 1000;
  background: #ffffff;
  border-right: 1px solid #e5e7eb;
  transition: var(--transition-base);
  display: flex;
  flex-direction: column;
}

.sidebar-brand {
  height: var(--header-height);
  display: flex;
  align-items: center;
  padding: 0 1.5rem;
  font-weight: 800;
  font-size: 1.5rem;
  background: white;
  color: var(--primary-color);
  letter-spacing: -0.025em;
}

.sidebar-brand i {
  font-size: 1.25em;
  background: linear-gradient(
    135deg,
    var(--primary-color),
    var(--accent-color)
  );
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.sidebar-menu {
  padding: 1.5rem 1rem;
  flex: 1;
  overflow-y: auto;
}

.nav-link {
  display: flex;
  align-items: center;
  color: var(--text-secondary);
  padding: 0.75rem 1rem;
  border-radius: var(--radius-md);
  transition: var(--transition-base);
  font-weight: 500;
  margin-bottom: 0.25rem;
  position: relative;
}

.nav-link i {
  width: 24px;
  margin-right: 12px;
  font-size: 1.1rem;
  transition: var(--transition-base);
  opacity: 0.8;
}

.nav-link:hover {
  background-color: var(--secondary-color);
  color: var(--primary-color);
}

.nav-link:hover i {
  opacity: 1;
  transform: translateX(2px);
}

.nav-link.active {
  background: linear-gradient(
    135deg,
    var(--primary-color),
    var(--primary-hover)
  );
  color: white;
  box-shadow: 0 4px 12px rgba(79, 70, 229, 0.3);
}

.nav-link.active i {
  color: white;
  opacity: 1;
}

.nav-divider {
  font-size: 0.7rem;
  text-transform: uppercase;
  color: var(--text-light);
  padding: 1.5rem 1rem 0.5rem;
  font-weight: 700;
  letter-spacing: 0.05em;
}

/* ================== HEADER ================== */
.top-header {
  height: var(--header-height);
  background: rgba(255, 255, 255, 0.8);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  position: fixed;
  top: 0;
  right: 0;
  left: var(--sidebar-width);
  z-index: 900;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 2rem;
  border-bottom: 1px solid rgba(229, 231, 235, 0.5);
  transition: left var(--transition-base);
}

#sidebarToggle {
  background: white;
  border: 1px solid #e5e7eb;
  font-size: 1rem;
  color: var(--text-secondary);
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: var(--transition-base);
}

#sidebarToggle:hover {
  border-color: var(--primary-color);
  color: var(--primary-color);
  box-shadow: var(--shadow-sm);
}

/* ================== MAIN CONTENT ================== */
.main-content {
  margin-top: var(--header-height);
  margin-left: var(--sidebar-width);
  padding: 2rem;
  transition: margin-left var(--transition-base);
  min-height: calc(100vh - var(--header-height));
}

/* ================== CARDS & PREMIUM UI ================== */
.card {
  border: 1px solid rgba(229, 231, 235, 0.5);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  background: white;
  transition: var(--transition-base);
  overflow: hidden;
}

.card:hover {
  box-shadow: var(--shadow-lg);
  border-color: rgba(79, 70, 229, 0.2);
}

.card-header {
  background: white;
  border-bottom: 1px solid #f3f4f6;
  padding: 1.25rem 1.5rem;
  font-weight: 600;
  color: var(--text-main);
}

/* Bot Card Specifics */
.bot-card {
  position: relative;
  border: none;
  background: white;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  overflow: visible; /* Allow pulse to spill out if needed, but we use internal */
}

.bot-card::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 4px;
  background: linear-gradient(90deg, var(--primary-color), var(--accent-color));
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  opacity: 0;
  transition: opacity 0.3s;
}

.bot-card:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow-lg);
}

.bot-card:hover::before {
  opacity: 1;
}

.bot-card.paused {
  background: #f9fafb;
  filter: grayscale(0.8);
}
.bot-card.paused:hover {
  filter: grayscale(0);
}

.avatar-wrapper {
  position: relative;
  width: 90px;
  height: 90px;
  margin: 0 auto 1rem;
  padding: 4px;
  background: white;
  border-radius: 50%;
  box-shadow: var(--shadow-md);
}

.avatar-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 50%;
}

/* Status Indicators */
.status-indicator {
  position: absolute;
  bottom: 5px;
  right: 5px;
  width: 20px;
  height: 20px;
  border: 3px solid white;
  border-radius: 50%;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.status-online {
  background-color: var(--status-online);
}
.status-offline {
  background-color: var(--status-offline);
}
.status-paused {
  background-color: var(--status-paused);
}

.pulse-ring {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 100%;
  height: 100%;
  border-radius: 50%;
  border: 2px solid var(--status-online);
  animation: pulse 2s infinite;
  opacity: 0;
}

@keyframes pulse {
  0% {
    transform: translate(-50%, -50%) scale(1);
    opacity: 0.8;
  }
  100% {
    transform: translate(-50%, -50%) scale(2.5);
    opacity: 0;
  }
}

/* Stats */
.stat-box {
  background: #f9fafb;
  border-radius: var(--radius-md);
  padding: 0.75rem;
  text-align: center;
  border: 1px solid #f3f4f6;
  transition: var(--transition-base);
}

.stat-box:hover {
  border-color: #e5e7eb;
  background: white;
  box-shadow: var(--shadow-sm);
}

.stat-label {
  font-size: 0.75rem;
  color: var(--text-secondary);
  font-weight: 500;
  margin-bottom: 2px;
}

.stat-value {
  font-size: 1rem;
  font-weight: 700;
  color: var(--text-main);
}

/* Buttons */
.btn {
  border-radius: var(--radius-full);
  font-weight: 500;
  padding: 0.5rem 1.25rem;
  transition: var(--transition-base);
}

.btn-primary {
  background-color: var(--primary-color);
  border-color: var(--primary-color);
}

.btn-primary:hover {
  background-color: var(--primary-hover);
  border-color: var(--primary-hover);
  box-shadow: 0 4px 12px rgba(79, 70, 229, 0.3);
}

.btn-icon-only {
  width: 36px;
  height: 36px;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
}

/* Modal Polish */
.modal-content {
  border: none;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  overflow: hidden;
}

.modal-header {
  border-bottom: 1px solid #f3f4f6;
  background: #fafafa;
}

.nav-tabs-pill .nav-link {
  border: none;
  background: transparent;
  color: var(--text-secondary);
  border-radius: var(--radius-full);
  padding: 0.5rem 1.25rem;
  font-weight: 600;
  box-shadow: none;
  transform: none;
}

.nav-tabs-pill .nav-link:hover {
  background: #f3f4f6;
  color: var(--primary-color);
  transform: none;
  box-shadow: none;
}

.nav-tabs-pill .nav-link.active {
  background: var(--secondary-color);
  color: var(--primary-color);
  box-shadow: none;
  transform: none;
}

/* Input Fields */
.form-control,
.form-select {
  border-radius: var(--radius-md);
  border: 1px solid #d1d5db;
  padding: 0.625rem 1rem;
  font-size: 0.95rem;
}

.form-control:focus {
  border-color: var(--primary-color);
  box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.1);
}

.input-group-text {
  border-radius: var(--radius-md) 0 0 var(--radius-md);
  background: #f9fafb;
  border-color: #d1d5db;
}

/* ================== MOBILE RESPONSIVE ================== */
@media (max-width: 992px) {
  .sidebar {
    left: calc(var(--sidebar-width) * -1);
  }
  .top-header {
    left: 0;
  }
  .main-content {
    margin-left: 0;
  }

  .sidebar.show {
    left: 0;
    box-shadow: 10px 0 30px rgba(0, 0, 0, 0.15);
  }

  .sidebar-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.4);
    backdrop-filter: blur(2px);
    z-index: 950;
    display: none;
    opacity: 0;
    transition: opacity 0.3s;
  }

  .sidebar-overlay.show {
    display: block;
    opacity: 1;
  }
}
