:root {
  --bg-dark: #0b0f19;
  --bg-card: rgba(21, 28, 45, 0.75);
  --bg-card-border: rgba(255, 255, 255, 0.08);
  --primary: #3b82f6;
  --primary-hover: #2563eb;
  --whatsapp-green: #25d366;
  --whatsapp-green-dark: #128c7e;
  --whatsapp-bg: #0b141a;
  --whatsapp-bubble-bot: #202c33;
  --whatsapp-bubble-user: #005c4b;
  --text-main: #f1f5f9;
  --text-muted: #94a3b8;
  --border-color: #1e293b;
  --status-green: #10b981;
  --status-orange: #f59e0b;
  --status-red: #ef4444;
  --status-blue: #0ea5e9;
  --font-family: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-mono: 'JetBrains Mono', monospace;
}

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

body {
  font-family: var(--font-family);
  background-color: var(--bg-dark);
  background-image: 
    radial-gradient(at 0% 0%, rgba(59, 130, 246, 0.12) 0px, transparent 50%),
    radial-gradient(at 100% 100%, rgba(37, 211, 102, 0.08) 0px, transparent 50%);
  color: var(--text-main);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.app-container {
  max-width: 1440px;
  margin: 0 auto;
  padding: 20px;
  width: 100%;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  gap: 20px;
}

/* Header Navbar */
.navbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 24px;
  background: var(--bg-card);
  backdrop-filter: blur(12px);
  border: 1px solid var(--bg-card-border);
  border-radius: 16px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 14px;
}

.logo-icon {
  width: 44px;
  height: 44px;
  background: linear-gradient(135deg, #2563eb, #25d366);
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  color: white;
  box-shadow: 0 4px 14px rgba(37, 211, 102, 0.25);
}

.brand-text h1 {
  font-size: 20px;
  font-weight: 800;
  letter-spacing: -0.5px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.version-tag {
  font-size: 11px;
  background: rgba(59, 130, 246, 0.2);
  color: var(--primary);
  padding: 2px 8px;
  border-radius: 20px;
  border: 1px solid rgba(59, 130, 246, 0.3);
}

.brand-text p {
  font-size: 12px;
  color: var(--text-muted);
}

.nav-metrics {
  display: flex;
  gap: 12px;
}

.metric-pill {
  font-size: 13px;
  padding: 6px 14px;
  border-radius: 20px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--bg-card-border);
  display: flex;
  align-items: center;
  gap: 8px;
}

.metric-pill.success { border-color: rgba(16, 185, 129, 0.3); }
.metric-pill.warning { border-color: rgba(245, 158, 11, 0.3); }

.dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
}
.dot.green { background: var(--status-green); }
.dot.orange { background: var(--status-orange); }
.dot.pulse { animation: pulse-green 2s infinite; }

@keyframes pulse-green {
  0% { box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.7); }
  70% { box-shadow: 0 0 0 8px rgba(16, 185, 129, 0); }
  100% { box-shadow: 0 0 0 0 rgba(16, 185, 129, 0); }
}

/* Layout Grid */
.workspace-grid {
  display: grid;
  grid-template-columns: 440px 1fr;
  gap: 20px;
  flex: 1;
}

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

.card {
  background: var(--bg-card);
  backdrop-filter: blur(12px);
  border: 1px solid var(--bg-card-border);
  border-radius: 20px;
  padding: 20px;
  display: flex;
  flex-direction: column;
}

.card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--border-color);
  margin-bottom: 16px;
}

.card-header h2 {
  font-size: 16px;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 8px;
}

.text-whatsapp { color: var(--whatsapp-green); }

.status-badge {
  font-size: 11px;
  padding: 4px 10px;
  border-radius: 12px;
  background: rgba(37, 211, 102, 0.15);
  color: var(--whatsapp-green);
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 6px;
}

/* Chat Section */
.chat-section {
  background: var(--whatsapp-bg);
  border-color: rgba(255, 255, 255, 0.05);
}

.chat-viewport {
  flex: 1;
  min-height: 400px;
  max-height: 520px;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  background: radial-gradient(circle, rgba(255,255,255,0.02) 1px, transparent 1px);
  background-size: 20px 20px;
  border-radius: 12px;
}

.chat-bubble {
  max-width: 85%;
  padding: 12px 16px;
  border-radius: 14px;
  font-size: 13.5px;
  line-height: 1.5;
  position: relative;
  word-break: break-word;
  animation: fadeIn 0.3s ease;
}

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

.bot-bubble {
  background: var(--whatsapp-bubble-bot);
  color: #e9edef;
  align-self: flex-start;
  border-top-left-radius: 2px;
}

.user-bubble {
  background: var(--whatsapp-bubble-user);
  color: #e9edef;
  align-self: flex-end;
  border-top-right-radius: 2px;
}

.sender-name {
  font-size: 11px;
  font-weight: 700;
  color: var(--whatsapp-green);
  margin-bottom: 4px;
}

.time-stamp {
  font-size: 10px;
  color: rgba(241, 245, 249, 0.5);
  text-align: right;
  margin-top: 6px;
}

