/* 
  BaLASchaT (BLAST) — Premium Design System CSS 
  WhatsApp Green Inspired Theme with Dark Mode & Glassmorphism 
*/

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&family=Outfit:wght@400;500;600;700;800&display=swap');

:root {
  /* HSL Palette */
  --wa-green-primary: 142, 70%, 27%; /* #075e54 */
  --wa-green-accent: 142, 60%, 45%;  /* #25d366 */
  --wa-teal: 172, 66%, 33%;
  
  /* Color Tokens - Light Mode */
  --bg-primary: hsl(135, 15%, 97%);
  --bg-sidebar: hsl(0, 0%, 100%);
  --bg-card: hsl(0, 0%, 100%);
  --bg-active: hsl(142, 20%, 94%);
  --bg-hover: hsl(142, 10%, 96%);
  
  --border-color: hsl(140, 10%, 90%);
  --text-primary: hsl(210, 24%, 16%);
  --text-secondary: hsl(210, 10%, 45%);
  --text-on-primary: hsl(0, 0%, 100%);
  
  --shadow-sm: 0 2px 4px rgba(0, 0, 0, 0.02);
  --shadow-md: 0 8px 24px rgba(0, 0, 0, 0.05);
  --shadow-lg: 0 16px 36px rgba(7, 94, 84, 0.08);

  --chat-bg: hsl(135, 10%, 94%);
  --bubble-incoming: hsl(0, 0%, 100%);
  --bubble-outgoing: hsl(135, 50%, 90%);
}

[data-theme="dark"] {
  /* Color Tokens - Dark Mode */
  --bg-primary: hsl(210, 16%, 9%); /* #0b141a */
  --bg-sidebar: hsl(210, 16%, 12%); /* #111b21 */
  --bg-card: hsl(210, 16%, 15%); /* #202c33 */
  --bg-active: hsl(142, 35%, 15%);
  --bg-hover: hsl(210, 16%, 18%);
  
  --border-color: hsl(210, 12%, 20%);
  --text-primary: hsl(210, 20%, 95%);
  --text-secondary: hsl(210, 10%, 70%);
  
  --shadow-sm: 0 2px 4px rgba(0, 0, 0, 0.15);
  --shadow-md: 0 8px 24px rgba(0, 0, 0, 0.25);
  --shadow-lg: 0 16px 36px rgba(0, 0, 0, 0.35);

  --chat-bg: hsl(210, 16%, 10%);
  --bubble-incoming: hsl(210, 16%, 15%);
  --bubble-outgoing: hsl(142, 30%, 20%);
}

/* Reset & Base Styles */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  transition: background-color 0.3s ease, border-color 0.3s ease;
}

body {
  font-family: 'Inter', sans-serif;
  background-color: var(--bg-primary);
  color: var(--text-primary);
  height: 100vh;
  overflow: hidden;
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4, h5, h6 {
  font-family: 'Outfit', sans-serif;
  font-weight: 600;
  color: var(--text-primary);
}

/* App Wrapper & Layout */
#app {
  display: flex;
  height: 100vh;
  width: 100vw;
  overflow: hidden;
  position: relative;
}

/* Splash Screen */
.splash-screen {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: hsl(210, 16%, 9%);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 9999;
}

.splash-logo {
  font-family: 'Outfit', sans-serif;
  font-size: 3rem;
  font-weight: 800;
  color: hsl(var(--wa-green-accent));
  margin-bottom: 20px;
  display: flex;
  align-items: center;
  gap: 12px;
  animation: pulse 2s infinite ease-in-out;
}

.splash-loader {
  width: 150px;
  height: 4px;
  background-color: rgba(255, 255, 255, 0.1);
  border-radius: 2px;
  overflow: hidden;
  position: relative;
}

.splash-loader-bar {
  width: 50%;
  height: 100%;
  background-color: hsl(var(--wa-green-accent));
  position: absolute;
  left: 0;
  top: 0;
  animation: loading 1.5s infinite linear;
}

