:root {
  --primary-color: #1f93ff;
  --primary-hover: #1279db;
  --wa-green: #00a884;
  --wa-green-light: #d9fdd3;
  --wa-green-hover: #069476;
  --bg-main: #f0f2f5;
  --bg-sidebar: #ffffff;
  --bg-chat: #efeae2;
  --bg-bubble-in: #ffffff;
  --bg-bubble-out: #d9fdd3;
  --text-primary: #111b21;
  --text-secondary: #667781;
  --text-muted: #8696a0;
  --border-color: #e9edef;
  --active-chat: #f0f2f5;
  --danger-color: #ea4335;
  --shadow-sm: 0 1px 2px rgba(11, 20, 26, 0.08);
  --shadow-md: 0 4px 12px rgba(11, 20, 26, 0.15);
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 18px;
}

body.dark-theme {
  --bg-main: #202c33;
  --bg-sidebar: #111b21;
  --bg-chat: #0b141a;
  --bg-bubble-in: #202c33;
  --bg-bubble-out: #005c4b;
  --text-primary: #e9edef;
  --text-secondary: #8696a0;
  --text-muted: #667781;
  --border-color: #222e35;
  --active-chat: #2a3942;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.5);
}

body.dark-theme .sidebar {
  background-color: #111b21;
}

body.dark-theme .search-box,
body.dark-theme .input-box-wrapper,
body.dark-theme .recorder-overlay,
body.dark-theme .file-preview-banner,
body.dark-theme .attach-menu,
body.dark-theme .action-dropdown,
body.dark-theme .emoji-popover {
  background-color: #202c33;
  color: #e9edef;
}

body.dark-theme .search-input-wrapper {
  background-color: #111b21;
}

body.dark-theme .conversation-item:hover {
  background-color: #182229;
}

body.dark-theme .conversation-item.active {
  background-color: #2a3942;
}

body.dark-theme .conv-avatar,
body.dark-theme .avatar {
  background-color: #374248;
  color: #cfd9df;
}

body.dark-theme .message-date-separator {
  background-color: #182229;
  color: #8696a0;
}

body.dark-theme .reply-preview-bar {
  background-color: #182229;
}

body.dark-theme .quoted-box {
  background: rgba(255, 255, 255, 0.08);
}

body.dark-theme .action-item {
  color: #e9edef;
}

body.dark-theme .action-item:hover,
body.dark-theme .attach-item:hover {
  background-color: #182229;
}

body.dark-theme .chat-textarea {
  color: #e9edef;
}

body.dark-theme .chat-welcome h2 {
  color: #e9edef;
}

body.dark-theme .bubble-actions-btn {
  background: rgba(32, 44, 51, 0.85);
  color: #8696a0;
}

body.dark-theme .msg-doc-box {
  background-color: rgba(255, 255, 255, 0.06);
  color: #e9edef;
}

body.dark-theme .conversation-item.has-unread {
  background-color: #064e3b33;
}

body.dark-theme .conversation-item.has-unread .conv-name {
  color: #34d399;
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

body {
  background-color: var(--bg-main);
  color: var(--text-primary);
  font-size: 14px;
  height: 100vh;
  overflow: hidden;
}

/* === TELA DE LOGIN === */
.login-body {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100vh;
  background: linear-gradient(135deg, #0f172a 0%, #1e293b 100%);
}

.login-card {
  background: #ffffff;
  width: 100%;
  max-width: 420px;
  padding: 35px 30px;
  border-radius: var(--radius-md);
  box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.3);
}

.login-header {
  text-align: center;
  margin-bottom: 25px;
}

.brand-icon {
  width: 54px;
  height: 54px;
  background: var(--primary-color);
  color: #fff;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
  margin: 0 auto 15px auto;
}

.login-header h2 {
  font-size: 20px;
  font-weight: 700;
  color: #1e293b;
}

.login-header p {
  color: var(--text-secondary);
  font-size: 13px;
  margin-top: 5px;
}

.form-group {
  margin-bottom: 18px;
}

.form-group label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 6px;
}

