:root {
  --bg-primary: #0b0f19;
  --bg-secondary: #111827;
  --bg-card: rgba(17, 24, 39, 0.75);
  --bg-card-border: rgba(255, 255, 255, 0.08);
  
  --text-main: #f3f4f6;
  --text-muted: #9ca3af;
  --text-dim: #6b7280;

  --wa-green: #25D366;
  --wa-green-glow: rgba(37, 211, 102, 0.25);
  --primary-accent: #6366f1;
  --primary-accent-hover: #4f46e5;
  --primary-glow: rgba(99, 102, 241, 0.25);

  --color-danger: #ef4444;
  --color-warning: #f59e0b;
  --color-success: #10b981;

  --sidebar-width: 260px;
  --radius-lg: 16px;
  --radius-md: 12px;
  --radius-sm: 8px;

  --font-family: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, sans-serif;
  --transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

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

body {
  font-family: var(--font-family);
  background-color: var(--bg-primary);
  color: var(--text-main);
  min-height: 100vh;
  overflow-x: hidden;
  line-height: 1.5;
}

/* Layout */
.app-layout {
  display: flex;
  min-height: 100vh;
}

/* Sidebar */
.sidebar {
  width: var(--sidebar-width);
  background-color: var(--bg-secondary);
  border-right: 1px solid var(--bg-card-border);
  display: flex;
  flex-direction: column;
  position: fixed;
  height: 100vh;
  z-index: 100;
  padding: 1.5rem 1rem;
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  padding: 0.5rem 0.5rem 1.5rem 0.5rem;
  border-bottom: 1px solid var(--bg-card-border);
  margin-bottom: 1.5rem;
}

.brand-icon {
  width: 44px;
  height: 44px;
  background: linear-gradient(135deg, #25D366 0%, #128C7E 100%);
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
  color: white;
  box-shadow: 0 4px 14px var(--wa-green-glow);
}

.brand-info h2 {
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--text-main);
}

.brand-badge {
  font-size: 0.65rem;
  font-weight: 700;
  background: rgba(99, 102, 241, 0.2);
  color: #818cf8;
  padding: 0.15rem 0.5rem;
  border-radius: 20px;
  letter-spacing: 0.5px;
}

.nav-menu {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  flex: 1;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  padding: 0.85rem 1rem;
  border: none;
  background: transparent;
  color: var(--text-muted);
  font-family: inherit;
  font-size: 0.95rem;
  font-weight: 500;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: var(--transition);
  text-align: left;
}

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

.nav-item:hover {
  background: rgba(255, 255, 255, 0.04);
  color: var(--text-main);
}

.nav-item.active {
  background: linear-gradient(135deg, rgba(99, 102, 241, 0.2) 0%, rgba(99, 102, 241, 0.08) 100%);
  color: #a5b4fc;
  border: 1px solid rgba(99, 102, 241, 0.3);
  box-shadow: 0 4px 12px rgba(99, 102, 241, 0.1);
}

.sidebar-footer {
  padding-top: 1rem;
  border-top: 1px solid var(--bg-card-border);
}

.bot-status-card {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem;
  background: rgba(0, 0, 0, 0.3);
  border-radius: var(--radius-md);
  border: 1px solid var(--bg-card-border);
}

.status-indicator-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background-color: var(--color-danger);
  box-shadow: 0 0 10px var(--color-danger);
  transition: var(--transition);
}

.status-indicator-dot.connected {
  background-color: var(--wa-green);
  box-shadow: 0 0 10px var(--wa-green);
}

.status-indicator-dot.connecting,
.status-indicator-dot.qr_ready {
  background-color: var(--color-warning);
  box-shadow: 0 0 10px var(--color-warning);
}

.status-text-wrapper {
  display: flex;
  flex-direction: column;
}

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

.status-text-wrapper strong {
  font-size: 0.85rem;
  color: var(--text-main);
}

