﻿:root {
  color-scheme: light;
  --bg: #d1d7db;
  --card: #ffffff;
  --ink: #1b1a17;
  --muted: #5a544b;
  --accent: #00a884;
  --accent-dark: #008069;
  --border: #d7d9dc;
  --wa-bg: #efeae2;
  --wa-sidebar: #f0f2f5;
  --wa-border: #d1d7db;
  --wa-incoming: #ffffff;
  --wa-outgoing: #d9fdd3;
  --topbar-height: 64px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: "Segoe UI", Tahoma, sans-serif;
  color: var(--ink);
  background: var(--bg);
}

header {
  padding: 12px 20px;
  background: var(--wa-sidebar);
  border-bottom: 1px solid var(--wa-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: var(--topbar-height);
}

.brand {
  font-size: 20px;
  font-weight: 700;
  letter-spacing: 0.3px;
}

.subtitle {
  color: var(--muted);
  margin-top: 2px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.version {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  background: #e3f4ef;
  color: #0b5b4b;
  font-size: 12px;
  font-weight: 700;
}

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

.ghost {
  background: transparent;
  color: var(--muted);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 6px 12px;
  font-weight: 600;
  text-decoration: none;
}

.ghost:hover {
  background: #e4e6e8;
  color: var(--ink);
}

main.layout {
  max-width: 1200px;
  margin: 0 auto;
  padding: 16px 24px 32px;
  display: grid;
  gap: 24px;
}

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 18px 20px;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.08);
}

h1 {
  font-size: 18px;
  margin: 0 0 10px;
}

label {
  display: grid;
  gap: 6px;
  margin: 12px 0;
  font-weight: 600;
}

input, textarea, select {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  font-size: 14px;
  background: #fff;
}

button {
  margin-top: 8px;
  padding: 10px 16px;
  background: var(--accent);
  color: white;
  border: none;
  border-radius: 12px;
  font-weight: 700;
  cursor: pointer;
}

button:hover {
  background: var(--accent-dark);
}

.hint {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.result {
  margin-top: 12px;
  padding: 12px;
  background: #1c1c1c;
  color: #f5f5f5;
  border-radius: 10px;
  min-height: 60px;
  overflow: auto;
}

.error {
  color: #b8382a;
  font-weight: 700;
  min-height: 20px;
}

.footer {
  display: flex;
  gap: 10px;
  justify-content: center;
  padding: 16px 20px 24px;
  color: var(--muted);
}

.footer a {
  color: var(--accent-dark);
  text-decoration: none;
}

.dot { opacity: 0.6; }

.login-screen {
  min-height: 70vh;
  display: grid;
  place-items: center;
  padding: 16px 24px 40px;
}

.login-card {
  width: min(420px, 100%);
}

.tools-grid {
  display: grid;
  gap: 16px;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
}

.wa-shell {
  display: grid;
  grid-template-columns: 320px 1fr;
  background: #fff;
  border: 1px solid var(--wa-border);
  border-radius: 12px;
  overflow: hidden;
  min-height: 70vh;
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.12);
}

.wa-sidebar {
  background: var(--wa-sidebar);
  border-right: 1px solid var(--wa-border);
  display: grid;
  grid-template-rows: auto auto 1fr;
}

.wa-sidebar-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
}

.wa-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.icon-btn {
  background: #e6e8ea;
  color: #2b2b2b;
  padding: 6px 10px;
  border-radius: 999px;
  border: none;
  font-size: 12px;
  font-weight: 700;
}

.icon-btn:hover {
  background: #d6d9dc;
}

.wa-search {
  padding: 8px 16px 12px;
}

.wa-search input {
  border-radius: 999px;
  background: #fff;
}

.conversation-list {
  padding: 0 8px 12px;
  display: grid;
  gap: 6px;
  overflow: auto;
}

.conversation-item {
  display: grid;
  grid-template-columns: 44px 1fr;
  gap: 10px;
  align-items: center;
  padding: 10px 12px;
  border-radius: 10px;
  cursor: pointer;
  background: transparent;
  transition: background 0.12s ease;
}

