:root {
  --bg-dark: #090D16;
  --bg-card: rgba(18, 24, 38, 0.75);
  --bg-card-hover: rgba(26, 34, 52, 0.85);
  --border-color: rgba(255, 255, 255, 0.08);
  --border-glow: rgba(37, 211, 102, 0.25);
  
  --primary: #25D366;
  --primary-hover: #20BA56;
  --primary-glow: rgba(37, 211, 102, 0.35);
  --accent: #0084FF;
  --accent-glow: rgba(0, 132, 255, 0.35);
  
  --text-main: #F8FAFC;
  --text-muted: #94A3B8;
  --text-dim: #64748B;
  
  --status-success: #10B981;
  --status-warning: #F59E0B;
  --status-error: #EF4444;
  --status-info: #3B82F6;
  
  --radius-sm: 8px;
  --radius-md: 14px;
  --radius-lg: 20px;
  
  --font-sans: 'Plus Jakarta Sans', system-ui, -apple-system, sans-serif;
  --font-mono: 'JetBrains Mono', monospace;
}

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

body {
  font-family: var(--font-sans);
  background-color: var(--bg-dark);
  color: var(--text-main);
  min-height: 100vh;
  overflow-x: hidden;
  position: relative;
  -webkit-font-smoothing: antialiased;
}

/* Background Ambient Glow */
.app-background {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  overflow: hidden;
}

.glow-orb {
  position: absolute;
  border-radius: 50%;
  filter: blur(120px);
  opacity: 0.15;
}

.glow-top-left {
  width: 500px;
  height: 500px;
  background: radial-gradient(circle, var(--primary) 0%, transparent 70%);
  top: -150px;
  left: -150px;
}

.glow-bottom-right {
  width: 600px;
  height: 600px;
  background: radial-gradient(circle, var(--accent) 0%, transparent 70%);
  bottom: -200px;
  right: -200px;
}

/* Main Container */
.app-container {
  position: relative;
  z-index: 1;
  max-width: 1280px;
  margin: 0 auto;
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 24px;
}

/* Header */
.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 28px;
  background: var(--bg-card);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
}

.logo-group {
  display: flex;
  align-items: center;
  gap: 16px;
}

.logo-icon {
  width: 48px;
  height: 48px;
  border-radius: var(--radius-md);
  background: linear-gradient(135deg, rgba(37, 211, 102, 0.2), rgba(0, 132, 255, 0.2));
  border: 1px solid var(--border-glow);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--primary);
}

.logo-icon svg {
  width: 26px;
  height: 26px;
}

.app-title {
  font-size: 1.4rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 10px;
}

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

/* Status Pill */
.status-pill {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 16px;
  border-radius: 9999px;
  font-size: 0.85rem;
  font-weight: 500;
  border: 1px solid var(--border-color);
  background: rgba(255, 255, 255, 0.03);
  transition: all 0.3s ease;
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
}

.status-loading .status-dot {
  background: var(--status-warning);
  box-shadow: 0 0 10px var(--status-warning);
  animation: pulse 1.5s infinite;
}

.status-connected {
  background: rgba(16, 185, 129, 0.1);
  border-color: rgba(16, 185, 129, 0.3);
  color: #34D399;
}
.status-connected .status-dot {
  background: #10B981;
  box-shadow: 0 0 8px #10B981;
}

.status-disconnected {
  background: rgba(239, 68, 68, 0.1);
  border-color: rgba(239, 68, 68, 0.3);
  color: #F87171;
}
.status-disconnected .status-dot {
  background: #EF4444;
}

@keyframes pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.4; transform: scale(1.3); }
}

/* Navigation Tabs */
.nav-tabs {
  display: flex;
  gap: 10px;
  background: rgba(15, 20, 32, 0.6);
  padding: 6px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
  backdrop-filter: blur(12px);
}

.nav-tab {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 18px;
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-family: var(--font-sans);
  font-size: 0.92rem;
  font-weight: 600;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.2s ease;
}

.nav-tab svg {
  width: 18px;
  height: 18px;
}

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

.nav-tab.active {
  color: var(--text-main);
  background: linear-gradient(135deg, rgba(37, 211, 102, 0.18), rgba(0, 132, 255, 0.12));
  border: 1px solid var(--border-glow);
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
}

/* Tab Panels */
.tab-panel {
  display: none;
  animation: fadeIn 0.25s ease forwards;
}

.tab-panel.active {
  display: block;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Cards & Layout */
.card {
  background: var(--bg-card);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 24px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.25);
  transition: border-color 0.2s ease;
}