/* Main Content */
.main-content {
  margin-left: var(--sidebar-width);
  flex: 1;
  padding: 2rem 2.5rem;
  max-width: calc(100vw - var(--sidebar-width));
}

/* Topbar */
.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 2rem;
  padding-bottom: 1.25rem;
  border-bottom: 1px solid var(--bg-card-border);
}

.page-title h1 {
  font-size: 1.6rem;
  font-weight: 800;
  color: var(--text-main);
  margin-bottom: 0.25rem;
}

.page-title p {
  color: var(--text-muted);
  font-size: 0.9rem;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 1.25rem;
}

.toggle-switch-wrapper {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  background: var(--bg-secondary);
  padding: 0.5rem 1rem;
  border-radius: 30px;
  border: 1px solid var(--bg-card-border);
}

.toggle-label {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-muted);
}

/* Custom Toggle Switch */
.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: #374151;
  transition: .3s;
}

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

input:checked + .slider {
  background-color: var(--wa-green);
}

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

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

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

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.65rem 1.25rem;
  font-family: inherit;
  font-size: 0.9rem;
  font-weight: 600;
  border-radius: var(--radius-md);
  border: none;
  cursor: pointer;
  transition: var(--transition);
}

.btn-primary {
  background: linear-gradient(135deg, var(--primary-accent) 0%, var(--primary-accent-hover) 100%);
  color: white;
  box-shadow: 0 4px 14px var(--primary-glow);
}

.btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px var(--primary-glow);
}

.btn-outline {
  background: transparent;
  color: var(--text-main);
  border: 1px solid var(--bg-card-border);
}

.btn-outline:hover {
  background: rgba(255, 255, 255, 0.05);
}

/* Tabs Content */
.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); }
}

/* Cards */
.card {
  background: var(--bg-card);
  backdrop-filter: blur(16px);
  border: 1px solid var(--bg-card-border);
  border-radius: var(--radius-lg);
  margin-bottom: 1.5rem;
  overflow: hidden;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
}

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

.card-header.space-between {
  justify-content: space-between;
}

.card-header h3 {
  font-size: 1.1rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

.card-header p.subtitle {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-top: 0.15rem;
}

.card-body {
  padding: 1.5rem;
}

.card-body.padding-0 {
  padding: 0;
}

/* Badges */
.badge {
  padding: 0.25rem 0.75rem;
  font-size: 0.75rem;
  font-weight: 700;
  border-radius: 20px;
  letter-spacing: 0.5px;
  background: rgba(239, 68, 68, 0.2);
  color: var(--color-danger);
}

.badge.connected {
  background: rgba(37, 211, 102, 0.2);
  color: var(--wa-green);
}

.badge.connecting, .badge.qr_ready {
  background: rgba(245, 158, 11, 0.2);
  color: var(--color-warning);
}

/* Dashboard Hero */
.wa-session-details {
  display: flex;
  gap: 2.5rem;
  align-items: center;
}

.qr-box-wrapper {
  width: 240px;
  height: 240px;
  background: white;
  border-radius: var(--radius-md);
  padding: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
}

.qr-box-wrapper img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.qr-placeholder {
  text-align: center;
  color: #4b5563;
}

.qr-placeholder i {
  font-size: 3rem;
  margin-bottom: 0.5rem;
  color: #9ca3af;
}

.qr-placeholder p {
  font-size: 0.85rem;
}

.wa-info-box {
  flex: 1;
}

.info-row {
  display: flex;
  justify-content: space-between;
  padding: 0.75rem 0;
  border-bottom: 1px solid var(--bg-card-border);

}

.info-label {
  color: var(--text-muted);
  font-size: 0.9rem;
}

.info-val {
  font-weight: 600;
  font-size: 0.95rem;
}

.info-val.highlight {
  color: #818cf8;
}

.qr-instructions {
  margin-top: 1.25rem;
  background: rgba(255, 255, 255, 0.03);
  padding: 1rem;
  border-radius: var(--radius-md);
  border: 1px solid var(--bg-card-border);
}

.qr-instructions h4 {
  font-size: 0.9rem;
  color: var(--wa-green);
  margin-bottom: 0.5rem;
}

.qr-instructions ol {
  padding-left: 1.2rem;
  font-size: 0.85rem;
  color: var(--text-muted);
}

.qr-instructions li {
  margin-bottom: 0.25rem;
}

/* Stats Row */
.stats-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1.5rem;
}

