:root {
  --sidebar-width: 250px;
  --color-connected: #198754;
  --color-disconnected: #dc3545;
  --color-warning: #ffc107;
  --bs-purple: #6f42c1;
}

body {
  font-family: 'Segoe UI', Tahoma, 'Noto Sans Arabic', sans-serif;
  background-color: #f8f9fa;
  min-height: 100vh;
}

/* --- Login --- */
#login-screen {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  background: linear-gradient(135deg, #1a1a2e 0%, #16213e 50%, #0f3460 100%);
}

#login-screen .card {
  border: none;
  border-radius: 12px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.3);
}

#login-screen .login-brand {
  font-size: 2rem;
  font-weight: 700;
  color: #198754;
}

/* --- Sidebar --- */
#sidebar {
  position: fixed;
  top: 0;
  right: 0;
  width: var(--sidebar-width);
  height: 100vh;
  overflow-y: auto;
  z-index: 1030;
  display: flex;
  flex-direction: column;
}

#sidebar .nav-link {
  color: rgba(255,255,255,0.7);
  padding: 0.75rem 1.25rem;
  border-radius: 0;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

#sidebar .nav-link:hover {
  color: #fff;
  background: rgba(255,255,255,0.1);
}

#sidebar .nav-link.active {
  color: #fff;
  background: rgba(255,255,255,0.15);
  border-right: 3px solid #198754;
}

#sidebar .nav-link i {
  font-size: 1.1rem;
  width: 24px;
  text-align: center;
}

.sidebar-footer {
  margin-top: auto;
  border-top: 1px solid rgba(255,255,255,0.1);
}

/* --- Content --- */
#content {
  margin-right: var(--sidebar-width);
  min-height: 100vh;
  padding: 1.5rem;
}

/* --- Top navbar (mobile only) --- */
#top-nav {
  z-index: 1040;
}

/* --- Status cards --- */
.status-card {
  border: none;
  border-radius: 10px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.06);
  transition: transform 0.2s;
}

.status-card:hover {
  transform: translateY(-2px);
}

.stat-value {
  font-size: 2rem;
  font-weight: 700;
  line-height: 1.2;
}

.stat-label {
  color: #6c757d;
  font-size: 0.85rem;
}

.stat-icon {
  font-size: 2.5rem;
  opacity: 0.15;
  position: absolute;
  left: 1rem;
  top: 50%;
  transform: translateY(-50%);
}

/* --- Chart container --- */
#msg-chart {
  max-height: 250px !important;
}

/* --- Tables --- */
.table th {
  font-weight: 600;
  font-size: 0.85rem;
  color: #495057;
  border-bottom-width: 2px;
}

.table td {
  vertical-align: middle;
  font-size: 0.9rem;
}

/* --- Message direction --- */
.msg-in { border-right: 3px solid #6c757d; }
.msg-out { border-right: 3px solid var(--color-connected); }

/* --- Badge overrides --- */
.badge.bg-purple {
  background-color: var(--bs-purple) !important;
}

/* --- Page header --- */
.page-header {
  margin-bottom: 1.5rem;
  padding-bottom: 0.75rem;
  border-bottom: 2px solid #e9ecef;
}

.page-header h4 {
  font-weight: 700;
  margin: 0;
}

/* --- Responsive --- */
@media (max-width: 768px) {
  #sidebar {
    transform: translateX(100%);
    transition: transform 0.3s ease;
  }

  #sidebar.sidebar-open {
    transform: translateX(0);
  }

  #content {
    margin-right: 0;
    padding-top: 60px;
  }

  #sidebar-overlay.active {
    display: block !important;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    z-index: 1020;
  }

  .stat-value {
    font-size: 1.5rem;
  }
}

/* --- Loading spinner --- */
.page-loading {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 300px;
}

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

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

/* --- Conversation thread --- */
.msg-bubble {
  max-width: 75%;
  padding: 0.5rem 0.75rem;
  border-radius: 12px;
  margin-bottom: 0.5rem;
  font-size: 0.9rem;
  word-break: break-word;
}

.msg-bubble.in {
  background: #e9ecef;
  margin-left: auto;
  border-top-left-radius: 4px;
}

.msg-bubble.out {
  background: #d4edda;
  margin-right: auto;
  border-top-right-radius: 4px;
}

.msg-time {
  font-size: 0.7rem;
  color: #6c757d;
}

/* --- Settings controls --- */
.safety-control {
  background: #fff;
  border-radius: 10px;
  padding: 1.25rem;
  box-shadow: 0 2px 8px rgba(0,0,0,0.06);
  margin-bottom: 1rem;
}

.safety-control h6 {
  font-weight: 600;
  margin-bottom: 0.75rem;
}