.conversation-item:hover,
.conversation-item.active {
  background: #e9edef;
}

.conversation-body {
  display: grid;
  gap: 4px;
}

.conversation-row {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  font-weight: 700;
}

.conversation-preview {
  color: #596066;
  font-size: 13px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  display: flex;
  align-items: center;
  gap: 6px;
}

.conversation-time {
  font-size: 12px;
  color: #798086;
}

.avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: #cdd1d4;
  display: grid;
  place-items: center;
  font-weight: 700;
  color: #2c2c2c;
}

.wa-chat {
  background: var(--wa-bg);
  display: grid;
  grid-template-rows: auto 1fr auto;
  position: relative;
}

.wa-chat::before {
  content: "";
  position: absolute;
  inset: 0;
  background-image: url("data:image/svg+xml,%3Csvg width='120' height='120' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='%23d7cec5' fill-opacity='0.25'%3E%3Ccircle cx='20' cy='20' r='2'/%3E%3Ccircle cx='60' cy='40' r='2'/%3E%3Ccircle cx='90' cy='80' r='2'/%3E%3Cpath d='M10 70h10v10H10z'/%3E%3Cpath d='M70 10h12v12H70z'/%3E%3C/g%3E%3C/svg%3E");
  opacity: 0.5;
  pointer-events: none;
}

.wa-chat-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 16px;
  background: #f0f2f5;
  border-bottom: 1px solid var(--wa-border);
  position: relative;
  z-index: 1;
}

.chat-title {
  display: flex;
  align-items: center;
  gap: 12px;
}

.chat-header {
  font-weight: 700;
}

.chat-subtitle {
  color: #7a8087;
  font-size: 12px;
}

.chat-history {
  position: relative;
  z-index: 1;
  padding: 12px 20px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  overflow: auto;
}

.chat-bubble {
  padding: 8px 10px;
  border-radius: 10px 10px 10px 2px;
  background: var(--wa-incoming);
  border: none;
  max-width: 70%;
  position: relative;
  box-shadow: 0 1px 1px rgba(0, 0, 0, 0.08);
  font-size: 14px;
  line-height: 1.4;
}

.chat-bubble.incoming {
  justify-self: start;
}

.chat-bubble.outgoing {
  justify-self: end;
  background: var(--wa-outgoing);
  border-radius: 10px 10px 2px 10px;
}

.chat-bubble-meta {
  margin-top: 6px;
  color: #7a8087;
  font-size: 11px;
  text-align: right;
  display: flex;
  justify-content: flex-end;
  gap: 6px;
}

.status {
  font-size: 12px;
}

.status-sent {
  color: #7a8087;
}

.status-delivered {
  color: #7a8087;
}

.status-read {
  color: #1fa7e1;
}

.chat-composer {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  padding: 12px 16px;
  background: #f0f2f5;
  border-top: 1px solid var(--wa-border);
  align-items: center;
}

.chat-composer input {
  border-radius: 999px;
  background: #fff;
}

.chat-composer button {
  border-radius: 999px;
  padding: 8px 16px;
  margin-top: 0;
}

.chat-error {
  grid-column: 1 / -1;
  color: #b8382a;
  font-size: 12px;
}

body.app-page {
  background: var(--wa-bg);
}

body.app-page main.layout {
  max-width: none;
  padding: 0;
  min-height: calc(100vh - var(--topbar-height));
}

body.app-page .wa-shell {
  min-height: calc(100vh - var(--topbar-height));
  height: calc(100vh - var(--topbar-height));
  border-radius: 0;
  border-left: none;
  border-right: none;
}

body.app-page .footer {
  display: none;
}

@media (max-width: 980px) {
  header {
    flex-direction: column;
    align-items: flex-start;
  }

  .topbar-actions {
    width: 100%;
    justify-content: flex-end;
  }

  .wa-shell {
    grid-template-columns: 1fr;
    min-height: 70vh;
  }

  .wa-sidebar {
    border-right: none;
    border-bottom: 1px solid var(--wa-border);
  }
}
