@import url('https://fonts.googleapis.com/css2?family=Poppins:wght@400;500;600;700&display=swap');

:root {
  --navy: #0B2242;
  --navy-2: #15365f;
  --gold: #F7AC23;
  --gold-light: #fff5e3;
  --gray: #A6A6A6;
  --dark-gray: #404040;
  --muted: #8993a2;
  --line: #edf0f4;
  --background: #F5F7FA;
  --white: #FFFFFF;
  --green: #35b779;
  --shadow: 0 12px 35px rgba(11, 34, 66, .07);
}
* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body { background: var(--background); color: var(--navy); font-family: 'Poppins', sans-serif; font-size: 14px; }
button, input, textarea { font: inherit; }
button { cursor: pointer; }
.app-shell { min-height: 100vh; display: flex; }
.sidebar { width: 238px; min-width: 238px; background: var(--navy); color: white; padding: 27px 17px 18px; display: flex; flex-direction: column; position: fixed; inset: 0 auto 0 0; z-index: 5; }
.brand {
  height: 88px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 12px;
  border-bottom: 1px solid rgba(255,255,255,.11);
}
.brand img {
  display: block;
  width: 100%;
  max-width: 195px;
  max-height: 75px;
  object-fit: contain;
  background: #FFFFFF;
  border-radius: 14px;
  padding: 8px;
}
.sidebar-label { color: #91a1b7; font-size: 9px; font-weight: 600; letter-spacing: 1.5px; margin: 31px 13px 13px; }
.main-nav { display: grid; gap: 8px; }
.nav-link { position: relative; display: flex; align-items: center; gap: 13px; width: 100%; min-height: 48px; padding: 0 14px; border: 0; border-radius: 11px; background: transparent; color: #c2ccda; text-decoration: none; text-align: left; font-size: 12px; font-weight: 500; transition: .2s ease; }
.nav-link:hover { background: rgba(255,255,255,.08); color: white; }
.nav-link.active { background: rgba(247,172,35,.14); color: #ffc24f; }
.nav-icon { width: 20px; height: 20px; display: inline-flex; align-items: center; justify-content: center; flex: 0 0 20px; }
.nav-icon svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.active-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--gold); margin-left: auto; }
.sidebar-bottom { margin-top: auto; }
.help-card { display: flex; flex-direction: column; gap: 4px; margin: 0 4px 18px; padding: 15px 13px; border: 1px solid rgba(255,255,255,.12); border-radius: 13px; background: rgba(255,255,255,.055); }
.help-icon { width: 23px; height: 23px; border-radius: 8px; display: grid; place-items: center; color: var(--navy); background: var(--gold); font-weight: 700; margin-bottom: 5px; }
.help-card strong { font-size: 11px; color: white; }
.help-card span { font-size: 9px; color: #9cacc0; }
.logout-button { margin-top: 8px; }
.sidebar-footer { color: #71839b; font-size: 9px; text-align: center; margin-top: 17px; }
.workspace { margin-left: 238px; width: calc(100% - 238px); padding: 27px 31px 30px; min-width: 0; }
.topbar { max-width: 1500px; margin: 0 auto 22px; display: flex; align-items: center; justify-content: space-between; }
.eyebrow { color: #9aa5b3; font-size: 9px; font-weight: 600; letter-spacing: 1.7px; margin-bottom: 3px; }
.topbar h1 { margin: 0; font-size: 24px; letter-spacing: -.7px; font-weight: 600; }
.topbar-user { display: flex; align-items: center; gap: 12px; }
.user-copy { display: flex; flex-direction: column; text-align: right; gap: 1px; }
.user-copy strong { font-size: 11px; font-weight: 600; }
.user-copy span { color: #929cab; font-size: 9px; }
.avatar { flex: 0 0 auto; width: 43px; height: 43px; border-radius: 50%; display: grid; place-items: center; font-weight: 600; color: var(--navy); background: #e8eef6; border: 2px solid white; }
.avatar-user { background: #fbe6bd; color: #8b5a06; }
.messaging-layout { max-width: 1500px; height: calc(100vh - 122px); min-height: 570px; margin: 0 auto; display: grid; grid-template-columns: 320px minmax(0, 1fr); background: white; border: 1px solid #edf0f4; border-radius: 18px; overflow: hidden; box-shadow: var(--shadow); }
.conversations-panel { min-width: 0; border-right: 1px solid var(--line); display: flex; flex-direction: column; background: #fff; }
.panel-heading { display: flex; align-items: center; justify-content: space-between; padding: 24px 21px 17px; }
.panel-heading h2 { margin: 0; font-size: 16px; font-weight: 600; }
.panel-heading p { margin: 4px 0 0; color: #9aa3af; font-size: 10px; }
.conversation-count { min-width: 25px; height: 25px; padding: 0 7px; display: grid; place-items: center; border-radius: 8px; background: var(--gold-light); color: #bd7b08; font-size: 10px; font-weight: 600; }
.search-box { height: 41px; margin: 0 17px 14px; padding: 0 11px; display: flex; align-items: center; gap: 8px; border: 1px solid #edf0f4; border-radius: 9px; background: #fafbfd; }
.search-icon { color: #9aa5b3; font-size: 21px; line-height: 1; transform: rotate(-20deg); }
.search-box input { width: 100%; min-width: 0; border: 0; outline: 0; background: transparent; color: var(--navy); font-size: 10px; }
.search-box input::placeholder { color: #aab2bd; }
.search-box kbd { color: #aab2bd; font-size: 8px; white-space: nowrap; border: 1px solid #e7eaf0; border-radius: 4px; padding: 2px 4px; }
.filter-row { display: flex; gap: 7px; padding: 0 18px 12px; }
.filter-chip { padding: 6px 11px; border: 1px solid #edf0f4; border-radius: 20px; background: white; color: #929cab; font-size: 9px; }
.filter-chip.selected { border-color: #f7d99e; background: #fff8eb; color: #a66b08; font-weight: 600; }
.conversation-list { flex: 1; overflow-y: auto; padding: 0 9px; }
.conversation-item { width: 100%; display: flex; align-items: center; gap: 11px; padding: 12px 10px; border: 0; border-radius: 11px; background: white; text-align: left; transition: background .18s; }
.conversation-item:hover { background: #f8f9fb; }
.conversation-item.active { background: #fff7e9; }
.conversation-item.active .conversation-name { color: var(--navy); }
.conversation-avatar { width: 42px; height: 42px; border-radius: 50%; display: grid; place-items: center; flex: 0 0 auto; color: #fff; font-size: 13px; font-weight: 600; }
.conversation-details { min-width: 0; flex: 1; }
.conversation-topline { display: flex; align-items: center; justify-content: space-between; gap: 5px; }
.conversation-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: #273c57; font-size: 10px; font-weight: 600; }
.conversation-time { flex: 0 0 auto; color: #aab2bd; font-size: 8px; }
.conversation-preview-row { display: flex; align-items: center; justify-content: space-between; gap: 6px; margin-top: 5px; }
.conversation-preview { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: #9aa3af; font-size: 9px; }
.unread-badge { min-width: 17px; height: 17px; padding: 0 5px; display: grid; place-items: center; border-radius: 10px; background: var(--gold); color: var(--navy); font-size: 8px; font-weight: 700; }
.panel-note { display: flex; align-items: center; gap: 7px; padding: 13px 19px; border-top: 1px solid var(--line); color: #a2acb9; font-size: 8px; }
.online-dot, .status-dot { display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: var(--green); }
.chat-panel { position: relative; min-width: 0; background: #fff; }
.empty-state { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 30px; text-align: center; }
.empty-illustration { position: relative; width: 205px; height: 205px; display: grid; place-items: center; margin-bottom: 6px; }
.empty-illustration img { position: relative; z-index: 1; width: 100%; height: 100%; object-fit: contain; }
.illustration-glow { position: absolute; width: 155px; height: 155px; border-radius: 50%; background: #fff4df; }
.empty-kicker { color: #d18b14; font-size: 8px; font-weight: 700; letter-spacing: 2px; }
.empty-state h2 { margin: 10px 0 7px; color: var(--navy); font-size: 19px; font-weight: 600; }
.empty-state p { max-width: 350px; margin: 0; color: #98a2af; font-size: 10px; line-height: 1.8; }
.empty-tip { margin-top: 22px; padding: 9px 14px; border: 1px solid #f3e8d3; border-radius: 20px; color: #8d7957; background: #fffbf4; font-size: 9px; }
.empty-tip span { color: var(--gold); margin-right: 5px; }
.hidden { display: none !important; }
.conversation-view { height: 100%; display: flex; flex-direction: column; }
.chat-header { min-height: 77px; display: flex; align-items: center; gap: 12px; padding: 13px 22px; border-bottom: 1px solid var(--line); }
.chat-avatar { width: 42px; height: 42px; }
.contact-info { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.contact-info strong { color: var(--navy); font-size: 12px; font-weight: 600; }
.contact-info > span { display: flex; align-items: center; gap: 6px; color: #98a2af; font-size: 9px; }
.status-dot { width: 6px; height: 6px; }
.more-button { margin-left: auto; width: 34px; height: 34px; border: 0; border-radius: 9px; color: #9ba6b4; background: transparent; letter-spacing: 2px; }
.more-button:hover { background: #f5f7fa; }
.back-button { display: none; border: 0; background: transparent; color: var(--navy); font-size: 22px; }
.message-area { flex: 1; overflow-y: auto; padding: 22px clamp(18px, 4vw, 55px); background: linear-gradient(180deg, #fff 0%, #fcfdff 100%); }
.date-divider { display: flex; align-items: center; gap: 12px; margin: 3px 0 22px; color: #a7b0bb; font-size: 8px; }
.date-divider::before, .date-divider::after { content: ""; flex: 1; height: 1px; background: #edf0f4; }
.message-row { display: flex; margin: 12px 0; }
.message-row.sent { justify-content: flex-end; }
.message-bubble-wrap { max-width: min(72%, 470px); }
.message-sender { margin: 0 0 5px 3px; color: #a2acb9; font-size: 8px; }
.message-bubble { padding: 11px 14px; border-radius: 4px 13px 13px 13px; background: #f1f4f8; color: #45566d; font-size: 10px; line-height: 1.7; overflow-wrap: anywhere; white-space: pre-wrap; }
.sent .message-bubble { border-radius: 13px 4px 13px 13px; background: var(--navy); color: white; }
.message-meta { display: flex; justify-content: flex-end; gap: 5px; margin: 5px 3px 0; color: #aab3bf; font-size: 8px; }
.sent .message-meta { color: #a4b2c5; }
.read-mark { color: #d99a27; font-weight: 700; }
.composer { padding: 13px 20px 12px; border-top: 1px solid var(--line); background: white; }
.composer-inner { padding: 10px 11px 8px 15px; border: 1px solid #e9edf2; border-radius: 12px; background: #fff; transition: border .2s, box-shadow .2s; }
.composer-inner:focus-within { border-color: #e9bd69; box-shadow: 0 0 0 3px rgba(247,172,35,.09); }
.composer textarea { display: block; width: 100%; min-height: 27px; max-height: 110px; resize: none; border: 0; outline: 0; color: var(--navy); font-size: 10px; line-height: 1.6; }
.composer textarea::placeholder { color: #aab2bd; }
.composer-actions { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-top: 7px; }
.enter-hint { color: #b0b8c2; font-size: 8px; }
.send-button { min-width: 91px; height: 34px; display: flex; align-items: center; justify-content: center; gap: 10px; padding: 0 13px; border: 0; border-radius: 8px; background: var(--gold); color: var(--navy); font-size: 9px; font-weight: 700; transition: .2s; }
.send-button:hover { background: #f5a20d; transform: translateY(-1px); }
.send-button:disabled { opacity: .55; cursor: wait; transform: none; }
.send-arrow { font-size: 12px; }
.composer-status { min-height: 12px; padding: 4px 3px 0; color: #a0a9b5; font-size: 8px; }
.list-loading, .message-loading, .list-empty, .message-empty, .load-error { display: flex; align-items: center; justify-content: center; gap: 9px; padding: 25px 12px; color: #9aa5b3; font-size: 10px; text-align: center; }
.message-loading { height: 100%; }
.message-empty { height: 100%; flex-direction: column; }
.message-empty strong { color: #6f7e91; font-size: 11px; }
.spinner { width: 15px; height: 15px; border: 2px solid #f3e6ce; border-top-color: var(--gold); border-radius: 50%; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.toast { position: fixed; z-index: 20; right: 24px; bottom: 24px; max-width: calc(100vw - 40px); padding: 12px 17px; border-radius: 10px; background: var(--navy); color: white; box-shadow: var(--shadow); font-size: 10px; opacity: 0; transform: translateY(10px); pointer-events: none; transition: .25s; }
.toast.show { opacity: 1; transform: translateY(0); }
.toast.error { background: #9e3540; }
@media (min-width: 1500px) { .messaging-layout { grid-template-columns: 350px minmax(0,1fr); } }
@media (max-width: 900px) {
  .sidebar { width: 76px; min-width: 76px; padding: 22px 10px 15px; }
  .brand { height: 65px; padding: 0 0 13px; }
  .brand img { width: 55px; }
  .sidebar-label, .nav-link > span:not(.nav-icon):not(.active-dot), .help-card, .sidebar-footer { display: none; }
  .main-nav { margin-top: 24px; }
  .nav-link { justify-content: center; padding: 0; }
  .nav-icon { width: 22px; height: 22px; flex-basis: 22px; }
  .active-dot { position: absolute; top: 8px; right: 8px; }
  .logout-button { margin-top: 10px; }
  .workspace { margin-left: 76px; width: calc(100% - 76px); padding: 22px 18px; }
  .messaging-layout { grid-template-columns: 290px minmax(0,1fr); height: calc(100vh - 112px); }
}
@media (max-width: 640px) {
  .sidebar { display: none; }
  .workspace { margin: 0; width: 100%; padding: 17px 12px 12px; }
  .topbar { margin-bottom: 14px; padding: 0 3px; }
  .topbar h1 { font-size: 21px; }
  .user-copy span { display: none; }
  .user-copy strong { font-size: 9px; }
  .avatar-user { width: 36px; height: 36px; }
  .messaging-layout { display: block; height: calc(100dvh - 92px); min-height: 480px; border-radius: 14px; }
  .conversations-panel { height: 100%; border-right: 0; }
  .chat-panel { display: none; height: 100%; }
  .messaging-layout.mobile-chat-open .conversations-panel { display: none; }
  .messaging-layout.mobile-chat-open .chat-panel { display: block; }
  .panel-heading { padding: 18px 17px 14px; }
  .search-box { margin: 0 14px 12px; }
  .conversation-list { padding: 0 7px; }
  .back-button { display: block; }
  .chat-header { min-height: 68px; padding: 10px 12px; gap: 9px; }
  .chat-avatar { width: 38px; height: 38px; }
  .message-area { padding: 18px 13px; }
  .message-bubble-wrap { max-width: 84%; }
  .composer { padding: 10px 9px 8px; }
  .enter-hint { max-width: 170px; line-height: 1.4; }
  .send-button { min-width: 76px; }
  .empty-illustration { width: 175px; height: 175px; }
  .empty-state h2 { font-size: 16px; }
  .empty-state p { font-size: 9px; }
}

/* Botão Nova conversa */
#newConversationButton {
  background: #F7AC23;
  color: #0B2242;
  border: 2px solid #F7AC23;
  border-radius: 10px;
  padding: 10px 12px;
  font-size: 11px;
  font-weight: 700;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.2s ease;
}

#newConversationButton:hover {
  background: #e99b0b;
  border-color: #e99b0b;
}

#newConversationButton:focus-visible {
  outline: 3px solid #0B2242;
  outline-offset: 2px;
}

/* Painel de nova conversa */
.new-conversation-panel {
  margin: 0 17px 14px;
  padding: 14px;
  background: #fffaf0;
  border: 1px solid #f3d79d;
  border-radius: 12px;
}

.new-conversation-panel label {
  display: block;
  margin-bottom: 10px;
  color: var(--navy);
  font-size: 11px;
  font-weight: 600;
}

.new-conversation-search {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 9px 11px;
  background: white;
  border: 1px solid #e3e7ed;
  border-radius: 10px;
}

.new-conversation-search:focus-within {
  border-color: var(--gold);
}

.new-conversation-search input {
  flex: 1;
  min-width: 0;
  border: none;
  outline: none;
  font-size: 11px;
  color: var(--navy);
}

#closeNewConversation {
  border: none;
  background: transparent;
  color: var(--navy);
  font-size: 16px;
}

.new-conversation-results {
  max-height: 220px;
  overflow-y: auto;
  margin-top: 10px;
  color: #8993a2;
  font-size: 11px;
}

.new-contact-item {
  display: block;
  width: 100%;
  padding: 11px;
  border: none;
  border-radius: 8px;
  background: white;
  color: var(--navy);
  text-align: left;
  font-size: 11px;
  cursor: pointer;
}

.new-contact-item:hover {
  background: #ffeac2;
}

.new-contact-item:disabled {
  opacity: 0.5;
  cursor: wait;
}