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

:root {
  --wa-green: #00a884;
  --wa-dark: #111b21;
  --wa-panel: #202c33;
  --wa-input: #2a3942;
  --wa-bubble-out: #005c4b;
  --wa-bubble-in: #202c33;
  --wa-text: #e9edef;
  --wa-muted: #8696a0;
  --call-green: #25d366;
  --hangup-red: #e74c3c;
  --font: "Segoe UI", system-ui, -apple-system, sans-serif;
}

html, body {
  height: 100%;
  font-family: var(--font);
  background: #0b141a;
  color: var(--wa-text);
}

.app {
  display: flex;
  height: 100vh;
  max-width: 1200px;
  margin: 0 auto;
  background: var(--wa-dark);
  box-shadow: 0 0 40px rgba(0, 0, 0, 0.5);
}

.sidebar {
  width: 340px;
  min-width: 300px;
  background: var(--wa-panel);
  border-right: 1px solid #2f3b43;
  display: flex;
  flex-direction: column;
}

.sidebar-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px;
  background: var(--wa-input);
}

.avatar {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: var(--wa-green);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 1rem;
  flex-shrink: 0;
}

.avatar.small {
  width: 40px;
  height: 40px;
  font-size: 1.2rem;
  background: #3b4a54;
}

.sidebar-header h1 {
  font-size: 1rem;
  font-weight: 600;
}

.status {
  font-size: 0.8rem;
  color: var(--wa-muted);
  margin-top: 2px;
}

.status.connected { color: var(--call-green); }
.status.calling { color: #f39c12; }
.status.error { color: var(--hangup-red); }

.dial-section {
  padding: 20px 16px;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.dial-section label {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--wa-muted);
}

.phone-display input {
  width: 100%;
  background: var(--wa-input);
  border: none;
  border-radius: 8px;
  padding: 12px 14px;
  color: var(--wa-text);
  font-size: 1.25rem;
  letter-spacing: 0.05em;
  outline: none;
}

.phone-display input:focus {
  box-shadow: 0 0 0 2px var(--wa-green);
}

.keypad {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin-top: 8px;
}

.keypad button {
  background: #2a3942;
  border: none;
  border-radius: 50%;
  width: 64px;
  height: 64px;
  margin: 0 auto;
  color: var(--wa-text);
  font-size: 1.5rem;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  line-height: 1;
  transition: background 0.15s;
}

.keypad button span {
  font-size: 0.55rem;
  color: var(--wa-muted);
  letter-spacing: 0.08em;
  margin-top: 2px;
}

.keypad button:hover { background: #3b4a54; }
.keypad button:active { background: var(--wa-green); }

.call-actions {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 20px;
  margin-top: auto;
  padding-top: 16px;
}

.btn-call,
.btn-hangup {
  width: 60px;
  height: 60px;
  border-radius: 50%;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  transition: transform 0.15s, opacity 0.15s;
}

.btn-call {
  background: var(--call-green);
}

.btn-hangup {
  background: var(--hangup-red);
}

.btn-call:hover,
.btn-hangup:hover { transform: scale(1.06); }

.btn-backspace {
  background: transparent;
  border: 1px solid #3b4a54;
  color: var(--wa-muted);
  border-radius: 8px;
  padding: 10px 14px;
  cursor: pointer;
  font-size: 1.1rem;
}

.btn-backspace:hover { background: #2a3942; }

.hidden { display: none !important; }

.chat {
  flex: 1;
  display: flex;
  flex-direction: column;
  background: #0b141a url("data:image/svg+xml,%3Csvg width='60' height='60' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M0 0h60v60H0z' fill='%230b141a'/%3E%3Cpath d='M30 0v60M0 30h60' stroke='%23111b21' stroke-width='0.5'/%3E%3C/svg%3E");
}

.chat-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 16px;
  background: var(--wa-panel);
  border-bottom: 1px solid #2f3b43;
}

.chat-header h2 {
  font-size: 1rem;
  font-weight: 600;
}

.chat-header p {
  font-size: 0.8rem;
  color: var(--wa-muted);
}

.messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px 8%;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.system-msg {
  align-self: center;
  background: rgba(255, 255, 255, 0.06);
  color: var(--wa-muted);
  font-size: 0.8rem;
  padding: 8px 14px;
  border-radius: 8px;
  text-align: center;
  max-width: 420px;
  margin-bottom: 12px;
}

.bubble {
  max-width: 65%;
  padding: 8px 12px 6px;
  border-radius: 8px;
  position: relative;
  animation: fadeIn 0.2s ease;
}

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

.bubble.outgoing {
  align-self: flex-end;
  background: var(--wa-bubble-out);
  border-top-right-radius: 0;
}

.bubble.incoming {
  align-self: flex-start;
  background: var(--wa-bubble-in);
  border-top-left-radius: 0;
}

.bubble .text {
  font-size: 0.95rem;
  line-height: 1.4;
  word-break: break-word;
}

.bubble .translation {
  font-size: 0.75rem;
  color: var(--wa-muted);
  margin-top: 4px;
  font-style: italic;
}

.bubble .meta {
  font-size: 0.65rem;
  color: rgba(255, 255, 255, 0.45);
  text-align: right;
  margin-top: 4px;
}

.chat-input {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 16px;
  background: var(--wa-panel);
}

.chat-input input {
  flex: 1;
  background: var(--wa-input);
  border: none;
  border-radius: 24px;
  padding: 12px 18px;
  color: var(--wa-text);
  font-size: 0.95rem;
  outline: none;
}

.chat-input input:disabled {
  opacity: 0.5;
}

.chat-input input:focus {
  box-shadow: 0 0 0 2px var(--wa-green);
}

#btn-send {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: none;
  background: var(--wa-green);
  color: white;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: opacity 0.15s;
}

#btn-send:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

#btn-send:not(:disabled):hover {
  filter: brightness(1.1);
}

@media (max-width: 768px) {
  .app { flex-direction: column; }
  .sidebar { width: 100%; min-width: unset; max-height: 45vh; }
}