.form-group input {
  width: 100%;
  padding: 11px 14px;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  font-size: 14px;
  outline: none;
  transition: border-color 0.2s;
}

.form-group input:focus {
  border-color: var(--primary-color);
}

.password-wrapper {
  position: relative;
  display: flex;
  align-items: center;
}

.password-wrapper input {
  padding-right: 40px;
}

.password-wrapper .btn-icon {
  position: absolute;
  right: 10px;
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 15px;
}

.form-check {
  display: flex;
  align-items: center;
  margin-bottom: 22px;
}

.custom-checkbox {
  display: flex;
  align-items: center;
  position: relative;
  cursor: pointer;
  font-size: 13px;
  color: var(--text-secondary);
  user-select: none;
}

.custom-checkbox input {
  margin-right: 8px;
  accent-color: var(--primary-color);
  cursor: pointer;
}

.btn-primary {
  background-color: var(--primary-color);
  color: #fff;
  border: none;
  padding: 12px 20px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: background-color 0.2s, transform 0.1s;
  display: flex;
  align-items: center;
  justify-content: center;
}

.btn-primary:hover {
  background-color: var(--primary-hover);
}

.btn-primary:active {
  transform: scale(0.99);
}

.btn-block {
  width: 100%;
}

.login-footer {
  text-align: center;
  margin-top: 25px;
  color: var(--text-muted);
}

.alert {
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  margin-bottom: 18px;
}

.alert-danger {
  background-color: #fde8e8;
  color: #c81e1e;
  border: 1px solid #f8b4b4;
}

.spinner {
  width: 18px;
  height: 18px;
  border: 2px solid rgba(255, 255, 255, 0.3);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* === APLICAÇÃO PRINCIPAL (APP LAYOUT) === */
.app-container {
  display: flex;
  height: 100vh;
  width: 100vw;
  background-color: #fff;
}

/* SIDEBAR ESQUERDA */
.sidebar {
  width: 380px;
  min-width: 320px;
  max-width: 450px;
  height: 100%;
  background-color: var(--bg-sidebar);
  border-right: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
}

.sidebar-header {
  height: 60px;
  padding: 10px 16px;
  background-color: var(--bg-main);
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--border-color);
}

.user-profile {
  display: flex;
  align-items: center;
  gap: 12px;
}

.avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background-color: #cbd5e1;
  color: #334155;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 15px;
  text-transform: uppercase;
}

.user-info h4 {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
}

.user-info span {
  font-size: 11px;
  color: var(--wa-green);
  display: flex;
  align-items: center;
  gap: 4px;
}

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

.icon-btn {
  background: none;
  border: none;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  color: var(--text-secondary);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  transition: background-color 0.2s;
}

.icon-btn:hover {
  background-color: rgba(0, 0, 0, 0.05);
}

.search-box {
  padding: 8px 14px;
  background-color: #fff;
  border-bottom: 1px solid var(--border-color);
}

.search-input-wrapper {
  background-color: var(--bg-main);
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  padding: 6px 12px;
  gap: 10px;
}

.search-input-wrapper i {
  color: var(--text-muted);
}

.search-input-wrapper input {
  border: none;
  background: transparent;
  width: 100%;
  outline: none;
  font-size: 13px;
  color: var(--text-primary);
}

.conversations-list {
  flex: 1;
  overflow-y: auto;
}

.conversation-item {
  display: flex;
  align-items: center;
  padding: 12px 16px;
  cursor: pointer;
  border-bottom: 1px solid var(--border-color);
  transition: background-color 0.15s;
  position: relative;
}

.conversation-item:hover {
  background-color: #f5f6f6;
}

.conversation-item.active {
  background-color: var(--active-chat);
}

.conv-avatar {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background-color: #e2e8f0;
  color: #475569;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: 16px;
  margin-right: 14px;
  flex-shrink: 0;
}

