@import url('https://fonts.googleapis.com/css2?family=Sora:wght@300;400;500;600;700&family=Space+Grotesk:wght@400;500;600;700&family=IBM+Plex+Mono:wght@400;500&display=swap');

:root {
  --bg: #f3f6f7;
  --bg-deep: #e2ecee;
  --ink: #0f1f22;
  --ink-soft: rgba(15, 31, 34, 0.72);
  --muted: rgba(15, 31, 34, 0.55);
  --accent: #38a289;
  --accent-strong: #276f88;
  --accent-glow: rgba(56, 162, 137, 0.28);
  --highlight: #a7ba24;
  --highlight-glow: rgba(167, 186, 36, 0.22);
  --brand-green: #38a289;
  --brand-olive: #a7ba24;
  --brand-amber: #a5670e;
  --brand-red: #661e3a;
  --brand-blue: #276f88;
  --brand-cyan: #3e2a4e;
  --card: rgba(255, 255, 255, 0.9);
  --card-strong: rgba(255, 255, 255, 0.96);
  --border: rgba(47, 124, 134, 0.18);
  --shadow: 0 24px 60px rgba(15, 60, 64, 0.18);
  --radius: 22px;
  --mono: 'IBM Plex Mono', monospace;
  --sans: 'Sora', sans-serif;
  --display: 'Space Grotesk', sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: var(--sans);
  color: var(--ink);
  background:
    linear-gradient(
      90deg,
      rgba(56, 162, 137, 0.45) 0%,
      rgba(167, 186, 36, 0.45) 22%,
      rgba(165, 103, 14, 0.45) 42%,
      rgba(102, 30, 58, 0.45) 60%,
      rgba(39, 111, 136, 0.45) 80%,
      rgba(62, 42, 78, 0.45) 100%
    ),
    linear-gradient(140deg, #f6fbfb, #e6eff1 55%, #d4e1e3);
  min-height: 100vh;
}

body::before {
  content: '';
  position: fixed;
  inset: 0;
  background-image:
    radial-gradient(circle at 12% 22%, rgba(56, 162, 137, 0.38), transparent 50%),
    radial-gradient(circle at 40% 18%, rgba(165, 103, 14, 0.3), transparent 45%),
    radial-gradient(circle at 60% 22%, rgba(102, 30, 58, 0.28), transparent 50%),
    radial-gradient(circle at 82% 18%, rgba(39, 111, 136, 0.3), transparent 55%),
    radial-gradient(circle at 72% 82%, rgba(62, 42, 78, 0.28), transparent 55%);
  pointer-events: none;
  z-index: -2;
}

body::after {
  content: '';
  position: fixed;
  inset: 0;
  background-image:
    linear-gradient(120deg, rgba(255, 255, 255, 0.4), transparent 30%),
    linear-gradient(300deg, rgba(255, 255, 255, 0.25), transparent 45%);
  pointer-events: none;
  z-index: -1;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 36px;
  background: rgba(255, 255, 255, 0.82);
  color: var(--ink);
  backdrop-filter: blur(18px);
  border-bottom: 1px solid rgba(47, 124, 134, 0.18);
  position: sticky;
  top: 0;
  z-index: 10;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  font-weight: 600;
  letter-spacing: 0.6px;
  font-family: var(--display);
}

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

.brand-logo {
  height: 44px;
  width: auto;
  object-fit: contain;
  background: rgba(255, 255, 255, 0.95);
  padding: 6px 8px;
  border-radius: 12px;
  border: 1px solid rgba(47, 124, 134, 0.2);
  box-shadow: 0 10px 18px rgba(15, 60, 64, 0.16);
}

.brand-logo.umts {
  height: 52px;
}

.brand-logo.labs {
  height: 46px;
}

.brand-text {
  display: flex;
  flex-direction: column;
}

.brand span {
  font-size: 0.82rem;
  color: var(--ink-soft);
}

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

.user-pill {
  padding: 8px 14px;
  border-radius: 999px;
  background: rgba(47, 124, 134, 0.12);
  border: 1px solid rgba(47, 124, 134, 0.18);
  font-size: 0.9rem;
}

.dashboard {
  display: grid;
  grid-template-columns: repeat(12, minmax(0, 1fr));
  gap: 22px;
  padding: 28px 36px 56px;
}

.card {
  background: var(--card);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  padding: 22px 24px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(22px) saturate(140%);
  position: relative;
  overflow: hidden;
  animation: rise 0.6s ease both;
  animation-delay: var(--delay, 0s);
}

.card::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(145deg, rgba(90, 166, 173, 0.08), transparent 55%);
  pointer-events: none;
}