.card:hover {
  border-color: rgba(255, 255, 255, 0.14);
}

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

.card-header h3 {
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--text-main);
}

.card-description {
  color: var(--text-muted);
  font-size: 0.92rem;
  line-height: 1.5;
  margin-bottom: 16px;
}

/* Stats Grid */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.stat-card {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 20px;
}

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

.stat-icon svg {
  width: 26px;
  height: 26px;
}

.icon-emerald { background: rgba(37, 211, 102, 0.15); color: #34D399; }
.icon-blue { background: rgba(59, 130, 246, 0.15); color: #60A5FA; }
.icon-purple { background: rgba(168, 85, 247, 0.15); color: #C084FC; }
.icon-amber { background: rgba(245, 158, 11, 0.15); color: #FBBF24; }

.stat-content {
  display: flex;
  flex-direction: column;
}

.stat-label {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.stat-value {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--text-main);
  margin: 2px 0;
}

.stat-hint {
  font-size: 0.8rem;
  color: var(--text-dim);
}

.dashboard-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(400px, 1fr));
  gap: 20px;
}

/* Code Box */
.code-box {
  background: rgba(10, 14, 23, 0.8);
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: var(--radius-sm);
  padding: 12px 16px;
  margin-bottom: 12px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

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

.code-box code {
  font-family: var(--font-mono);
  color: #38BDF8;
  font-size: 0.9rem;
  word-break: break-all;
}

/* Alerts */
.alert {
  padding: 14px 18px;
  border-radius: var(--radius-sm);
  font-size: 0.88rem;
  line-height: 1.5;
  margin-top: 14px;
}

.alert-info {
  background: rgba(59, 130, 246, 0.1);
  border: 1px solid rgba(59, 130, 246, 0.25);
  color: #93C5FD;
}

/* Feature List */
.feature-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.feature-list li {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 0.92rem;
  color: var(--text-main);
}

/* Badges */
.badge {
  padding: 4px 10px;
  border-radius: 9999px;
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.badge-accent {
  background: rgba(0, 132, 255, 0.15);
  color: #60A5FA;
  border: 1px solid rgba(0, 132, 255, 0.3);
}

.badge-success {
  background: rgba(16, 185, 129, 0.15);
  color: #34D399;
  border: 1px solid rgba(16, 185, 129, 0.3);
}

/* Send Tab Layout */
.send-layout {
  display: grid;
  grid-template-columns: 1.2fr 0.8fr;
  gap: 24px;
}

@media (max-width: 960px) {
  .send-layout {
    grid-template-columns: 1fr;
  }
}

/* Message Type Selector */
.msg-type-selector {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 20px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--border-color);
}

.type-btn {
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border-color);
  color: var(--text-muted);
  padding: 8px 14px;
  border-radius: var(--radius-sm);
  font-family: var(--font-sans);
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
}

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

.type-btn.active {
  background: var(--primary);
  color: #062312;
  border-color: var(--primary);
  box-shadow: 0 0 15px var(--primary-glow);
}

/* Form Styles */
.type-form {
  display: none;
}

.type-form.active {
  display: block;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 16px;
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

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

.required {
  color: var(--status-error);
}

input[type="text"],
input[type="url"],
select,
textarea {
  width: 100%;
  background: rgba(10, 14, 23, 0.8);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  color: var(--text-main);
  font-family: var(--font-sans);
  font-size: 0.92rem;
  outline: none;
  transition: all 0.2s ease;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 12px var(--primary-glow);
}

.input-with-icon {
  display: flex;
  align-items: center;
  position: relative;
}

.input-prefix {
  position: absolute;
  left: 14px;
  font-size: 1rem;
}

.input-with-icon input {
  padding-left: 44px;
}

.form-help {
  font-size: 0.78rem;
  color: var(--text-dim);
}

.form-group-checkbox {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 16px;
}

.form-group-checkbox input {
  accent-color: var(--primary);
  width: 16px;
  height: 16px;
}

.dynamic-inputs {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.list-rows-container {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.list-row-item {
  display: grid;
  grid-template-columns: 1fr 1.5fr;
  gap: 8px;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 20px;
  border-radius: var(--radius-sm);
  font-family: var(--font-sans);
  font-size: 0.92rem;
  font-weight: 600;
  border: none;
  cursor: pointer;
  transition: all 0.2s ease;
}

.btn-primary {
  background: var(--primary);
  color: #052613;
  box-shadow: 0 4px 15px var(--primary-glow);
}

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

.btn-primary:active {
  transform: translateY(0);
}

.btn-secondary {
  background: rgba(255, 255, 255, 0.08);
  color: var(--text-main);
  border: 1px solid var(--border-color);
}

.btn-secondary:hover {
  background: rgba(255, 255, 255, 0.12);
}

.btn-large {
  width: 100%;
  padding: 14px 24px;
  font-size: 1rem;
}

.btn-sm {
  padding: 6px 12px;
  font-size: 0.8rem;
}

/* WhatsApp Phone Preview Mockup */
.preview-card {
  background: #0B141A;
  border-radius: var(--radius-lg);
  border: 1px solid rgba(255, 255, 255, 0.1);
  overflow: hidden;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.4);
  display: flex;
  flex-direction: column;
  height: 520px;
}

.preview-header {
  background: #202C33;
  padding: 14px 18px;
  display: flex;
  align-items: center;
  gap: 12px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.preview-avatar {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: var(--primary);
  color: #062312;
  font-weight: 800;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
}

.preview-name {
  display: block;
  font-size: 0.95rem;
  font-weight: 600;
  color: #E9EDEF;
}

.preview-status {
  display: block;
  font-size: 0.75rem;
  color: #8696A0;
}

.preview-chat {
  flex: 1;
  background-color: #0B141A;
  background-image: radial-gradient(rgba(255, 255, 255, 0.03) 1px, transparent 1px);
  background-size: 16px 16px;
  padding: 20px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
}

.chat-bubble-container {
  display: flex;
  justify-content: flex-end;
}

.chat-bubble {
  background: #005C4B;
  color: #E9EDEF;
  padding: 10px 14px;
  border-radius: 12px 0 12px 12px;
  max-width: 85%;
  font-size: 0.9rem;
  line-height: 1.45;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
  word-break: break-word;
}

.chat-bubble-header {
  font-weight: 700;
  color: #25D366;
  margin-bottom: 4px;
}

.chat-bubble-footer {
  font-size: 0.75rem;
  color: #8696A0;
  margin-top: 6px;
}

.chat-bubble-buttons {
  margin-top: 10px;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
  padding-top: 8px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.preview-bubble-btn {
  background: rgba(255, 255, 255, 0.08);
  border: none;
  color: #53BDEB;
  padding: 6px 10px;
  border-radius: 6px;
  font-size: 0.85rem;
  font-weight: 600;
  text-align: center;
}

.chat-bubble-meta {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 4px;
  margin-top: 4px;
}

.chat-time {
  font-size: 0.7rem;
  color: #8696A0;
}

.chat-ticks {
  color: #53BDEB;
  font-size: 0.75rem;
}

/* Templates Grid */
.templates-layout {
  display: grid;
  grid-template-columns: 1.2fr 1fr;
  gap: 24px;
}

@media (max-width: 960px) {
  .templates-layout {
    grid-template-columns: 1fr;
  }
}

.templates-grid {
  display: flex;
  flex-direction: column;
  gap: 12px;
  max-height: 540px;
  overflow-y: auto;
  padding-right: 6px;
}

.template-card {
  background: rgba(10, 14, 23, 0.6);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.template-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.template-name {
  font-weight: 700;
  font-size: 0.95rem;
  color: var(--text-main);
}

.template-lang {
  font-size: 0.75rem;
  padding: 2px 8px;
  background: rgba(255, 255, 255, 0.06);
  border-radius: 4px;
  color: var(--text-muted);
}

.template-body-text {
  font-size: 0.88rem;
  color: var(--text-muted);
  line-height: 1.4;
}

/* History Table */
.table-container {
  overflow-x: auto;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.88rem;
}

.data-table th,
.data-table td {
  padding: 12px 16px;
  text-align: left;
  border-bottom: 1px solid var(--border-color);
}

.data-table th {
  color: var(--text-muted);
  font-weight: 600;
  font-size: 0.8rem;
  text-transform: uppercase;
}

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

.badge-direction {
  padding: 3px 8px;
  border-radius: 4px;
  font-size: 0.75rem;
  font-weight: 600;
}

.badge-out { background: rgba(59, 130, 246, 0.15); color: #60A5FA; }
.badge-in { background: rgba(16, 185, 129, 0.15); color: #34D399; }

/* Toast Notifications */
.toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.toast {
  background: #1E293B;
  border: 1px solid var(--border-color);
  color: var(--text-main);
  padding: 14px 20px;
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  gap: 12px;
  animation: slideUp 0.3s ease forwards;
}

.toast-success { border-color: var(--status-success); }
.toast-error { border-color: var(--status-error); }

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