/* Sidebar Navigation */
.sidebar {
  width: 260px;
  background-color: var(--bg-sidebar);
  border-right: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  height: 100%;
  flex-shrink: 0;
  z-index: 100;
}

.sidebar-brand {
  padding: 24px;
  display: flex;
  align-items: center;
  gap: 12px;
  border-bottom: 1px solid var(--border-color);
}

.brand-icon {
  background-color: hsl(var(--wa-green-primary));
  color: #fff;
  width: 36px;
  height: 36px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  box-shadow: 0 4px 10px rgba(7, 94, 84, 0.2);
}

.brand-name {
  font-size: 20px;
  font-weight: 800;
  font-family: 'Outfit', sans-serif;
  letter-spacing: 0.5px;
}

.brand-tagline {
  font-size: 10px;
  color: hsl(var(--wa-green-accent));
  font-weight: 700;
  display: block;
}

.sidebar-menu {
  flex: 1;
  padding: 16px 12px;
  overflow-y: auto;
  list-style: none;
}

.menu-item {
  margin-bottom: 4px;
}

.menu-link {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  border-radius: 8px;
  color: var(--text-secondary);
  text-decoration: none;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
}

.menu-link i {
  font-size: 16px;
  width: 20px;
}

.menu-link:hover {
  background-color: var(--bg-hover);
  color: var(--text-primary);
}

.menu-item.active .menu-link {
  background-color: var(--bg-active);
  color: hsl(var(--wa-green-primary));
  font-weight: 600;
}

[data-theme="dark"] .menu-item.active .menu-link {
  color: hsl(var(--wa-green-accent));
}

.sidebar-footer {
  padding: 16px 24px;
  border-top: 1px solid var(--border-color);
  font-size: 11px;
  color: var(--text-secondary);
  text-align: center;
}

/* Main Workspace */
.main-workspace {
  flex: 1;
  display: flex;
  flex-direction: column;
  height: 100%;
  overflow: hidden;
}

/* Topbar Header */
.topbar {
  height: 70px;
  background-color: var(--bg-sidebar);
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  z-index: 90;
}

.topbar-title {
  font-size: 18px;
  font-weight: 600;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 16px;
}

.device-selector-wrapper {
  display: flex;
  align-items: center;
  gap: 8px;
  background-color: var(--bg-hover);
  padding: 6px 12px;
  border-radius: 20px;
  border: 1px solid var(--border-color);
}

.device-selector {
  background: transparent;
  border: none;
  color: var(--text-primary);
  font-weight: 500;
  outline: none;
  font-size: 13px;
  cursor: pointer;
}

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

.status-online { background-color: hsl(var(--wa-green-accent)); }
.status-offline { background-color: hsl(0, 70%, 50%); }
.status-waiting { background-color: hsl(35, 80%, 55%); }

.action-btn {
  background: none;
  border: none;
  color: var(--text-secondary);
  font-size: 18px;
  cursor: pointer;
  padding: 8px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
}

.action-btn:hover {
  background-color: var(--bg-hover);
  color: var(--text-primary);
}

.user-profile-badge {
  display: flex;
  align-items: center;
  gap: 10px;
  padding-left: 16px;
  border-left: 1px solid var(--border-color);
}

.avatar-circle {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background-color: hsl(var(--wa-green-primary));
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: 15px;
}

.user-info {
  display: flex;
  flex-direction: column;
}

.user-name {
  font-weight: 600;
  font-size: 13px;
}

.user-role {
  font-size: 10px;
  color: var(--text-secondary);
}

/* Page Container & Panels */
.page-container {
  flex: 1;
  padding: 24px;
  overflow-y: auto;
  position: relative;
}

.panel-card {
  background-color: var(--bg-card);
  border-radius: 12px;
  border: 1px solid var(--border-color);
  padding: 24px;
  box-shadow: var(--shadow-sm);
  margin-bottom: 24px;
}

