@import url('https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:wght@400;500;600;700;800&family=JetBrains+Mono:wght@400;500;600&display=swap');

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-font-smoothing: antialiased;
}

:root {
  --bg-main: #06090e;
  --bg-card: rgba(16, 24, 38, 0.7);
  --bg-card-hover: rgba(22, 33, 52, 0.85);
  --bg-input: rgba(8, 14, 24, 0.85);
  --border: rgba(255, 255, 255, 0.08);
  --border-focus: rgba(37, 211, 102, 0.5);
  --border-glow: rgba(37, 211, 102, 0.25);
  
  --primary: #25d366;
  --primary-glow: rgba(37, 211, 102, 0.35);
  --primary-dark: #128c7e;
  
  --accent-cyan: #06b6d4;
  --accent-purple: #8b5cf6;
  --danger: #ef4444;
  --danger-bg: rgba(239, 68, 68, 0.12);
  --warning: #f59e0b;
  --warning-bg: rgba(245, 158, 11, 0.12);
  
  --text-main: #f8fafc;
  --text-muted: #94a3b8;
  --text-dim: #64748b;
  
  --radius-sm: 8px;
  --radius-md: 14px;
  --radius-lg: 20px;
  --radius-full: 9999px;
  
  --font-sans: 'Plus Jakarta Sans', system-ui, -apple-system, sans-serif;
  --font-mono: 'JetBrains Mono', monospace;
  
  --shadow-card: 0 10px 30px -10px rgba(0, 0, 0, 0.5), 0 0 1px 1px rgba(255, 255, 255, 0.05);
  --shadow-glow: 0 0 25px rgba(37, 211, 102, 0.2);
}

body {
  background-color: var(--bg-main);
  background-image: 
    radial-gradient(at 0% 0%, rgba(37, 211, 102, 0.07) 0px, transparent 50%),
    radial-gradient(at 100% 0%, rgba(6, 182, 212, 0.06) 0px, transparent 50%),
    radial-gradient(at 50% 100%, rgba(139, 92, 246, 0.05) 0px, transparent 50%);
  background-attachment: fixed;
  color: var(--text-main);
  font-family: var(--font-sans);
  min-height: 100vh;
  line-height: 1.5;
  display: flex;
  flex-direction: column;
}

/* ================= TOPBAR ================= */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  flex-wrap: wrap;
  padding: 14px 28px;
  background: rgba(10, 16, 26, 0.75);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 100;
}

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

.brand-icon-wrap {
  position: relative;
}

.logo-glow {
  position: absolute;
  inset: -2px;
  background: linear-gradient(135deg, var(--primary), var(--accent-cyan));
  border-radius: 50%;
  filter: blur(8px);
  opacity: 0.6;
  animation: pulse-glow 3s ease-in-out infinite alternate;
}

.logo {
  position: relative;
  width: 44px;
  height: 44px;
  background: linear-gradient(135deg, #1fa855, #128c7e);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 14px rgba(0,0,0,0.4);
}

.logo svg {
  width: 24px;
  height: 24px;
  fill: white;
}

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

.brand-title h1 {
  font-size: 19px;
  font-weight: 800;
  letter-spacing: -0.02em;
  background: linear-gradient(135deg, #ffffff 40%, #a7f3d0 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.tag-god {
  font-size: 10px;
  font-weight: 800;
  padding: 2px 7px;
  border-radius: var(--radius-full);
  background: linear-gradient(135deg, #059669, #10b981);
  color: #fff;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  box-shadow: 0 2px 8px rgba(16, 185, 129, 0.4);
}

.sub {
  color: var(--text-muted);
  font-size: 12.5px;
  font-weight: 500;
}

/* ================= TABS ================= */
.tabs {
  display: flex;
  gap: 4px;
  background: rgba(6, 10, 18, 0.8);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 4px;
}

.tab {
  border: none;
  background: transparent;
  color: var(--text-muted);
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 13.5px;
  font-weight: 600;
  font-family: inherit;
  display: flex;
  align-items: center;
  gap: 8px;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

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

.tab.active {
  background: linear-gradient(135deg, rgba(37, 211, 102, 0.2), rgba(6, 182, 212, 0.15));
  color: #a7f3d0;
  border: 1px solid rgba(37, 211, 102, 0.3);
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.3);
}

.sse-pill {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border-radius: var(--radius-full);
  background: rgba(15, 23, 42, 0.6);
  border: 1px solid var(--border);
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
}

.dot-live {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--primary);
  box-shadow: 0 0 8px var(--primary);
  animation: pulse-dot 1.8s infinite;
}

.dot-live.offline {
  background: var(--danger);
  box-shadow: 0 0 8px var(--danger);
}

/* ================= MAIN & LAYOUT ================= */
main {
  max-width: 1400px;
  width: 100%;
  margin: 0 auto;
  padding: 24px 28px 80px;
  flex: 1;
}

.tab-panel {
  display: none;
  animation: fadeIn 0.25s ease-out forwards;
}

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

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 12px;
  flex-wrap: wrap;
}

.panel-head h2 {
  font-size: 20px;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.hint {
  color: var(--text-muted);
  font-size: 13.5px;
  margin-bottom: 20px;
  line-height: 1.6;
}

.hint code {
  background: rgba(255, 255, 255, 0.08);
  padding: 2px 7px;
  border-radius: 6px;
  font-family: var(--font-mono);
  font-size: 12px;
  color: #67e8f9;
  border: 1px solid rgba(255, 255, 255, 0.05);
}

/* ================= CARDS & GRID ================= */
.cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(380px, 1fr));
  gap: 20px;
}

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

