/* Caso Ueno Bank — visualizador no estilo WhatsApp Web
   Tokens e componentes adaptados do MasterWhats (WDS). O Tailwind cuida do
   layout no HTML; aqui ficam os tokens, a cauda das bolhas e os painéis. */

:root {
  --WDS-accent: #1DAA61;
  --WDS-app-wash: #DBD8D4;
  --WDS-background-wash-plain: #FFFFFF;
  --WDS-surface-emphasized: #F7F5F3;
  --WDS-surface-highlight: rgba(194, 189, 184, .15);
  --WDS-content-default: #0A0A0A;
  --WDS-content-deemphasized: rgba(0, 0, 0, .6);
  --WDS-content-disabled: #BDBDBD;
  --WDS-content-external-link: #1B8755;
  --WDS-lines-divider: rgba(0, 0, 0, .1);
  --WDS-green-50: #F2FDF0;
  --WDS-green-700: #15603E;
  --WDS-warm-gray-75: #F7F5F3;
  --WDS-warm-gray-200: #DBD8D4;
  --WDS-bubble-incoming: #FFFFFF;
  --WDS-bubble-outgoing: #D9FDD3;
  --WDS-bubble-system: rgba(255, 255, 255, .9);
  --WDS-bubble-e2e: #FFF0D4;
  --WDS-chat-wallpaper: #F5F1EB;
}

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

html, body { height: 100%; overflow: hidden; }

body {
  margin: 0;
  font-family: Roboto, 'Segoe UI', 'Helvetica Neue', Helvetica, Arial, sans-serif;
  font-size: 14px;
  color: var(--WDS-content-default);
  background-color: var(--WDS-app-wash);
  -webkit-font-smoothing: antialiased;
  overflow-wrap: break-word;
}

button { font: inherit; }
[hidden] { display: none !important; }

::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-thumb { background: rgba(0, 0, 0, .2); border-radius: 3px; }
::-webkit-scrollbar-track { background: transparent; }
* { scrollbar-width: thin; scrollbar-color: rgba(0, 0, 0, .2) transparent; }

/* ── Nav rail ─────────────────────────────────── */
.nav-rail {
  width: 64px;
  min-width: 64px;
  background: var(--WDS-surface-emphasized);
  border-right: 1px solid var(--WDS-lines-divider);
}
.nav-rail-btn {
  display: flex; align-items: center; justify-content: center;
  width: 44px; height: 44px;
  border: 0; background: none; border-radius: 50%;
  color: var(--WDS-content-deemphasized);
  cursor: pointer; transition: background-color 120ms;
}
.nav-rail-btn:hover { background: var(--WDS-surface-highlight); }
.nav-rail-btn.active { color: var(--WDS-accent); background: var(--WDS-green-50); }

/* ── Sidebar / drawers (30%, 340–500px) ───────── */
.side-panel {
  display: flex; flex-direction: column;
  width: 30%; min-width: 340px; max-width: 500px;
  height: 100%;
  background: var(--WDS-background-wash-plain);
  border-right: 1px solid var(--WDS-lines-divider);
  overflow: hidden;
  flex-shrink: 0;
}
.panel-header {
  display: flex; align-items: center; gap: 20px;
  height: 59px; padding: 16px 24px; flex-shrink: 0;
  background: var(--WDS-background-wash-plain);
  border-bottom: 1px solid var(--WDS-lines-divider);
}
.panel-title { font-size: 16px; font-weight: 500; }
.panel-close {
  display: flex; align-items: center; padding: 4px; line-height: 1;
  border: 0; background: none; font-size: 18px; cursor: pointer;
  color: var(--WDS-content-deemphasized);
}
.panel-close:hover { color: var(--WDS-content-default); }
.panel-close .arrow { display: none; }
.panel-body { flex: 1; overflow-y: auto; }