.conv-content {
  flex: 1;
  min-width: 0;
}

.conv-top {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 4px;
}

.conv-name {
  font-weight: 600;
  font-size: 14px;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.conv-time {
  font-size: 11px;
  color: var(--text-muted);
  flex-shrink: 0;
  margin-left: 6px;
}

.conv-bottom {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.conv-last-msg {
  font-size: 13px;
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1;
}

.conv-badge {
  background-color: var(--wa-green);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 10px;
  margin-left: 8px;
}

.conversation-item.has-unread {
  background-color: #f0fdf4;
}

.conversation-item.has-unread .conv-name {
  color: #047857;
  font-weight: 700;
}

.conv-unread-pill {
  background-color: #ef4444;
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 10px;
  margin-left: 6px;
  display: inline-flex;
  align-items: center;
  gap: 3px;
}

.empty-state {
  text-align: center;
  padding: 40px 20px;
  color: var(--text-muted);
}

.empty-state i {
  font-size: 40px;
  margin-bottom: 12px;
}

/* SIDEBAR RECOLHIDA (mostra só os avatares) */
body.sidebar-collapsed .sidebar {
  width: 74px;
  min-width: 74px;
  max-width: 74px;
}

body.sidebar-collapsed .sidebar-header {
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  gap: 12px;
  height: auto;
  padding: 12px 0;
}

body.sidebar-collapsed .user-profile {
  justify-content: center;
  gap: 0;
}

body.sidebar-collapsed .user-info,
body.sidebar-collapsed .header-actions,
body.sidebar-collapsed .search-box {
  display: none;
}

body.sidebar-collapsed .sidebar-toggle-btn {
  color: var(--text-muted);
}

body.sidebar-collapsed .conversations-list {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding-top: 6px;
}

body.sidebar-collapsed .conversation-item {
  justify-content: center;
  padding: 6px 0;
  border-bottom: none;
}

body.sidebar-collapsed .conv-avatar {
  margin-right: 0;
}

body.sidebar-collapsed .conv-content,
body.sidebar-collapsed .conv-unread-pill {
  display: none;
}

/* ÁREA PRINCIPAL DO CHAT */
.chat-pane {
  flex: 1;
  display: flex;
  flex-direction: column;
  background-color: var(--bg-chat);
  position: relative;
  background-image: url('data:image/svg+xml;utf8,<svg width="100" height="100" viewBox="0 0 100 100" xmlns="http://www.w3.org/2000/svg"><path d="M10 10h1v1h-1z" fill="%23000000" fill-opacity="0.03"/></svg>');
}

.chat-welcome {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  color: var(--text-secondary);
  padding: 20px;
}

.chat-welcome i {
  font-size: 64px;
  color: var(--wa-green);
  margin-bottom: 20px;
}

.chat-welcome h2 {
  font-size: 24px;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 8px;
}

.chat-welcome p {
  max-width: 420px;
  font-size: 14px;
  line-height: 1.5;
}

/* CHAT HEADER */
.chat-header {
  height: 60px;
  padding: 10px 16px;
  background-color: var(--bg-main);
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
  z-index: 10;
}

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

.chat-contact-details h3 {
  font-size: 15px;
  font-weight: 600;
  color: var(--text-primary);
}

.chat-contact-details span {
  font-size: 12px;
  color: var(--text-secondary);
}

.ticket-tag {
  background-color: #e0f2fe;
  color: #0369a1;
  font-size: 11px;
  font-weight: 600;
  padding: 3px 8px;
  border-radius: 4px;
  margin-left: 8px;
}

/* MENSAGENS / TIMELINE */
.messages-container {
  flex: 1;
  overflow-y: auto;
  padding: 18px 24px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.message-date-separator {
  align-self: center;
  background-color: #ffffffcc;
  box-shadow: var(--shadow-sm);
  padding: 5px 12px;
  border-radius: var(--radius-sm);
  font-size: 11px;
  color: var(--text-secondary);
  font-weight: 500;
  margin: 10px 0;
  text-transform: uppercase;
}

.message-row {
  display: flex;
  width: 100%;
}

.message-row.incoming {
  justify-content: flex-start;
}

.message-row.outgoing {
  justify-content: flex-end;
}

.message-bubble {
  max-width: 65%;
  min-width: 120px;
  padding: 7px 10px 6px 10px;
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-sm);
  position: relative;
  word-wrap: break-word;
  font-size: 13.5px;
  line-height: 1.4;
}

.message-bubble.incoming {
  background-color: var(--bg-bubble-in);
  border-top-left-radius: 0;
}

.message-bubble.outgoing {
  background-color: var(--bg-bubble-out);
  border-top-right-radius: 0;
}

.message-sender {
  font-size: 11px;
  font-weight: 700;
  color: #128c7e;
  margin-bottom: 4px;
}

/* CITAÇÃO / REPLY BOX */
.quoted-box {
  background: rgba(0, 0, 0, 0.06);
  border-left: 4px solid var(--wa-green);
  padding: 5px 9px;
  border-radius: 4px;
  margin-bottom: 6px;
  font-size: 12px;
  cursor: pointer;
  transition: background 0.15s, transform 0.1s;
}

.quoted-box:hover {
  background: rgba(0, 0, 0, 0.1);
}

.quoted-box:active {
  transform: scale(0.99);
}

.quoted-box .quoted-author {
  font-weight: 700;
  color: var(--wa-green);
  font-size: 11px;
  margin-bottom: 2px;
}

.quoted-box .quoted-text {
  color: var(--text-secondary);
  font-size: 12px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 350px;
}

.pulse-highlight {
  animation: pulse-border 1.5s ease-in-out;
}

@keyframes pulse-border {
  0% { box-shadow: 0 0 0 0 rgba(0, 168, 132, 0.8); }
  50% { box-shadow: 0 0 0 8px rgba(0, 168, 132, 0.4); }
  100% { box-shadow: 0 0 0 0 rgba(0, 168, 132, 0); }
}

/* ANEXOS */
.msg-attachment {
  margin-bottom: 6px;
  border-radius: 4px;
  overflow: hidden;
}

.msg-attachment img {
  max-width: 100%;
  max-height: 280px;
  object-fit: cover;
  border-radius: 4px;
  cursor: pointer;
  display: block;
}

.msg-attachment video {
  max-width: 100%;
  max-height: 280px;
  border-radius: 4px;
}

.msg-doc-box {
  display: flex;
  align-items: center;
  background-color: rgba(0, 0, 0, 0.04);
  padding: 8px 12px;
  border-radius: 6px;
  gap: 12px;
  text-decoration: none;
  color: var(--text-primary);
}

.msg-doc-box i {
  font-size: 24px;
  color: #ef4444;
}

.msg-doc-info {
  flex: 1;
  min-width: 0;
}

.msg-doc-title {
  font-weight: 600;
  font-size: 13px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.msg-doc-size {
  font-size: 11px;
  color: var(--text-muted);
}

/* ÁUDIO / PLAYER */
.msg-audio-box {
  padding: 4px 0;
  min-width: 240px;
}

.msg-audio-box audio {
  width: 100%;
  height: 36px;
}

/* FOOTER DA MENSAGEM */
.message-meta {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 4px;
  font-size: 10px;
  color: var(--text-muted);
  margin-top: 2px;
}

.message-meta .tick {
  color: #53bdeb;
  font-size: 11px;
}

/* REAÇÕES */
.reaction-badge {
  position: absolute;
  bottom: -10px;
  right: 6px;
  background-color: #fff;
  border-radius: 12px;
  padding: 2px 6px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
  font-size: 12px;
  display: flex;
  align-items: center;
  cursor: pointer;
}

/* MENU DE AÇÕES DA MENSAGEM */
.bubble-actions-btn {
  position: absolute;
  top: 4px;
  right: 4px;
  background: rgba(255, 255, 255, 0.8);
  border: none;
  border-radius: 50%;
  width: 22px;
  height: 22px;
  display: none;
  align-items: center;
  justify-content: center;
  color: var(--text-secondary);
  cursor: pointer;
  font-size: 11px;
}

.message-bubble:hover .bubble-actions-btn {
  display: flex;
}

.action-dropdown {
  position: absolute;
  top: 28px;
  right: 4px;
  background: #fff;
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-md);
  padding: 4px 0;
  z-index: 100;
  min-width: 140px;
  display: none;
}

.action-dropdown.show {
  display: block;
}

.action-item {
  padding: 8px 14px;
  font-size: 13px;
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  color: var(--text-primary);
  transition: background 0.15s;
}

.action-item:hover {
  background: #f5f6f6;
}

.action-item.danger {
  color: var(--danger-color);
}

/* BARRA DE CITAÇÃO ATIVA */
.reply-preview-bar {
  background-color: #f0f2f5;
  padding: 8px 16px;
  border-top: 1px solid var(--border-color);
  border-left: 4px solid var(--wa-green);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.reply-preview-content {
  flex: 1;
}

.reply-preview-author {
  font-weight: 600;
  font-size: 12px;
  color: var(--wa-green);
}

.reply-preview-text {
  font-size: 13px;
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.reply-close-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 16px;
  padding: 4px;
}

/* BARRA DE ENVIO INFERIOR */
.chat-input-bar {
  min-height: 62px;
  padding: 8px 16px;
  background-color: var(--bg-main);
  border-top: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  gap: 12px;
  position: relative;
}

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

.input-box-wrapper {
  flex: 1;
  background-color: #fff;
  border-radius: var(--radius-sm);
  padding: 8px 12px;
  display: flex;
  align-items: center;
}

.chat-textarea {
  width: 100%;
  border: none;
  outline: none;
  resize: none;
  font-size: 14px;
  max-height: 100px;
  min-height: 20px;
  line-height: 1.4;
  color: var(--text-primary);
  background: transparent;
}

/* GRAVADOR DE VOZ */
.recorder-overlay {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  background-color: #fff;
  padding: 8px 16px;
  border-radius: var(--radius-sm);
}

.recorder-info {
  display: flex;
  align-items: center;
  gap: 12px;
  color: var(--danger-color);
}

.recording-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background-color: var(--danger-color);
  animation: pulse 1s infinite;
}

@keyframes pulse {
  0% { opacity: 1; }
  50% { opacity: 0.3; }
  100% { opacity: 1; }
}

.recorder-timer {
  font-weight: 600;
  font-size: 14px;
  color: var(--text-primary);
}

.recorder-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.btn-send {
  background-color: var(--wa-green);
  color: #fff;
  border: none;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 16px;
  transition: background-color 0.2s, transform 0.1s;
}

.btn-send:hover {
  background-color: var(--wa-green-hover);
}

.btn-send:active {
  transform: scale(0.95);
}

/* MENU DE ANEXOS */
.attach-menu {
  position: absolute;
  bottom: 70px;
  left: 16px;
  background: #fff;
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-md);
  padding: 10px 0;
  display: none;
  z-index: 200;
  flex-direction: column;
}

.attach-menu.show {
  display: flex;
}

.attach-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 20px;
  cursor: pointer;
  color: var(--text-primary);
  font-size: 13px;
  transition: background-color 0.15s;
}