.glass-card {
  background: var(--bg-card);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 22px;
  box-shadow: var(--shadow-card);
  transition: transform 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease;
  position: relative;
  overflow: hidden;
}

.glass-card:hover {
  border-color: rgba(255, 255, 255, 0.16);
  box-shadow: 0 14px 40px -10px rgba(0, 0, 0, 0.6);
}

.glass-card.connected-card {
  border-left: 4px solid var(--primary);
}

.glass-card.connecting-card {
  border-left: 4px solid var(--accent-cyan);
}

.card-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.card-title-group {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.card-name {
  font-size: 17px;
  font-weight: 700;
  color: var(--text-main);
}

.card-id-tag {
  font-family: var(--font-mono);
  font-size: 11.5px;
  color: var(--text-dim);
}

/* ================= BADGES ================= */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: var(--radius-full);
  font-size: 11.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.badge.activa,
.badge.connected {
  background: rgba(37, 211, 102, 0.15);
  color: #4ade80;
  border: 1px solid rgba(74, 222, 128, 0.3);
}

.badge.qr,
.badge.connecting {
  background: rgba(6, 182, 212, 0.15);
  color: #67e8f9;
  border: 1px solid rgba(103, 232, 249, 0.3);
}

.badge.inactiva,
.badge.disconnected {
  background: var(--danger-bg);
  color: #f87171;
  border: 1px solid rgba(248, 113, 113, 0.3);
}

/* ================= STATS ROW ================= */
.stats-strip {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  background: rgba(0, 0, 0, 0.25);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 8px 12px;
  margin: 14px 0;
  text-align: center;
}

.stat-item .stat-num {
  font-family: var(--font-mono);
  font-size: 14px;
  font-weight: 700;
  color: var(--text-main);
}

.stat-item .stat-lbl {
  font-size: 10.5px;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

/* ================= QR & PAIRING ================= */
.qr-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  background: #ffffff;
  border-radius: var(--radius-md);
  padding: 16px;
  margin: 16px 0;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
}

.qr-container img {
  width: 220px;
  height: 220px;
  image-rendering: pixelated;
}

.qr-instruction {
  color: #0f172a;
  font-size: 12px;
  font-weight: 600;
  text-align: center;
  line-height: 1.4;
}

.pairing-box {
  background: rgba(6, 182, 212, 0.1);
  border: 1px dashed rgba(6, 182, 212, 0.4);
  border-radius: var(--radius-sm);
  padding: 12px;
  margin: 12px 0;
  text-align: center;
}

.pairing-code-display {
  font-family: var(--font-mono);
  font-size: 24px;
  font-weight: 800;
  letter-spacing: 4px;
  color: #67e8f9;
  margin: 6px 0;
}

/* ================= BUTTONS ================= */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  background: rgba(255, 255, 255, 0.06);
  color: var(--text-main);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 8px 14px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
  font-family: inherit;
  transition: all 0.18s ease;
  white-space: nowrap;
}

.btn:hover {
  background: rgba(255, 255, 255, 0.12);
  border-color: rgba(255, 255, 255, 0.2);
  transform: translateY(-1px);
}

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