/* Linha da conversa na barra lateral */
.chat-row {
  display: flex; align-items: center; gap: 14px;
  width: 100%; padding: 12px 16px;
  border: 0; border-bottom: 1px solid var(--WDS-lines-divider);
  background: none; text-align: left; cursor: pointer;
}
.chat-row:hover, .chat-row.active { background: var(--WDS-surface-highlight); }
.chat-row-avatar { width: 49px; height: 49px; border-radius: 50%; object-fit: cover; flex-shrink: 0; }
.avatar-initials {
  display: inline-flex; align-items: center; justify-content: center;
  background: #dfe5e7; color: #52616a; font-weight: 600;
}
.chat-row-avatar.avatar-initials { font-size: 20px; }
.chat-row-name { font-size: 17px; }
.chat-row-preview {
  font-size: 14px; color: var(--WDS-content-deemphasized);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

/* ── Configurações ("Sobre") ──────────────────── */
.settings-logo-section { display: flex; flex-direction: column; align-items: center; padding: 28px 24px 20px; }
.settings-logo-img {
  display: grid; place-items: center;
  width: 80px; height: 80px; margin-bottom: 12px;
  border-radius: 16px; background: var(--WDS-green-700); color: #fff;
  font-size: 30px; font-weight: 700; letter-spacing: -.02em;
}
.settings-logo-name { font-size: 22px; font-weight: 600; color: var(--WDS-accent); margin-bottom: 4px; }
.settings-logo-sub { font-size: 13px; color: var(--WDS-content-deemphasized); text-align: center; }
.contact-info-divider { height: 10px; background: var(--WDS-surface-emphasized); }
.profile-sections { padding: 16px 24px 32px; }
.profile-section { margin-bottom: 20px; }
.profile-section-title { font-size: 16px; font-weight: 600; margin-bottom: 10px; }
.profile-section-text { font-size: 14px; line-height: 1.65; margin: 0 0 12px; }
.profile-section-text a, .profile-sources a { color: var(--WDS-green-700); text-decoration: none; font-weight: 500; }
.profile-section-text a:hover, .profile-sources a:hover { text-decoration: underline; }
.profile-sources { margin-top: 24px; font-size: 13px; }
.profile-sources summary { cursor: pointer; padding: 8px 0; font-weight: 500; color: var(--WDS-content-deemphasized); }
.profile-sources ul { list-style: none; margin: 0; padding: 8px 0; }
.profile-sources li { padding: 4px 0; font-size: 12.5px; }
.profile-credits {
  margin-top: 24px; padding: 16px 0;
  border-top: 1px solid var(--WDS-lines-divider);
  font-size: 12px; line-height: 1.5; color: var(--WDS-content-deemphasized);
}

/* ── Área principal e papel de parede ─────────── */
.main-area {
  flex: 1; display: flex; flex-direction: row; min-width: 0; position: relative;
  background-color: var(--WDS-chat-wallpaper);
}
.main-area::before {
  content: ''; position: absolute; inset: 0; z-index: 0; pointer-events: none;
  background: url('../assets/whatsapp-background.webp') repeat;
  background-size: 550px; opacity: .12;
}
.chat-view { display: flex; flex-direction: column; flex: 1; min-width: 0; min-height: 0; height: 100%; position: relative; z-index: 1; }

/* ── Cabeçalho do chat ────────────────────────── */
.chat-header {
  display: flex; align-items: center; gap: 10px;
  height: 59px; padding: 10px 16px; flex-shrink: 0; position: relative; z-index: 2;
  background: var(--WDS-background-wash-plain);
  border-bottom: 1px solid var(--WDS-lines-divider);
}
.chat-header-back {
  display: none; padding: 4px; border: 0; border-radius: 50%; background: none; cursor: pointer;
  color: var(--WDS-content-deemphasized);
}
.chat-header-avatar { width: 40px; height: 40px; border-radius: 50%; object-fit: cover; flex-shrink: 0; cursor: pointer; }
.chat-header-avatar.avatar-initials { font-size: 17px; }
.chat-header-name { font-size: 16px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-header-info { font-size: 12.5px; color: var(--WDS-content-deemphasized); }
.chat-header-btn {
  display: flex; padding: 8px; border: 0; border-radius: 50%; background: none; cursor: pointer;
  color: var(--WDS-content-deemphasized); transition: background-color 120ms;
}
.chat-header-btn:hover { background: var(--WDS-surface-highlight); }

/* ── Mensagens ────────────────────────────────── */
.chat-messages { flex: 1; min-height: 0; overflow-y: auto; padding: 8px 48px 8px 63px; position: relative; z-index: 1; }
.chat-date-badge, .chat-msg-system {
  display: block; width: fit-content; max-width: 80%;
  margin: 10px auto; padding: 6px 12px;
  font-size: 12.5px; line-height: 1.4; text-align: center;
  color: var(--WDS-content-deemphasized);
  background: var(--WDS-bubble-system);
  border-radius: 8px; box-shadow: 0 1px 1px rgba(0, 0, 0, .06);
}
.chat-msg-system.warning { background: var(--WDS-bubble-e2e); }

.chat-msg-row { display: flex; margin-bottom: 2px; }
.chat-msg-row.incoming { justify-content: flex-start; }
.chat-msg-row.outgoing { justify-content: flex-end; }
.chat-msg-row + .chat-msg-row.incoming, .chat-msg-row + .chat-msg-row.outgoing { margin-top: 6px; }

.chat-msg-bubble {
  position: relative; max-width: 65%; min-width: 80px;
  padding: 6px 12px 8px 9px; border-radius: 8px;
  font-size: 14.2px; line-height: 1.35;
  box-shadow: 0 1px .5px rgba(0, 0, 0, .13);
}
.chat-msg-bubble.incoming { background: var(--WDS-bubble-incoming); border-top-left-radius: 0; }
.chat-msg-bubble.outgoing { background: var(--WDS-bubble-outgoing); border-top-right-radius: 0; }
.chat-msg-bubble::after { content: ''; display: table; clear: both; }

.chat-msg-tail { position: absolute; top: 0; width: 8px; height: 13px; }
.chat-msg-bubble.incoming .chat-msg-tail { left: -8px; }
.chat-msg-bubble.incoming .chat-msg-tail::before {
  content: ''; position: absolute; top: 0; left: 0;
  border-right: 8px solid var(--WDS-bubble-incoming); border-bottom: 13px solid transparent;
}
.chat-msg-bubble.outgoing .chat-msg-tail { right: -8px; }
.chat-msg-bubble.outgoing .chat-msg-tail::before {
  content: ''; position: absolute; top: 0; right: 0;
  border-left: 8px solid var(--WDS-bubble-outgoing); border-bottom: 13px solid transparent;
}

.chat-msg-meta {
  float: right; margin: 6px 2px -4px 12px;
  font-size: 11px; white-space: nowrap; color: var(--WDS-content-deemphasized);
}
.chat-msg-transcription-note { font-size: 12px; color: var(--WDS-content-deemphasized); }
.chat-attachment { display: flex; align-items: center; gap: 10px; min-width: 220px; }
.chat-attachment-icon {
  display: grid; place-items: center; width: 42px; height: 48px; flex-shrink: 0;
  border-radius: 4px; background: #f3f4f6; color: #70777d; font-size: 11px; font-weight: 700;
}
.chat-attachment strong, .chat-attachment small { display: block; }
.chat-attachment strong { font-weight: 500; }
.chat-attachment small { margin-top: 3px; color: var(--WDS-content-deemphasized); }

/* ── Compositor (somente leitura) ─────────────── */
.chat-composer {
  display: flex; align-items: center; gap: 12px;
  min-height: 62px; padding: 10px 16px; flex-shrink: 0; position: relative; z-index: 2;
  background: var(--WDS-surface-emphasized);
}
.chat-composer-input {
  flex: 1; padding: 10px 14px; border: 0; border-radius: 8px;
  background: #fff; color: var(--WDS-content-deemphasized); font-size: 15px;
  cursor: not-allowed;
}

/* ── Info do contato (foto de perfil) ─────────── */
.contact-info-drawer {
  display: none; flex-direction: column;
  width: 30%; min-width: 340px; max-width: 420px;
  height: 100%; position: relative; z-index: 3; flex-shrink: 0;
  background: var(--WDS-background-wash-plain);
  border-left: 1px solid var(--WDS-lines-divider);
  overflow: hidden;
}
.contact-info-drawer.open { display: flex; }
.contact-info-profile { display: flex; flex-direction: column; align-items: center; padding: 28px 24px 20px; }
.contact-info-avatar { width: 120px; height: 120px; margin-bottom: 16px; border-radius: 50%; object-fit: cover; }
.contact-info-avatar.avatar-initials { font-size: 40px; }
.contact-info-name { font-size: 21px; font-weight: 500; margin-bottom: 4px; }
.contact-info-phone { font-size: 14px; color: var(--WDS-content-deemphasized); }
.profile-field { padding: 14px 24px; border-bottom: 1px solid var(--WDS-lines-divider); }
.profile-field-label { margin-bottom: 4px; font-size: 13px; color: var(--WDS-content-deemphasized); }
.profile-field-value { font-size: 16px; }

/* ── Responsivo ───────────────────────────────── */
@media (max-width: 900px) {
  .nav-rail.flex { display: none; }
  .side-panel { width: 100%; max-width: none; min-width: 0; position: absolute; inset: 0; z-index: 5; }
  .main-area { width: 100%; }
  .chat-header-back { display: flex; }
  .panel-close .x { display: none; }
  .panel-close .arrow { display: inline; }
  .chat-messages { padding: 8px 16px; }
  .chat-msg-bubble { max-width: 85%; }
  .contact-info-drawer { position: absolute; inset: 0; width: 100%; max-width: none; min-width: 0; }
  body.chat-open #sidebar { display: none; }
}
@media (max-width: 600px) {
  .chat-messages { padding: 8px 12px; }
}