.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--bg-card-border);
  padding: 1.25rem 1.5rem;
  border-radius: var(--radius-lg);
  display: flex;
  align-items: center;
  gap: 1.25rem;
}

.stat-icon {
  width: 52px;
  height: 52px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.4rem;
}

.bg-blue { background: rgba(99, 102, 241, 0.2); color: #818cf8; }
.bg-green { background: rgba(37, 211, 102, 0.2); color: var(--wa-green); }
.bg-purple { background: rgba(168, 85, 247, 0.2); color: #c084fc; }

.stat-num {
  display: block;
  font-size: 1.5rem;
  font-weight: 800;
}

.stat-title {
  font-size: 0.85rem;
  color: var(--text-muted);
}

/* Tables */
.table-filter-bar {
  padding: 1rem 1.5rem;
  border-bottom: 1px solid var(--bg-card-border);
}

.search-box {
  position: relative;
  max-width: 400px;
}

.search-box i {
  position: absolute;
  left: 1rem;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-dim);
}

.search-box input {
  width: 100%;
  padding: 0.65rem 1rem 0.65rem 2.5rem;
  background: rgba(0, 0, 0, 0.2);
  border: 1px solid var(--bg-card-border);
  border-radius: var(--radius-md);
  color: var(--text-main);
  font-family: inherit;
  font-size: 0.9rem;
}

.search-box input:focus {
  outline: none;
  border-color: var(--primary-accent);
}

.table-responsive {
  width: 100%;
  overflow-x: auto;
}

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

.custom-table th {
  padding: 1rem 1.5rem;
  font-size: 0.8rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
  background: rgba(0, 0, 0, 0.3);
  border-bottom: 1px solid var(--bg-card-border);
}

.custom-table td {
  padding: 1rem 1.5rem;
  font-size: 0.9rem;
  border-bottom: 1px solid var(--bg-card-border);
  vertical-align: top;
}

.custom-table tbody tr:hover {
  background: rgba(255, 255, 255, 0.02);
}

.category-tag {
  display: inline-block;
  padding: 0.2rem 0.6rem;
  font-size: 0.75rem;
  font-weight: 600;
  border-radius: 4px;
  background: rgba(99, 102, 241, 0.15);
  color: #a5b4fc;
}

.text-right { text-align: right; }
.text-center { text-align: center; }
.py-4 { padding-top: 2rem; padding-bottom: 2rem; }

.btn-icon {
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 1rem;
  padding: 0.4rem 0.6rem;
  cursor: pointer;
  border-radius: var(--radius-sm);
  transition: var(--transition);
}

.btn-icon:hover {
  color: var(--text-main);
  background: rgba(255, 255, 255, 0.1);
}

.btn-icon.danger:hover {
  color: var(--color-danger);
  background: rgba(239, 68, 68, 0.15);
}

/* Chat Logs Stream */
.chat-logs-stream {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  padding: 1.5rem;
  max-height: 600px;
  overflow-y: auto;
}

.chat-card-item {
  background: rgba(0, 0, 0, 0.25);
  border: 1px solid var(--bg-card-border);
  border-radius: var(--radius-md);
  padding: 1.25rem;
  transition: var(--transition);
}

.chat-card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.75rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.chat-user-info {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  font-weight: 700;
  color: var(--text-main);
}

.chat-time {
  font-size: 0.75rem;
  color: var(--text-dim);
}

.chat-body-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}