/* Auth Page */
.auth-wrapper {
  display: flex;
  width: 100vw;
  height: 100vh;
  background-color: var(--bg-primary);
  align-items: center;
  justify-content: center;
}

.auth-card {
  width: 400px;
  background-color: var(--bg-card);
  border-radius: 16px;
  border: 1px solid var(--border-color);
  padding: 40px;
  box-shadow: var(--shadow-lg);
  display: flex;
  flex-direction: column;
}

.auth-header {
  text-align: center;
  margin-bottom: 32px;
}

.auth-logo {
  display: inline-flex;
  background-color: hsl(var(--wa-green-primary));
  color: #fff;
  width: 54px;
  height: 54px;
  border-radius: 14px;
  align-items: center;
  justify-content: center;
  font-size: 24px;
  margin-bottom: 16px;
  box-shadow: 0 6px 16px rgba(7, 94, 84, 0.3);
}

.auth-title {
  font-size: 24px;
  font-weight: 800;
  margin-bottom: 4px;
}

.auth-subtitle {
  color: var(--text-secondary);
  font-size: 13px;
}

/* Forms Elements */
.form-group {
  margin-bottom: 20px;
}

.form-label {
  display: block;
  font-weight: 500;
  margin-bottom: 8px;
  color: var(--text-secondary);
}

.form-input {
  width: 100%;
  padding: 12px 16px;
  background-color: var(--bg-primary);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  color: var(--text-primary);
  outline: none;
  font-size: 14px;
  transition: border-color 0.2s ease;
}

.form-input:focus {
  border-color: hsl(var(--wa-green-accent));
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 24px;
  border-radius: 8px;
  font-weight: 600;
  cursor: pointer;
  border: none;
  outline: none;
  transition: all 0.2s ease;
  font-size: 14px;
}

.btn-primary {
  background-color: hsl(var(--wa-green-primary));
  color: #fff;
}

.btn-primary:hover {
  background-color: hsl(var(--wa-green-primary), 0.9);
  box-shadow: 0 4px 12px rgba(7, 94, 84, 0.2);
}

.btn-secondary {
  background-color: var(--bg-hover);
  color: var(--text-primary);
  border: 1px solid var(--border-color);
}

.btn-secondary:hover {
  background-color: var(--border-color);
}

.btn-danger {
  background-color: hsl(0, 75%, 45%);
  color: #fff;
}

.btn-danger:hover {
  background-color: hsl(0, 75%, 40%);
}

.btn-block {
  width: 100%;
}

/* Alert notifications */
.alert-error {
  background-color: hsl(0, 70%, 95%);
  border: 1px solid hsl(0, 70%, 85%);
  color: hsl(0, 70%, 40%);
  padding: 12px;
  border-radius: 8px;
  font-size: 13px;
  margin-bottom: 20px;
}

[data-theme="dark"] .alert-error {
  background-color: hsl(0, 40%, 15%);
  border-color: hsl(0, 40%, 25%);
  color: hsl(0, 70%, 75%);
}

/* Dashboard Summary Widgets */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 20px;
  margin-bottom: 24px;
}

.stats-card {
  background-color: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  padding: 20px;
  display: flex;
  align-items: center;
  gap: 16px;
  box-shadow: var(--shadow-sm);
}

.stats-icon-wrapper {
  width: 48px;
  height: 48px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
}

.stats-icon-green {
  background-color: hsl(142, 20%, 90%);
  color: hsl(var(--wa-green-primary));
}

[data-theme="dark"] .stats-icon-green {
  background-color: hsl(142, 35%, 15%);
  color: hsl(var(--wa-green-accent));
}

.stats-info {
  display: flex;
  flex-direction: column;
}

.stats-title {
  font-size: 12px;
  color: var(--text-secondary);
  font-weight: 500;
  text-transform: uppercase;
  margin-bottom: 4px;
}

.stats-number {
  font-size: 22px;
  font-weight: 700;
  font-family: 'Outfit', sans-serif;
}