.card h2 {
  margin: 0 0 12px 0;
  font-size: 1.1rem;
  font-family: var(--display);
  letter-spacing: 0.2px;
}

.card p {
  margin: 0 0 12px 0;
  color: var(--muted);
  line-height: 1.6;
}

.summary-card {
  grid-column: span 5;
}

.whatsapp-card {
  grid-column: span 7;
}

.chats-card,
.automation-card,
.admin-card {
  grid-column: 1 / -1;
}

.status-grid {
  display: grid;
  gap: 10px;
}

.status-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.95rem;
  color: var(--ink-soft);
}

.status-row strong {
  color: var(--ink);
}

.qr-layout {
  display: grid;
  gap: 18px;
  grid-template-columns: 220px 1fr;
  align-items: center;
}

.qr-box {
  width: 220px;
  height: 220px;
  background: var(--card-strong);
  border-radius: 18px;
  border: 1px solid var(--border);
  display: grid;
  place-items: center;
  padding: 10px;
}

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

.toggle {
  display: flex;
  align-items: center;
  gap: 12px;
  font-weight: 500;
  color: var(--ink);
}

.toggle input {
  display: none;
}

.toggle span {
  width: 46px;
  height: 26px;
  background: rgba(47, 124, 134, 0.18);
  border-radius: 999px;
  position: relative;
  transition: background 0.2s ease;
}

.toggle span::after {
  content: '';
  width: 20px;
  height: 20px;
  background: #ffffff;
  border-radius: 50%;
  position: absolute;
  top: 3px;
  left: 3px;
  transition: transform 0.2s ease, background 0.2s ease;
  box-shadow: 0 4px 10px rgba(18, 60, 34, 0.2);
}

.toggle input:checked + span {
  background: linear-gradient(135deg, var(--accent), var(--accent-strong));
}

.toggle input:checked + span::after {
  transform: translateX(20px);
  background: #ffffff;
}

.controls {
  display: grid;
  gap: 16px;
}

textarea,
input,
select {
  width: 100%;
  border-radius: 14px;
  border: 1px solid rgba(47, 124, 134, 0.22);
  padding: 12px 14px;
  font-family: var(--sans);
  font-size: 0.95rem;
  color: var(--ink);
  background: rgba(255, 255, 255, 0.95);
  outline: none;
  transition: border 0.2s ease, box-shadow 0.2s ease;
}

textarea:focus,
input:focus,
select:focus {
  border-color: rgba(47, 124, 134, 0.7);
  box-shadow: 0 0 0 3px rgba(47, 124, 134, 0.2);
}

textarea {
  min-height: 160px;
  max-height: 220px;
  resize: none;
  overflow-y: auto;
}

label {
  font-weight: 500;
  color: var(--ink-soft);
}

.btn {
  border: none;
  border-radius: 14px;
  padding: 10px 18px;
  font-weight: 600;
  cursor: pointer;
  font-family: var(--sans);
  transition: transform 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
}

.btn.primary {
  background: linear-gradient(135deg, var(--accent), var(--accent-strong));
  color: #ffffff;
  box-shadow: 0 12px 24px rgba(90, 166, 173, 0.28);
}