.chat-bubble {
  padding: 0.85rem 1rem;
  border-radius: var(--radius-md);
  font-size: 0.88rem;
}

.chat-user-msg {
  background: rgba(255, 255, 255, 0.05);
  border-left: 3px solid #60a5fa;
}

.chat-bot-reply {
  background: rgba(37, 211, 102, 0.1);
  border-left: 3px solid var(--wa-green);
}

.msg-tag {
  display: block;
  font-size: 0.7rem;
  font-weight: 700;
  margin-bottom: 0.25rem;
  text-transform: uppercase;
}

.msg-tag.user { color: #60a5fa; }
.msg-tag.bot { color: var(--wa-green); }

/* Form Settings */
.settings-form {
  max-width: 700px;
}

.form-group {
  margin-bottom: 1.5rem;
}

.form-group label {
  display: block;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text-main);
  margin-bottom: 0.5rem;
}

.form-group input, .form-group select, .form-group textarea {
  width: 100%;
  padding: 0.75rem 1rem;
  background: rgba(0, 0, 0, 0.3);
  border: 1px solid var(--bg-card-border);
  border-radius: var(--radius-md);
  color: var(--text-main);
  font-family: inherit;
  font-size: 0.95rem;
  transition: var(--transition);
}

.form-group input:focus, .form-group select:focus, .form-group textarea:focus {
  outline: none;
  border-color: var(--primary-accent);
  box-shadow: 0 0 0 3px var(--primary-glow);
}

.form-text {
  display: block;
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-top: 0.35rem;
}

.form-text a {
  color: #818cf8;
  text-decoration: none;
}

.input-password-wrapper {
  position: relative;
}

.btn-toggle-eye {
  position: absolute;
  right: 0.75rem;
  top: 50%;
  transform: translateY(-50%);
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
}

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

.col-6 {
  flex: 1;
}

/* Modals */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  opacity: 0;
  visibility: hidden;
  transition: var(--transition);
}

.modal-overlay.active {
  opacity: 1;
  visibility: visible;
}

.modal {
  background: var(--bg-secondary);
  border: 1px solid var(--bg-card-border);
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 540px;
  overflow: hidden;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.5);
  transform: scale(0.95);
  transition: var(--transition);
}

.modal-overlay.active .modal {
  transform: scale(1);
}

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

.modal-header h3 {
  font-size: 1.15rem;
  font-weight: 700;
}

.btn-close {
  background: transparent;
  border: none;
  font-size: 1.5rem;
  color: var(--text-muted);
  cursor: pointer;
}

.modal-body {
  padding: 1.5rem;
}

.modal-footer {
  padding: 1rem 1.5rem;
  border-top: 1px solid var(--bg-card-border);
  display: flex;
  justify-content: flex-end;
  gap: 0.75rem;
}

/* Toast Notifications */
.toast-container {
  position: fixed;
  bottom: 2rem;
  right: 2rem;
  z-index: 2000;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.toast {
  background: var(--bg-secondary);
  border: 1px solid var(--bg-card-border);
  color: var(--text-main);
  padding: 0.85rem 1.25rem;
  border-radius: var(--radius-md);
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.4);
  display: flex;
  align-items: center;
  gap: 0.75rem;
  font-size: 0.9rem;
  animation: slideInRight 0.3s forwards;
}

.toast.success { border-left: 4px solid var(--color-success); }
.toast.error { border-left: 4px solid var(--color-danger); }