.btn.primary {
  background: linear-gradient(135deg, #1fa855, #128c7e);
  border-color: rgba(37, 211, 102, 0.4);
  color: #ffffff;
  box-shadow: 0 4px 12px rgba(37, 211, 102, 0.25);
}

.btn.primary:hover {
  background: linear-gradient(135deg, #25d366, #16a085);
  box-shadow: 0 6px 18px rgba(37, 211, 102, 0.35);
}

.btn.cyan {
  background: linear-gradient(135deg, #0284c7, #06b6d4);
  border-color: rgba(6, 182, 212, 0.4);
  color: #ffffff;
}

.btn.danger {
  background: transparent;
  border-color: rgba(239, 68, 68, 0.4);
  color: #f87171;
}

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

.btn.sm {
  padding: 5px 10px;
  font-size: 12px;
}

.btn-group {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 14px;
}

/* ================= INPUTS & FORMS ================= */
.field {
  margin-bottom: 16px;
}

.field label {
  display: block;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

input[type='text'],
input[type='password'],
input[type='number'],
textarea,
select {
  width: 100%;
  background: var(--bg-input);
  border: 1px solid var(--border);
  color: var(--text-main);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  font-size: 14px;
  font-family: inherit;
  transition: border-color 0.2s, box-shadow 0.2s;
}

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

textarea {
  resize: vertical;
  min-height: 80px;
}

.grid2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}

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

/* ================= LIVE SIMULATOR / TEST BOX ================= */
.test-panel {
  margin-top: 16px;
  background: rgba(0, 0, 0, 0.35);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 16px;
}

.test-panel-title {
  font-size: 12.5px;
  font-weight: 700;
  text-transform: uppercase;
  color: #a7f3d0;
  letter-spacing: 0.05em;
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  gap: 6px;
}

/* ================= CONSTRUCTOR DE MENÚS ================= */
.menu-builder-layout {
  display: grid;
  grid-template-columns: 320px 1fr 340px;
  gap: 20px;
  align-items: start;
}

@media (max-width: 1100px) {
  .menu-builder-layout {
    grid-template-columns: 1fr;
  }
}

.menu-list-col {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 16px;
}

.menu-item-btn {
  width: 100%;
  text-align: left;
  background: transparent;
  border: 1px solid transparent;
  color: var(--text-main);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  cursor: pointer;
  margin-bottom: 6px;
  transition: all 0.15s;
}

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

.menu-item-btn.active {
  background: rgba(37, 211, 102, 0.12);
  border-color: rgba(37, 211, 102, 0.4);
}

.menu-item-btn .mit-title {
  font-weight: 700;
  font-size: 14px;
}

.menu-item-btn .mit-sub {
  font-size: 11.5px;
  color: var(--text-muted);
  font-family: var(--font-mono);
}

.menu-editor-col {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 24px;
}

.section-block {
  background: rgba(0, 0, 0, 0.3);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 14px;
  margin-bottom: 14px;
}

.row-item-grid {
  display: grid;
  grid-template-columns: 1fr 1.2fr 0.8fr auto;
  gap: 8px;
  align-items: center;
  margin-bottom: 8px;
}

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

/* ================= WHATSAPP PREVIEW MOCKUP ================= */
.phone-mockup {
  background: #0b141a;
  border: 3px solid #2a3942;
  border-radius: 28px;
  padding: 16px 12px;
  box-shadow: 0 20px 40px rgba(0,0,0,0.8);
  font-family: var(--font-sans);
  max-width: 330px;
  margin: 0 auto;
}

.phone-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding-bottom: 12px;
  border-bottom: 1px solid #1f2c34;
  margin-bottom: 14px;
}

.phone-avatar {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: var(--primary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 13px;
  color: #04240f;
}

.phone-contact-name {
  font-size: 14px;
  font-weight: 700;
  color: #e9edef;
}

.phone-bubble {
  background: #005c4b;
  border-radius: 12px 12px 2px 12px;
  padding: 10px 12px;
  color: #e9edef;
  font-size: 13px;
  line-height: 1.4;
  box-shadow: 0 1px 2px rgba(0,0,0,0.3);
  position: relative;
  word-break: break-word;
}

.phone-bubble-header {
  font-weight: 800;
  font-size: 13.5px;
  margin-bottom: 4px;
  color: #ffffff;
}

.phone-bubble-footer {
  font-size: 11px;
  color: #8696a0;
  margin-top: 6px;
}

.phone-list-btn {
  margin-top: 10px;
  padding-top: 8px;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
  color: #53bdeb;
  font-weight: 600;
  font-size: 13px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}

/* ================= LIVE LOGS TERMINAL ================= */
.terminal-card {
  background: #04070c;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  overflow: hidden;
  font-family: var(--font-mono);
}

.terminal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  background: rgba(255, 255, 255, 0.03);
  border-bottom: 1px solid var(--border);
}

.terminal-dots {
  display: flex;
  gap: 6px;
}

.t-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
}
.t-dot.red { background: #ef4444; }
.t-dot.yellow { background: #f59e0b; }
.t-dot.green { background: #10b981; }

.terminal-body {
  padding: 12px 16px;
  font-size: 12px;
  line-height: 1.6;
  max-height: 380px;
  overflow-y: auto;
  color: #94a3b8;
}

.log-row {
  margin-bottom: 4px;
  word-break: break-all;
}

.log-time {
  color: var(--text-dim);
  margin-right: 8px;
}

.log-info { color: #38bdf8; }
.log-warn { color: #fbbf24; }
.log-error { color: #f87171; }

/* ================= MODAL ================= */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(4, 7, 13, 0.75);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 999;
  padding: 20px;
}

.modal-card {
  background: #0d1522;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: var(--radius-lg);
  padding: 24px;
  width: 100%;
  max-width: 520px;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.8), 0 0 30px rgba(37, 211, 102, 0.15);
  animation: slideUp 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

/* ================= TOAST ================= */
.toast {
  position: fixed;
  bottom: 30px;
  right: 30px;
  background: rgba(6, 12, 20, 0.95);
  backdrop-filter: blur(12px);
  color: #a7f3d0;
  border: 1px solid rgba(37, 211, 102, 0.4);
  padding: 12px 24px;
  border-radius: var(--radius-full);
  font-size: 13.5px;
  font-weight: 700;
  z-index: 1000;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.7), 0 0 20px var(--primary-glow);
  display: flex;
  align-items: center;
  gap: 10px;
  animation: slideUp 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

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

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

@keyframes pulse-glow {
  0% { transform: scale(0.95); opacity: 0.4; }
  100% { transform: scale(1.1); opacity: 0.8; }
}

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