/* Chart and Tables */
.dashboard-row {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 24px;
}

@media (max-width: 1024px) {
  .dashboard-row {
    grid-template-columns: 1fr;
  }
}

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

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

.table th, .table td {
  padding: 14px 16px;
  border-bottom: 1px solid var(--border-color);
}

.table th {
  font-weight: 600;
  color: var(--text-secondary);
  font-size: 12px;
  text-transform: uppercase;
}

.table tr:hover td {
  background-color: var(--bg-hover);
}

/* Badges */
.badge {
  display: inline-flex;
  padding: 4px 8px;
  border-radius: 12px;
  font-size: 11px;
  font-weight: 600;
  text-transform: capitalize;
}

.badge-success {
  background-color: hsl(142, 20%, 90%);
  color: hsl(var(--wa-green-primary));
}

.badge-danger {
  background-color: hsl(0, 70%, 95%);
  color: hsl(0, 70%, 40%);
}

.badge-warning {
  background-color: hsl(35, 75%, 90%);
  color: hsl(35, 80%, 40%);
}

.badge-info {
  background-color: hsl(200, 75%, 90%);
  color: hsl(200, 80%, 40%);
}

[data-theme="dark"] .badge-success { background-color: hsl(142, 30%, 15%); color: hsl(var(--wa-green-accent)); }
[data-theme="dark"] .badge-danger { background-color: hsl(0, 40%, 15%); color: hsl(0, 70%, 75%); }
[data-theme="dark"] .badge-warning { background-color: hsl(35, 40%, 15%); color: hsl(35, 80%, 75%); }

/* Device management cards */
.devices-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 20px;
}

.device-card {
  background-color: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  padding: 24px;
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  position: relative;
}

.device-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}

.device-card-title {
  font-size: 16px;
  font-weight: 600;
}

.device-details {
  font-size: 12px;
  color: var(--text-secondary);
  margin-bottom: 20px;
}

.device-details p {
  margin-bottom: 4px;
}

.device-card-actions {
  display: flex;
  gap: 8px;
  margin-top: auto;
}

/* Modals layout */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background-color: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(4px);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
}

.modal-content {
  background-color: var(--bg-card);
  border-radius: 16px;
  border: 1px solid var(--border-color);
  padding: 32px;
  max-width: 500px;
  width: 90%;
  box-shadow: var(--shadow-lg);
  position: relative;
}

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

.modal-close {
  background: none;
  border: none;
  font-size: 20px;
  color: var(--text-secondary);
  cursor: pointer;
}

.qr-code-wrapper {
  background-color: #fff;
  padding: 16px;
  border-radius: 12px;
  display: flex;
  justify-content: center;
  align-items: center;
  width: 250px;
  height: 250px;
  margin: 0 auto 20px;
  box-shadow: var(--shadow-md);
}

.qr-code-wrapper img {
  max-width: 100%;
}

/* Chat view split layout */
.chat-split-view {
  display: flex;
  height: calc(100vh - 120px);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  overflow: hidden;
  background-color: var(--bg-card);
}

.chat-list-panel {
  width: 320px;
  border-right: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  height: 100%;
  background-color: var(--bg-sidebar);
}

.chat-search-wrapper {
  padding: 16px;
  border-bottom: 1px solid var(--border-color);
}

.chat-threads {
  flex: 1;
  overflow-y: auto;
}

.chat-thread-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border-color);
  cursor: pointer;
  transition: background-color 0.2s ease;
}

.chat-thread-item:hover {
  background-color: var(--bg-hover);
}

.chat-thread-item.active {
  background-color: var(--bg-active);
}

.chat-thread-info {
  flex: 1;
  overflow: hidden;
}

.chat-thread-header {
  display: flex;
  justify-content: space-between;
  margin-bottom: 4px;
}