.btn.primary:hover {
  transform: translateY(-1px);
  box-shadow: 0 18px 32px rgba(90, 166, 173, 0.35);
}

.btn.secondary {
  background: rgba(47, 124, 134, 0.12);
  color: var(--ink);
  border: 1px solid rgba(47, 124, 134, 0.2);
}

.btn.ghost {
  background: rgba(47, 124, 134, 0.08);
  color: var(--ink);
  border: 1px solid rgba(47, 124, 134, 0.18);
}

.btn.danger {
  background: rgba(216, 85, 100, 0.12);
  color: #ff9aa7;
  border: 1px solid rgba(216, 85, 100, 0.35);
}

.btn-group {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  border-radius: 999px;
  font-size: 0.8rem;
  background: rgba(47, 124, 134, 0.12);
  color: var(--ink-soft);
}

.badge.success {
  background: rgba(90, 166, 173, 0.2);
  color: #0f4d55;
}

.badge.warn {
  background: rgba(216, 85, 100, 0.2);
  color: #ff9aa7;
}

.chat-workspace {
  --chat-height: 520px;
  display: grid;
  grid-template-columns: 320px minmax(0, 1fr);
  gap: 18px;
  height: var(--chat-height);
}

.chat-list {
  border: 1px solid var(--border);
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.7);
  padding: 10px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  height: 100%;
  overflow-y: auto;
}

.chat-item {
  padding: 12px 14px;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.92);
  border: 1px solid transparent;
  cursor: pointer;
  transition: border 0.2s ease, box-shadow 0.2s ease, transform 0.2s ease;
}

.chat-item.active {
  border-color: rgba(90, 166, 173, 0.55);
  box-shadow: 0 10px 20px rgba(90, 166, 173, 0.2);
  transform: translateY(-1px);
}

.chat-item h4 {
  margin: 0 0 6px 0;
  font-size: 0.95rem;
  color: var(--ink);
}

.chat-item p {
  margin: 0;
  font-size: 0.82rem;
  color: var(--muted);
  line-height: 1.4;
}

.chat-panel {
  border: 1px solid var(--border);
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.85);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  height: 100%;
}

.chat-header {
  padding: 14px 18px;
  border-bottom: 1px solid rgba(47, 124, 134, 0.12);
  background: rgba(236, 248, 249, 0.9);
}

.chat-header h3 {
  margin: 0;
  font-size: 1rem;
  font-family: var(--display);
}

.chat-messages {
  flex: 1;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  overflow-y: auto;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.9) 0%, rgba(232, 248, 238, 0.9) 100%);
}

.chat-input {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 12px;
  padding: 12px 16px 16px;
  border-top: 1px solid rgba(47, 124, 134, 0.12);
  background: rgba(232, 246, 248, 0.95);
}

.chat-input textarea {
  min-height: 48px;
  max-height: 96px;
  resize: none;
}

.message {
  max-width: 72%;
  padding: 10px 14px;
  border-radius: 14px;
  font-size: 0.9rem;
  line-height: 1.5;
  box-shadow: 0 8px 16px rgba(18, 60, 34, 0.18);
}

.message.incoming {
  background: #ffffff;
  border: 1px solid rgba(47, 124, 134, 0.15);
  align-self: flex-start;
}

.message.outgoing {
  background: rgba(90, 166, 173, 0.18);
  border: 1px solid rgba(90, 166, 173, 0.35);
  align-self: flex-end;
}

.message .time {
  display: block;
  margin-top: 6px;
  font-size: 0.72rem;
  color: var(--muted);
  font-family: var(--mono);
}

.chat-empty {
  color: var(--muted);
  font-size: 0.9rem;
  text-align: center;
  margin-top: 20px;
}

.automation-card {
  display: grid;
  gap: 18px;
}

.automation-header {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  align-items: flex-start;
}

.automation-actions {
  display: grid;
  gap: 8px;
  min-width: 220px;
}

.automation-body {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 18px;
  align-items: end;
}