@keyframes slideInRight {
  from { transform: translateX(100%); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}

.color-wa { color: var(--wa-green); }
.color-purple { color: #c084fc; }
.color-green { color: var(--color-success); }
.color-blue { color: #818cf8; }

/* Login Page Glassmorphism Styling */
.login-screen {
  min-height: 100vh;
  width: 100vw;
  display: flex;
  align-items: center;
  justify-content: center;
  background: radial-gradient(circle at 50% 20%, #1e1b4b 0%, #0b0f19 70%);
  padding: 1.5rem;
  position: relative;
  overflow: hidden;
}

.login-screen::before {
  content: '';
  position: absolute;
  width: 350px;
  height: 350px;
  background: radial-gradient(circle, rgba(37, 211, 102, 0.15) 0%, rgba(0, 0, 0, 0) 70%);
  top: 15%;
  left: 20%;
  border-radius: 50%;
  pointer-events: none;
  filter: blur(40px);
}

.login-screen::after {
  content: '';
  position: absolute;
  width: 400px;
  height: 400px;
  background: radial-gradient(circle, rgba(99, 102, 241, 0.2) 0%, rgba(0, 0, 0, 0) 70%);
  bottom: 10%;
  right: 20%;
  border-radius: 50%;
  pointer-events: none;
  filter: blur(50px);
}

.login-card {
  width: 100%;
  max-width: 440px;
  background: rgba(17, 24, 39, 0.8);
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 24px;
  padding: 2.5rem 2.25rem;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.5), 0 0 40px rgba(99, 102, 241, 0.1);
  position: relative;
  z-index: 10;
  animation: loginCardFade 0.5s ease-out;
}

@keyframes loginCardFade {
  from {
    opacity: 0;
    transform: translateY(20px) scale(0.97);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.login-header {
  text-align: center;
  margin-bottom: 2rem;
}

.login-brand-icon {
  width: 64px;
  height: 64px;
  background: linear-gradient(135deg, #25D366 0%, #128C7E 100%);
  border-radius: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2.2rem;
  color: white;
  margin: 0 auto 1.25rem auto;
  box-shadow: 0 8px 25px rgba(37, 211, 102, 0.35);
}

.login-header h2 {
  font-size: 1.65rem;
  font-weight: 800;
  color: var(--text-main);
  letter-spacing: -0.5px;
  margin-bottom: 0.35rem;
}

.login-header p {
  color: var(--text-muted);
  font-size: 0.9rem;
}

.login-error-alert {
  background: rgba(239, 68, 68, 0.15);
  border: 1px solid rgba(239, 68, 68, 0.3);
  color: #fca5a5;
  padding: 0.75rem 1rem;
  border-radius: var(--radius-md);
  font-size: 0.88rem;
  margin-bottom: 1.25rem;
  display: flex;
  align-items: center;
  gap: 0.6rem;
  animation: shakeAlert 0.3s ease-in-out;
}

@keyframes shakeAlert {
  0%, 100% { transform: translateX(0); }
  20%, 60% { transform: translateX(-5px); }
  40%, 80% { transform: translateX(5px); }
}

.btn-block {
  width: 100%;
  justify-content: center;
}

.btn-login {
  padding: 0.85rem 1.5rem;
  font-size: 1rem;
  font-weight: 700;
  margin-top: 0.5rem;
  border-radius: var(--radius-md);
}

.login-footer {
  margin-top: 2rem;
  padding-top: 1.25rem;
  border-top: 1px solid var(--bg-card-border);
  text-align: center;
}

.login-footer p {
  font-size: 0.8rem;
  color: var(--text-dim);
}

/* Logout Button Styles */
.btn-logout {
  color: var(--color-danger);
  border-color: rgba(239, 68, 68, 0.3);
}

.btn-logout:hover {
  background: rgba(239, 68, 68, 0.15);
  color: #fca5a5;
}

.btn-logout-sidebar {
  width: 100%;
  margin-top: 0.75rem;
  padding: 0.6rem 1rem;
  background: rgba(239, 68, 68, 0.1);
  color: #fca5a5;
  border: 1px solid rgba(239, 68, 68, 0.2);
  border-radius: var(--radius-md);
  font-family: inherit;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  transition: var(--transition);
}

.btn-logout-sidebar:hover {
  background: rgba(239, 68, 68, 0.25);
  color: white;
}