.chat-thread-name {
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.chat-thread-time {
  font-size: 11px;
  color: var(--text-secondary);
}

.chat-thread-preview {
  font-size: 12px;
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.chat-window-panel {
  flex: 1;
  display: flex;
  flex-direction: column;
  height: 100%;
  background-color: var(--chat-bg);
}

.chat-window-header {
  height: 60px;
  background-color: var(--bg-sidebar);
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  padding: 0 20px;
}

.chat-timeline {
  flex: 1;
  padding: 20px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.chat-bubble {
  max-width: 65%;
  padding: 8px 12px;
  border-radius: 8px;
  position: relative;
  box-shadow: 0 1px 1px rgba(0, 0, 0, 0.05);
  line-height: 1.4;
}

.bubble-in {
  background-color: var(--bubble-incoming);
  align-self: flex-start;
  border-top-left-radius: 0;
}

.bubble-out {
  background-color: var(--bubble-outgoing);
  align-self: flex-end;
  border-top-right-radius: 0;
}

.bubble-meta {
  font-size: 10px;
  color: var(--text-secondary);
  text-align: right;
  margin-top: 4px;
  display: flex;
  justify-content: flex-end;
  gap: 4px;
}

.chat-input-toolbar {
  padding: 16px;
  background-color: var(--bg-sidebar);
  border-top: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  gap: 12px;
}

/* Stepper components for Wizard like setups (e.g. Broadcast Step 1-5) */
.stepper-header {
  display: flex;
  justify-content: space-between;
  margin-bottom: 32px;
  position: relative;
}

.stepper-header::before {
  content: '';
  position: absolute;
  top: 16px;
  left: 0;
  width: 100%;
  height: 2px;
  background-color: var(--border-color);
  z-index: 1;
}

.step-node {
  display: flex;
  flex-direction: column;
  align-items: center;
  z-index: 2;
  flex: 1;
  text-align: center;
}

.step-circle {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background-color: var(--bg-card);
  border: 2px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 8px;
  transition: all 0.3s ease;
}

.step-node.active .step-circle {
  background-color: hsl(var(--wa-green-primary));
  border-color: hsl(var(--wa-green-primary));
  color: #fff;
  box-shadow: 0 0 0 4px hsl(142, 20%, 90%);
}

.step-node.completed .step-circle {
  background-color: hsl(var(--wa-green-accent));
  border-color: hsl(var(--wa-green-accent));
  color: #fff;
}

.step-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-secondary);
}

.step-node.active .step-label {
  color: hsl(var(--wa-green-primary));
}

/* Stepper navigation footer */
.stepper-actions {
  display: flex;
  justify-content: space-between;
  margin-top: 32px;
  border-top: 1px solid var(--border-color);
  padding-top: 20px;
}

/* File Drag & Drop Upload Zone */
.upload-zone {
  border: 2px dashed var(--border-color);
  border-radius: 12px;
  padding: 40px;
  text-align: center;
  cursor: pointer;
  background-color: var(--bg-primary);
  transition: all 0.2s ease;
}

.upload-zone:hover {
  border-color: hsl(var(--wa-green-accent));
  background-color: var(--bg-hover);
}

.upload-icon {
  font-size: 40px;
  color: var(--text-secondary);
  margin-bottom: 16px;
}

.toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 2000;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.toast {
  background-color: var(--bg-card);
  border: 1px solid var(--border-color);
  border-left: 4px solid hsl(var(--wa-green-accent));
  border-radius: 8px;
  padding: 12px 20px;
  display: flex;
  align-items: center;
  gap: 12px;
  box-shadow: var(--shadow-md);
  animation: slideIn 0.3s ease;
  min-width: 300px;
}

.toast-error {
  border-left-color: hsl(0, 70%, 50%);
}

.toast-info {
  border-left-color: hsl(200, 70%, 50%);
}

/* Animations */
@keyframes pulse {
  0%, 100% { opacity: 0.8; }
  50% { opacity: 0.4; }
}

@keyframes loading {
  0% { left: -50%; }
  100% { left: 100%; }
}

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

/* Scrollbars styling */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: var(--border-color);
  border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--text-secondary);
}