.attach-item:hover {
  background-color: #f5f6f6;
}

.attach-item i {
  font-size: 18px;
  width: 22px;
}

.attach-item.photos i { color: #8b5cf6; }
.attach-item.docs i { color: #0284c7; }
.attach-item.videos i { color: #ec4899; }

/* PAINEL DE MACROS / RESPOSTAS RÁPIDAS */
.macros-panel {
  position: absolute;
  bottom: 70px;
  left: 16px;
  width: 400px;
  max-width: calc(100vw - 32px);
  max-height: 460px;
  background: #fff;
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-md);
  display: none;
  flex-direction: column;
  z-index: 250;
  overflow: hidden;
}

.macros-panel.show {
  display: flex;
}

.macros-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 14px;
  background: var(--bg-main);
  border-bottom: 1px solid var(--border-color);
}

.macros-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 700;
  font-size: 14px;
  color: var(--text-primary);
}

.macros-title i {
  color: #f59e0b;
}

.macros-header-actions {
  display: flex;
  align-items: center;
  gap: 4px;
}

.macros-search {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  margin: 10px 12px 0 12px;
  background: var(--bg-main);
  border-radius: var(--radius-sm);
}

.macros-search i {
  color: var(--text-muted);
  font-size: 13px;
}

.macros-search input {
  border: none;
  background: transparent;
  width: 100%;
  outline: none;
  font-size: 13px;
  color: var(--text-primary);
}