.ticket-preview-box {
  background: rgba(0, 0, 0, 0.3);
  border: 1px dashed rgba(255, 255, 255, 0.2);
  border-radius: 8px;
  padding: 10px;
  margin-top: 8px;
  font-family: var(--font-mono);
  font-size: 11px;
}

.doc-download-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: rgba(59, 130, 246, 0.2);
  color: #60a5fa;
  padding: 6px 12px;
  border-radius: 6px;
  text-decoration: none;
  font-size: 12px;
  margin-top: 6px;
  border: 1px solid rgba(59, 130, 246, 0.3);
  transition: all 0.2s;
}

.doc-download-btn:hover {
  background: rgba(59, 130, 246, 0.3);
  color: white;
}

/* Presets & Inputs */
.preset-section {
  padding: 12px 0;
  border-top: 1px solid var(--border-color);
  margin-top: 10px;
}

.preset-label {
  font-size: 11px;
  color: var(--text-muted);
  display: block;
  margin-bottom: 8px;
  font-weight: 600;
}

.preset-buttons {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.btn-preset {
  font-size: 11px;
  padding: 6px 10px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: var(--text-main);
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-preset:hover {
  background: rgba(37, 211, 102, 0.2);
  border-color: var(--whatsapp-green);
  color: white;
}

.chat-input-bar {
  display: flex;
  gap: 8px;
  margin-top: 8px;
}

.chat-input-bar input[type="text"] {
  flex: 1;
  background: #2a3942;
  border: none;
  border-radius: 8px;
  padding: 10px 14px;
  color: white;
  font-size: 13px;
  outline: none;
}

.chat-input-bar input[type="text"]::placeholder {
  color: #8696a0;
}

.btn-icon {
  width: 38px;
  height: 38px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #2a3942;
  border: none;
  border-radius: 8px;
  color: #8696a0;
  cursor: pointer;
}

.btn-icon:hover { color: white; }

.btn-whatsapp {
  background: var(--whatsapp-green);
  color: #0b141a;
  font-weight: 700;
  padding: 0 16px;
  border-radius: 8px;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
  transition: background 0.2s;
}

.btn-whatsapp:hover {
  background: #20c65e;
}

/* Control Tabs */
.tabs-header {
  display: flex;
  gap: 8px;
  border-bottom: 1px solid var(--border-color);
  padding-bottom: 10px;
  margin-bottom: 16px;
}

.tab-btn {
  padding: 8px 16px;
  border-radius: 10px;
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-weight: 600;
  font-size: 13px;
  cursor: pointer;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  gap: 8px;
}

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

.tab-btn.active {
  color: white;
  background: var(--primary);
}

.tab-pane {
  display: none;
  flex: 1;
}

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

.pane-title {
  margin-bottom: 16px;
}

.pane-title h3 {
  font-size: 16px;
  font-weight: 700;
}

.pane-title p {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 4px;
}

/* Form Styles */
.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.form-group.full-width {
  grid-column: span 2;
}

.form-group label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
}

.form-group input, .form-group select {
  background: rgba(15, 23, 42, 0.6);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  padding: 10px 12px;
  color: white;
  font-size: 13px;
  outline: none;
}

.form-group input:focus, .form-group select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.2);
}

.form-actions {
  grid-column: span 2;
  margin-top: 10px;
}

.btn-primary {
  background: var(--primary);
  color: white;
  font-weight: 600;
  padding: 10px 20px;
  border-radius: 8px;
  border: none;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  transition: background 0.2s;
}

.btn-primary:hover { background: var(--primary-hover); }

.info-alert {
  margin-top: 20px;
  padding: 12px 16px;
  background: rgba(16, 185, 129, 0.1);
  border: 1px solid rgba(16, 185, 129, 0.2);
  border-radius: 10px;
  font-size: 12px;
  display: flex;
  align-items: center;
  gap: 10px;
}

/* Merchant List Cards */
.merchant-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.merchant-card {
  background: rgba(15, 23, 42, 0.4);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  padding: 14px;
}

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

.merchant-name {
  font-weight: 700;
  font-size: 15px;
  color: white;
}

.merchant-rfc {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-muted);
}

.steps-list {
  font-size: 12px;
  color: #cbd5e1;
  padding-left: 18px;
  margin-top: 8px;
  line-height: 1.6;
}

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

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
}

.data-table th {
  background: rgba(15, 23, 42, 0.8);
  color: var(--text-muted);
  text-align: left;
  padding: 10px 12px;
  font-weight: 600;
}

.data-table td {
  padding: 12px;
  border-bottom: 1px solid var(--border-color);
}

.badge-status {
  padding: 4px 8px;
  border-radius: 12px;
  font-weight: 700;
  font-size: 10px;
}
.badge-status.automated { background: rgba(16, 185, 129, 0.2); color: var(--status-green); }
.badge-status.info_required { background: rgba(245, 158, 11, 0.2); color: var(--status-orange); }

.app-footer {
  text-align: center;
  font-size: 12px;
  color: var(--text-muted);
  padding: 10px;
  border-top: 1px solid var(--border-color);
}