.prompt-panel {
  display: grid;
  gap: 8px;
}

.prompt-actions {
  display: flex;
  justify-content: flex-end;
}

.admin-panel {
  display: grid;
  gap: 16px;
}

.admin-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.admin-header .helper {
  text-align: right;
  max-width: 45%;
  word-break: break-word;
}

.admin-grid {
  display: grid;
  gap: 14px;
}

.admin-form {
  display: grid;
  grid-template-columns: minmax(160px, 1fr) minmax(200px, 1fr) minmax(200px, 1fr) auto;
  gap: 16px;
  align-items: end;
}

.admin-form button {
  height: 44px;
}

.admin-table {
  border: 1px solid var(--border);
  border-radius: 18px;
  overflow: hidden;
  background: rgba(255, 255, 255, 0.85);
  max-height: 420px;
  overflow: auto;
}

.table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.92rem;
  min-width: 720px;
}

.table-input {
  width: 100%;
  min-width: 180px;
  padding: 8px 10px;
  border-radius: 10px;
  border: 1px solid rgba(47, 124, 134, 0.25);
  background: rgba(255, 255, 255, 0.95);
  color: var(--ink);
  font-size: 0.85rem;
}

.table th,
.table td {
  padding: 12px 12px;
  border-bottom: 1px solid rgba(47, 124, 134, 0.12);
  text-align: left;
}

.table th {
  color: var(--ink-soft);
  font-weight: 600;
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  background: rgba(47, 124, 134, 0.08);
}

.table td {
  color: var(--ink);
}

.toast {
  position: fixed;
  bottom: 28px;
  right: 28px;
  padding: 14px 18px;
  border-radius: 14px;
  background: rgba(47, 124, 134, 0.95);
  color: #ffffff;
  opacity: 0;
  transform: translateY(10px);
  transition: opacity 0.2s ease, transform 0.2s ease;
  z-index: 20;
}

.toast.show {
  opacity: 1;
  transform: translateY(0);
}

.auth-body {
  display: grid;
  place-items: center;
  padding: 40px 20px;
}

.auth-shell {
  max-width: 440px;
  width: 100%;
  background: var(--card);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  padding: 32px;
  display: grid;
  gap: 16px;
  backdrop-filter: blur(18px);
}

.auth-shell .brand {
  flex-direction: column;
  gap: 10px;
  text-align: center;
}

.auth-shell .brand-text {
  align-items: center;
}

.auth-shell .brand-logos {
  justify-content: center;
}

.auth-actions {
  display: flex;
  justify-content: flex-end;
}

.auth-title {
  margin: 0;
  font-size: 1.6rem;
  font-family: var(--display);
}

.auth-sub {
  color: var(--muted);
  margin: 0;
}

.auth-footer {
  font-size: 0.85rem;
  color: var(--muted);
}

.helper {
  font-size: 0.82rem;
  color: var(--muted);
}

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

@media (max-width: 1200px) {
  .summary-card,
  .whatsapp-card {
    grid-column: 1 / -1;
  }

  .automation-body {
    grid-template-columns: 1fr;
  }

  .prompt-actions {
    justify-content: flex-start;
  }
}

@media (max-width: 900px) {
  .dashboard {
    grid-template-columns: 1fr;
    padding: 22px 20px 40px;
  }

  .qr-layout {
    grid-template-columns: 1fr;
    justify-items: center;
  }

  .chat-workspace {
    grid-template-columns: 1fr;
    height: auto;
  }

  .chat-list,
  .chat-panel {
    height: auto;
    max-height: 360px;
  }

  .topbar {
    flex-direction: column;
    align-items: flex-start;
    gap: 12px;
  }

  .brand {
    align-items: flex-start;
  }

  .admin-form {
    grid-template-columns: 1fr;
  }

  .automation-header {
    flex-direction: column;
  }
}

::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

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

::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.2);
  border-radius: 999px;
}

::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.35);
}