.macros-list {
  flex: 1;
  overflow-y: auto;
  padding: 8px 0;
}

.macro-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 12px;
  border-bottom: 1px solid var(--border-color);
  transition: background-color 0.15s;
}

.macro-item:hover {
  background-color: #f5f6f6;
}

.macro-item-disabled {
  opacity: 0.55;
}

.macro-item-main {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 1;
  min-width: 0;
  cursor: pointer;
}

.macro-item-icon {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: #fef3c7;
  color: #b45309;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  flex-shrink: 0;
}

.macro-item-content {
  flex: 1;
  min-width: 0;
}

.macro-item-name {
  font-weight: 600;
  font-size: 13px;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.macro-item-preview {
  font-size: 12px;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.macro-item-actions {
  display: flex;
  align-items: center;
  gap: 2px;
  margin-left: 8px;
  flex-shrink: 0;
}

.macro-icon-btn {
  background: none;
  border: none;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  color: var(--text-secondary);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  transition: background-color 0.15s;
}

.macro-icon-btn:hover {
  background-color: rgba(0, 0, 0, 0.08);
}

.macro-icon-btn.macro-icon-danger {
  color: var(--danger-color);
}

.macro-form {
  padding: 12px;
  border-top: 1px solid var(--border-color);
  background: var(--bg-main);
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.macro-form input,
.macro-form textarea {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-family: inherit;
  outline: none;
  background: #fff;
  color: var(--text-primary);
  resize: none;
}

.macro-form input:focus,
.macro-form textarea:focus {
  border-color: var(--primary-color);
}

.macro-form-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

.macro-form-actions .btn-cancel {
  background: none;
  border: 1px solid var(--border-color);
  padding: 7px 14px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  color: var(--text-secondary);
  font-size: 13px;
}

.macro-form-actions .btn-save {
  background: var(--wa-green);
  border: none;
  padding: 7px 14px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  color: #fff;
  font-size: 13px;
  font-weight: 600;
}

.macro-form-actions .btn-save:hover {
  background: var(--wa-green-hover);
}

body.dark-theme .macros-panel,
body.dark-theme .macro-form input,
body.dark-theme .macro-form textarea {
  background-color: #202c33;
  color: #e9edef;
}

body.dark-theme .macro-item:hover {
  background-color: #182229;
}

body.dark-theme .macro-item-icon {
  background: rgba(245, 158, 11, 0.18);
  color: #fbbf24;
}

body.dark-theme .macro-form-actions .btn-cancel {
  border-color: #222e35;
  color: #8696a0;
}

/* MODAL LIGHTBOX / PREVIEW */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(0, 0, 0, 0.85);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}

.modal-overlay.show {
  display: flex;
}

.modal-content {
  max-width: 90%;
  max-height: 90%;
}

.modal-content img {
  max-width: 100%;
  max-height: 85vh;
  border-radius: var(--radius-sm);
  display: block;
}

.modal-close-btn {
  position: absolute;
  top: 20px;
  right: 25px;
  background: none;
  border: none;
  color: #fff;
  font-size: 28px;
  cursor: pointer;
}

/* MODAL NOVA CONVERSA */
.new-conv-card {
  width: 460px;
  max-width: calc(100vw - 32px);
  max-height: 90vh;
  background: var(--bg-sidebar);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-md);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.new-conv-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px;
  border-bottom: 1px solid var(--border-color);
}

.new-conv-header h3 {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 16px;
  font-weight: 700;
  color: var(--text-primary);
}

.new-conv-header h3 i {
  color: var(--wa-green);
}

.new-conv-close {
  background: none;
  border: none;
  font-size: 24px;
  color: var(--text-secondary);
  cursor: pointer;
  line-height: 1;
}

.new-conv-body {
  flex: 1;
  overflow-y: auto;
  padding: 14px 18px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.new-conv-field label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 6px;
}

.new-conv-search {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--bg-main);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 8px 12px;
}

.new-conv-search i {
  color: var(--text-muted);
  font-size: 13px;
}

.new-conv-search input {
  border: none;
  background: transparent;
  width: 100%;
  outline: none;
  font-size: 13px;
  color: var(--text-primary);
}

.new-conv-contacts {
  max-height: 200px;
  overflow-y: auto;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  margin-top: 8px;
}

.new-conv-contact {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  cursor: pointer;
  border-bottom: 1px solid var(--border-color);
  transition: background-color 0.15s;
}

.new-conv-contact:last-child {
  border-bottom: none;
}

.new-conv-contact:hover {
  background-color: var(--active-chat);
}

.new-conv-contact.selected {
  background-color: var(--wa-green-light);
}

.new-conv-contact-info {
  min-width: 0;
}

.new-conv-contact-name {
  font-weight: 600;
  font-size: 13px;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.new-conv-contact-phone {
  font-size: 12px;
  color: var(--text-muted);
}

.new-conv-field select,
.new-conv-field textarea {
  width: 100%;
  padding: 9px 12px;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-family: inherit;
  outline: none;
  background: var(--bg-sidebar);
  color: var(--text-primary);
  resize: none;
}

.new-conv-field select:focus,
.new-conv-field textarea:focus {
  border-color: var(--primary-color);
}

.new-conv-footer {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding: 12px 18px;
  border-top: 1px solid var(--border-color);
}

.new-conv-footer .btn-cancel {
  background: none;
  border: 1px solid var(--border-color);
  padding: 9px 16px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  color: var(--text-secondary);
  font-size: 13px;
}

.new-conv-footer .btn-primary {
  display: flex;
  align-items: center;
  gap: 6px;
  background: var(--wa-green);
  border: none;
  padding: 9px 16px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  color: #fff;
  font-size: 13px;
  font-weight: 600;
}

.new-conv-footer .btn-primary:hover {
  background: var(--wa-green-hover);
}

.new-conv-footer .btn-primary:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

body.dark-theme .new-conv-contact.selected {
  background-color: rgba(0, 168, 132, 0.25);
}

body.dark-theme .new-conv-search {
  background: #202c33;
}

/* POPUP DE EMOJIS RÁPIDOS */
.emoji-popover {
  position: fixed;
  background: #fff;
  border-radius: 20px;
  box-shadow: var(--shadow-md);
  padding: 6px 10px;
  display: none;
  gap: 8px;
  z-index: 1500;
}

.emoji-popover.show {
  display: flex;
}

.emoji-btn {
  background: none;
  border: none;
  font-size: 20px;
  cursor: pointer;
  transition: transform 0.1s;
}

.emoji-btn:hover {
  transform: scale(1.3);
}

/* PREVIEW ANTES DO ENVIO DE ARQUIVO */
.file-preview-banner {
  background-color: #fff;
  padding: 10px 16px;
  border-top: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.file-preview-info {
  display: flex;
  align-items: center;
  gap: 12px;
}

.file-preview-info img {
  width: 44px;
  height: 44px;
  object-fit: cover;
  border-radius: 4px;
}

.file-preview-info i {
  font-size: 32px;
  color: var(--primary-color);
}
