@import url("https://fonts.googleapis.com/css2?family=Roboto:ital,wght@0,100..900;1,100..900&display=swap");

[data-theme="dark"] .message-composer {
  background: #2a2f32;
  border-color: #3b454b;
}

[data-theme="dark"] .composer-icon {
  color: #c9d1d9;
}

[data-theme="dark"] .composer-icon:hover {
  background: rgba(255, 255, 255, 0.08);
}
/* ===========================
   Dark Theme -  Message Input
=========================== */

[data-theme="dark"] #messageInput,
[data-theme="dark"] .messages,
[data-theme="dark"] .chat-list {
  scrollbar-color: #474949 transparent;
}

[data-theme="dark"] #messageInput::-webkit-scrollbar-thumb {
  background: #6f6f6f;
  border: 2px solid transparent;
  background-clip: content-box;
}

[data-theme="dark"] #messageInput::-webkit-scrollbar-thumb:hover {
  background: #8a8a8a;
  background-clip: content-box;
}

[data-theme="dark"] .chat-panel::before {
  content: "";
  position: absolute;
  inset: 0;

  background: url("/chat-bg-pattern.svg") repeat;
  background-size: 540px 960px;

  filter: invert(1);
  opacity: 0.05;

  pointer-events: none;
  z-index: 0;
}
/* ===========================
   Dark Theme - File Preview
=========================== */

[data-theme="dark"] .file-preview {
  background: #111b21;
}

/* Top Bar */

[data-theme="dark"] .preview-top {
  background: #111b21;
  border-bottom: 1px solid #2a3942;
}

[data-theme="dark"] .preview-top button {
  color: #aebac1;
}

[data-theme="dark"] .preview-top button:hover {
  background: rgba(255, 255, 255, 0.08);
}

[data-theme="dark"] #previewFileName {
  color: #e9edef;
}

/* Center */

[data-theme="dark"] .preview-header {
  background: #111b21;
}

/* Document Card */

[data-theme="dark"] .preview-document {
  background: #1f2c34;
  border: 1px solid #2a3942;
  box-shadow: none;
}

[data-theme="dark"] .preview-document i {
  color: #ffffff;
}

[data-theme="dark"] .preview-title {
  color: #e9edef;
}

[data-theme="dark"] #previewFileSize {
  color: #8696a0;
}

/* Footer */

[data-theme="dark"] .attachment-footer {
  background: #111b21;
  border-top: 1px solid #2a3942;
}

/* Caption */

[data-theme="dark"] .attachment-caption {
  background: #2a3942;
  border: 1px solid #3b4a54;
}

[data-theme="dark"] .attachment-caption input {
  color: #e9edef;
}

[data-theme="dark"] .attachment-caption input::placeholder {
  color: #8696a0;
}

[data-theme="dark"] .emoji-btn {
  color: #8696a0;
}

[data-theme="dark"] .emoji-btn:hover {
  color: #ffffff;
}

/* File Thumbnail */

[data-theme="dark"] .attachment-thumb {
  background: #202c33;
  border: 2px solid #25d366;
  box-shadow: none;
}

[data-theme="dark"] .attachment-name {
  color: #e9edef;
}

/* Remove */

[data-theme="dark"] .remove-file {
  background: #f15c6d;
}

[data-theme="dark"] .remove-file:hover {
  background: #e53935;
}

/* Add More */

[data-theme="dark"] .attachment-add {
  background: transparent;
  border: 2px dashed #55626c;
  color: #aebac1;
}

[data-theme="dark"] .attachment-add:hover {
  background: #202c33;
  border-color: #25d366;
  color: #25d366;
}

/* Send */

[data-theme="dark"] .attachment-send {
  background: #25d366;
}

[data-theme="dark"] .attachment-send:hover {
  background: #20ba5a;
}

[data-theme="dark"] .date-divider span {
  background: #202c33;
  color: #e9edef;
}

html {
  scroll-behavior: smooth;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  height: 100vh;
  overflow: hidden;
  overflow-x: hidden;
  background: var(--bg);
}

/* Tablet breakpoint */
@media (max-width: 1024px) {
  .app-shell {
    width: calc(100vw - 24px);
    height: calc(100vh - 20px);
    margin: 10px auto;
  }
}

/* Small tablet */
@media (max-width: 900px) {
  .app-shell {
    grid-template-columns: minmax(260px, 300px) minmax(0, 1fr);
    width: 100vw;
    height: 100vh;
    margin: 0;
    border-radius: 0;
  }
}

.theme-toggle {
  margin-left: auto;
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface);
  cursor: pointer;
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: var(--text-xs);
  font-weight: var(--font-semibold);
  transition: all 0.2s ease;
  height: 40px !important;
  min-height: 40px !important;
  line-height: var(--leading-none) !important;
}

.app-shell {
  display: grid;
  grid-template-columns: minmax(250px, 300px) minmax(0, 1fr);
  width: min(1300px, calc(100vw - 48px));
  height: min(930px, calc(100vh - 34px));
  margin: 17px auto;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--card);
  box-shadow: var(--shadow);
  transition:
    background 0.3s,
    border-color 0.3s;
}

.sidebar {
  display: flex;
  height: 100%;
  min-width: 0;
  min-height: 0;
  flex-direction: column;
  overflow: hidden;
  border-right: 1px solid var(--border);
  background: var(--card);
  transition:
    background 0.3s,
    border-color 0.3s;
}

.sidebar .sidebar-header {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4) var(--space-4);
  border-bottom: 1px solid var(--border);
  background: var(--light);
  transition:
    background 0.3s,
    border-color 0.3s;
  justify-content: space-between;
  width: 100%;
}

.sidebar .sidebar-header .header-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
}

.chat-header {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  min-height: 60px;
  padding: 10px var(--space-5);
  border-bottom: 1px solid var(--border);
  background: var(--light);
  transition:
    background 0.3s,
    border-color 0.3s;
  position: relative;
  z-index: 100;
}

.eyebrow {
  margin: 0 0 3px;
  color: var(--primary);
  font-size: var(--text-x);
  font-weight: var(--font-bold);
  text-transform: uppercase;
}

.chat-header h2 {
  font-size: var(--text-xl);
  line-height: var(--leading-tight);
}

.chat-header p {
  margin-top: 5px;
  color: var(--text-secondary);
  font-size: var(--text-sm);
}

.icon-button {
  display: grid;
  width: 40px;
  height: 40px;
  place-items: center;
  border: 0;
  border-radius: 50%;
  color: var(--text-secondary);
  background: var(--surface);
  cursor: pointer;
  transition:
    color 160ms ease,
    background 160ms ease,
    transform 160ms ease;
}

.icon-button:hover {
  color: var(--primary);
  background: var(--surface-hover);
  transform: rotate(18deg);
}

.search-box {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  flex: 0 0 auto;
  margin: 14px var(--space-4);
  padding: 0 14px;
  min-height: 52px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  color: var(--text-secondary);
  background: var(--surface);
  transition:
    border-color 160ms ease,
    background 160ms ease,
    box-shadow 160ms ease;
}

.search-box:focus-within {
  border-color: var(--primary);
  background: var(--surface-hover);
  box-shadow: 0 0 0 3px rgba(0, 123, 255, 0.1);
}

.fa-icon {
  display: block;
  width: 1em;
  height: 1em;
  fill: currentColor;
}

.search-box .fa-icon {
  flex: 0 0 auto;
  width: 16px;
  height: 16px;
  font-size: var(--text-sm);
  text-align: center;
}

.icon-button .fa-icon {
  width: 16px;
  height: 16px;
  font-size: var(--text-base);
}

.search-box input {
  width: 100%;
  min-width: 0;
  border: 0;
  outline: 0;
  color: var(--text-primary);
  background: transparent;
  font-size: var(--text-base);
}

.search-clear {
  display: none;
  flex: 0 0 auto;
  width: 28px;
  height: 28px;
  place-items: center;
  border: 0;
  border-radius: 50%;
  color: var(--text-secondary);
  background: transparent;
  cursor: pointer;
  transition:
    color 160ms ease,
    background 160ms ease;
}

.search-box.has-value .search-clear {
  display: grid;
}

.search-clear:hover {
  color: var(--primary);
  background: var(--surface-hover);
}

.search-clear .fa-icon {
  width: 12px;
  height: 12px;
}

.search-box input::placeholder {
  color: var(--text-secondary);
}

.search-box input::-webkit-search-cancel-button,
.search-box input::-webkit-search-decoration {
  appearance: none;
  -webkit-appearance: none;
}

.chat-list {
  flex: 1 1 auto;
  min-height: 0;
  overflow-x: hidden;
  overflow-y: scroll;
  /* scrollbar-color: var(--accent-dark) transparent; */
  scrollbar-color: #e0dede transparent;
  scrollbar-gutter: stable;
  scrollbar-width: thin;
}

.chat-list::-webkit-scrollbar {
  width: 7px;
}

.chat-list::-webkit-scrollbar-track {
  background: transparent;
}

.chat-list::-webkit-scrollbar-thumb {
  border: 2px solid var(--card);
  border-radius: 999px;
  background: var(--secondary);
}

.chat-preview {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--text-secondary);
  font-size: var(--text-xs);
  line-height: var(--leading-snug);
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  margin-top: var(--space-1);
  flex: 1;
  min-width: 0;
}

.chat-preview i {
  font-size: var(--text-xs);
  color: #667781;
  width: 16px;
  text-align: center;
  flex-shrink: 0;
}

.chat-preview .fa-image {
  color: #6b7280;
}

.chat-preview .fa-file-lines {
  color: #6b7280;
}

.chat-preview .fa-video {
  color: #6b7280;
}

.chat-preview .fa-microphone {
  color: #6b7280;
}

.chat-preview .fa-location-dot {
  color: #6b7280;
}

.sidebar-footer {
  flex: 0 0 auto;
  padding: var(--space-3) var(--space-4);
  border-top: 1px solid var(--border);
  color: var(--text-secondary);
  font-size: var(--text-x);
  line-height: var(--leading-snug);
  text-align: center;
  background: var(--surface);
}

.sidebar-footer a {
  display: inline-block;
  color: var(--accent-dark);
  font-weight: var(--font-bold);
  text-decoration: none;
}

.sidebar-footer a:hover {
  text-decoration: underline;
}

.chat-item {
  display: grid;
  grid-template-columns: 46px minmax(0, 1fr);
  gap: var(--space-3);
  width: 100%;
  min-height: 72px;
  padding: 10px var(--space-4);
  border: 0;
  border-bottom: 1px solid var(--border);
  text-align: left;
  color: var(--text-primary);
  background: transparent;
  cursor: pointer;
  transition:
    background 160ms ease,
    box-shadow 160ms ease;
}

.chat-item:hover,
.chat-item.active {
  background: var(--surface-hover);
}

.chat-item.active {
  box-shadow: inset 3px 0 0 var(--primary);
}

.avatar {
  display: grid;
  width: 46px;
  height: 46px;
  flex: 0 0 auto;
  place-items: center;
  border-radius: 50%;
  color: #ffffff;
  font-weight: var(--font-bold);
  font-size: var(--text-sm);
  background: linear-gradient(135deg, var(--primary), var(--text-secondary));
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.chat-name-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--space-3);
}

.chat-name {
  overflow: hidden;
  font-weight: var(--font-bold);
  font-size: var(--text-sm);
  line-height: var(--leading-tight);
  text-overflow: ellipsis;
  white-space: nowrap;
}

.chat-time {
  flex: 0 0 auto;
  color: var(--text-secondary);
  font-size: var(--text-x);
}

/* .chat-panel {
  display: grid;
  min-width: 0;
  grid-template-rows: auto 1fr auto;
  background: var(--chat-bg);
  transition: background 0.3s;
  height: 100%;
  overflow: hidden;
  position: relative;
} */

.chat-panel {
  position: relative;

  display: flex;
  flex-direction: column;

  min-width: 0;
  min-height: 0;
  height: 100%;

  overflow: hidden;

  background: var(--chat-bg);
}
.messages {
  display: flex;
  flex-direction: column;
  gap: 10px;
  overflow-y: auto;
  padding: 36px clamp(24px, 5vw, 90px);
  /* scrollbar-color: var(--accent-dark) transparent; */
  scrollbar-color: #e0dede transparent;
  scrollbar-width: thin;
  position: relative;
  flex: 1;
  -webkit-overflow-scrolling: touch;
}

.chat-panel::before {
  content: "";
  position: absolute;
  inset: 0;

  background: var(--chat-bg) url("/chat-bg-pattern.svg") repeat;
  background-size: 540px 960px;

  z-index: 0;
  opacity: 0.05;
}

#messageList {
  width: 100%;
  height: 100%;
}

.messages::-webkit-scrollbar {
  width: 8px;
}

.messages::-webkit-scrollbar-track {
  background: transparent;
}

.messages::-webkit-scrollbar-thumb {
  border: 2px solid var(--chat-bg);
  border-radius: 999px;
  background: var(--text-secondary);
}

.date-divider {
  display: flex;
  justify-content: center;

  margin: 14px 0;
}

.date-divider span {
  padding: 6px var(--space-3);

  border-radius: var(--radius-md);

  background: #d9fdd3;
  color: #111b21;

  font-size: var(--text-xs);
  font-weight: var(--font-medium);
}

.message-row {
  display: flex;
  margin: 10px 0;
}

.message-row.incoming {
  justify-content: flex-start;
}

.message-bubble {
  width: fit-content;
  max-width: min(640px, 82%);
  padding: var(--space-3) 15px 5px;
  border-radius: 7px;
  /* border: 1px solid var(--border); */
  background: var(--msg-bg);
  box-shadow: 0 12px 28px rgba(0, 0, 0, 0.22);
}

.message-row.outgoing {
  justify-content: flex-end;
}

.message-row.outgoing .message-bubble {
  border-color: rgba(0, 123, 255, 0.22);
  background: var(--outgoing);
}

.message-text {
  color: var(--text-primary);
  font-size: var(--text-base);
  line-height: var(--leading-base);
  /* white-space: pre-wrap; */
  word-break: break-word;
}

.message-link {
  color: var(--link-color);
  text-decoration: underline;
  word-break: break-word;
}

.message-link:hover {
  /* color: #06e463; */
  color: var(--link-hover-color);
  text-decoration: none;
}
.message-time {
  margin-top: 3px;
  color: var(--text-secondary);
  font-size: var(--text-x);
  text-align: right;
  display: flex;
  justify-content: flex-end;
}

.empty-state,
.error-state {
  align-self: center;
  max-width: 330px;
  margin: auto;
  padding: 26px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  text-align: center;
  background: var(--card);
  box-shadow: var(--shadow);
}

.chat-list-state {
  max-width: 250px;
}
.empty-state h2,
.error-state h2 {
  margin-bottom: var(--space-2);
  font-size: 20px;
}

.empty-state p,
.error-state p {
  color: var(--text-secondary);
  line-height: var(--leading-base);
}

.chat-preview-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-2);
  margin-top: 2px;
}

.unread-badge {
  min-width: 22px;
  height: 22px;

  padding: 0 6px;

  border-radius: 999px;

  background: #25d366;
  color: #fff;

  display: flex;
  align-items: center;
  justify-content: center;

  font-size: 11px;
  font-weight: var(--font-bold);

  flex-shrink: 0;
}

.chat-user-info {
  flex: 1;
}

.chat-menu-wrapper {
  position: relative;
  margin-left: auto;
}

.chat-menu-btn {
  width: 40px;
  height: 40px;
  border: none;
  border-radius: 50%;
  cursor: pointer;

  background: transparent;
  color: var(--text-primary);

  font-size: var(--text-lg);
}

.chat-menu-btn:hover {
  background: var(--surface-hover);
}

.chat-dropdown {
  position: absolute;
  top: 48px;
  right: 0;

  width: 180px;

  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);

  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.15);

  display: none;
  overflow: hidden;
  z-index: 9999; /*1000*/
}

.chat-dropdown.show {
  display: block;
}

.chat-dropdown button {
  width: 100%;
  padding: var(--space-3) 15px;

  border: none;
  background: transparent;

  text-align: left;
  cursor: pointer;

  display: flex;
  align-items: center;
  gap: 10px;

  color: var(--text-primary);
}

.chat-dropdown button:hover {
  background: var(--surface-hover);
}

#deleteContactBtn {
  color: #dc3545;
}

.no-select-contact {
  font-size: 100px;
  margin-bottom: 30px;
}

/* Prevent text selection on UI elements */
.icon-button,
.search-clear,
.chat-item {
  -webkit-user-select: none;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}

/* Smooth scrolling for chat list */
.chat-list {
  -webkit-overflow-scrolling: touch;
}

.message-placeholder {
  display: flex;
  align-items: center;
  gap: var(--space-3);

  width: auto;
  min-width: 220px;
  max-width: 280px;

  padding: var(--space-3);
  border-radius: var(--radius-md);

  background: rgba(0, 0, 0, 0.04);
  border: 1px solid var(--border);
}

.message-placeholder-icon {
  flex-shrink: 0;

  width: 54px;
  height: 54px; /* 42 */

  display: flex;
  align-items: center;
  justify-content: center;

  border-radius: var(--radius-md);

  background: rgba(0, 123, 255, 0.1);
  color: var(--primary);
  font-size: var(--text-2xl);
}

.message-placeholder-content {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.message-placeholder-title {
  font-size: var(--text-base);
  font-weight: var(--font-semibold);
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.message-placeholder-subtitle {
  font-size: var(--text-xs);
  color: var(--text-secondary);
}

.chat-preview-media {
  color: var(--text-secondary);
  font-style: italic;
}

.message-caption {
  /* margin-top: 8px; */
  padding-top: var(--space-2);
  border-top: 1px solid rgba(255, 255, 255, 0.08);

  font-size: var(--text-base);
  line-height: var(--leading-base);
  color: var(--text-primary);
  /* white-space: pre-wrap; */
  word-break: break-word;
}

.button-option {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: var(--space-3);
  margin-top: var(--space-3);
  width: 100%;
}

.downloadDocument,
.openDocument {
  width: 100%;
  height: 44px;

  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);

  padding: 0 var(--space-4);

  border: none;
  border-radius: 10px;

  font-size: var(--text-sm);
  font-weight: var(--font-semibold);

  text-decoration: none;
  cursor: pointer;

  transition: 0.2s;
  box-sizing: border-box;
}
.downloadDocument {
  background: var(--primary);
  color: #fff;
}

.downloadDocument:hover {
  background: var(--accent-dark);
}

.openDocument {
  background: #eef2f5;
  color: #374151;
}

.openDocument:hover {
  background: #dfe6ec;
}

/* ===========================
   WhatsApp Style Composer
=========================== */

.message-composer {
  display: none;
  position: relative;
}

.message-composer.show {
  display: flex;
  align-items: center;

  min-height: 58px;
  height: auto;

  margin: 14px;

  /* padding: 0 10px; */
  padding: var(--space-2) 10px;

  border: 1px solid var(--border);
  border-radius: 30px;

  background: var(--card);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);

  transition: height 0.15s ease;
}

#messageInput {
  flex: 1;

  border: none;
  outline: none;
  resize: none;

  overflow-y: auto;

  background: transparent;

  line-height: 22px;
  font-size: var(--text-base);
  font: inherit;

  min-height: 24px;
  max-height: 140px;
  overflow-y: auto;

  color: var(--text-primary);

  padding: 0;
  margin: 0;

  display: block;
  scrollbar-width: thin;
  scrollbar-color: #cccccc transparent;
}

#messageInput::placeholder {
  color: var(--text-secondary);
}
/* Chrome / Edge / Safari */
#messageInput::-webkit-scrollbar {
  width: 8px;
}

#messageInput::-webkit-scrollbar-track {
  background: transparent;
  margin: var(--space-2) 0;
}

#messageInput::-webkit-scrollbar-thumb {
  background: #9b9b9b;
  border-radius: 999px;
  border: 2px solid transparent;
  background-clip: content-box;
}

#messageInput::-webkit-scrollbar-thumb:hover {
  background: #7d7d7d;
  background-clip: content-box;
}

#messageInput::-webkit-scrollbar-corner {
  background: transparent;
}

.composer-icon {
  width: 42px;
  height: 42px;

  border: none;
  border-radius: 50%;

  background: transparent;

  color: #54656f;

  cursor: pointer;

  display: flex;
  align-items: center;
  justify-content: center;

  font-size: var(--text-xl);

  transition: 0.2s;
}

.composer-icon:hover {
  background: rgba(0, 0, 0, 0.06);
}

.composer-send {
  width: 42px;
  height: 42px;

  border: none;
  border-radius: 50%;

  background: #25d366;

  color: white;

  cursor: pointer;

  display: flex;
  align-items: center;
  justify-content: center;

  font-size: var(--text-lg);

  transition: 0.2s;
}

.composer-send:hover {
  background: #1ebe5d;

  transform: scale(1.05);
}

.composer-send:active {
  transform: scale(0.95);
}

#sendBtn {
  right: 26px;
  background: #21c063;
  color: white;
  margin-left: 5px;
}

/* #sendBtn:hover {
  background: #20ba5a;
  transform: translateY(-50%) scale(0.5); 
} */

#sendBtn i {
  font-size: var(--text-lg);
}

/* ===========================
   WhatsApp Document Preview
=========================== */

.file-preview {
  position: absolute;
  /* position: relative; */
  inset: 0;

  display: flex;
  flex-direction: column;

  background: #f5f7fb;
  z-index: 20;
}

.file-preview.hidden {
  display: none;
}

/* Top bar */

.preview-top {
  height: 58px;

  display: flex;
  align-items: center;

  padding: 0 22px;
  border-bottom: 1px solid #dfe3e8;
  color: #212529;
  background: #ffffff;
  flex-shrink: 0;
}

.preview-top button {
  width: 42px;
  height: 42px;

  border: none;
  border-radius: 50%;

  background: transparent;

  color: #495057;

  font-size: var(--text-xl);

  cursor: pointer;

  transition: 0.2s;
}

.preview-top button:hover {
  background: #eef2f7;
}

#previewFileName {
  flex: 1;

  text-align: center;

  font-size: var(--text-sm);
  font-weight: var(--font-semibold);

  color: #212529;

  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;

  margin-right: 42px;
}

/* Center */

.preview-header {
  flex: 1;

  display: flex;
  justify-content: center;
  align-items: center;
  background: #f5f7fb;
  padding: 30px;
}

/* Card */

.preview-document {
  width: 520px;
  max-width: 90%;
  background: #ffffff;
  border: 1px solid #e5e7eb;
  border-radius: var(--radius-xl);
  padding: 60px 30px;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.preview-document i {
  font-size: 120px;
  color: #6c757d;
  margin-bottom: var(--space-6);
}

.preview-title {
  font-size: var(--text-2xl);
  font-weight: 400;
  color: #212529;
  margin-bottom: 10px;
}

#previewFileSize {
  font-size: var(--text-lg);
  color: #6c757d;
}

/* ===========================
   WhatsApp Attachment Footer
=========================== */

.attachment-footer {
  border-top: 1px solid #dfe3e8;
  background: #ffffff;
  padding: var(--space-4) var(--space-5);
}

/* Caption */

.attachment-caption {
  height: 56px;
  display: flex;
  align-items: center;
  background: #f3f5f7;
  border-radius: 10px;
  padding: 0 14px;
}

.attachment-caption input {
  flex: 1;
  border: none;
  outline: none;
  background: transparent;
  color: #212529;
  font-size: var(--text-base);
}

.attachment-caption input::placeholder {
  color: #868e96;
}

.emoji-btn {
  width: 38px;
  height: 38px;
  border: none;
  background: none;
  color: #6c757d;
  cursor: pointer;
  font-size: var(--text-xl);
}

.emoji-btn:hover {
  color: #0d6efd;
}

/* Bottom row */

.attachment-actions {
  margin-top: 18px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.attachment-files {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
}

/* Selected File */

.attachment-thumb {
  position: relative;

  width: 70px;
  height: 70px;

  border-radius: var(--radius-md);

  background: #ffffff;

  border: 3px solid #25d366;

  display: flex;
  align-items: center;
  justify-content: center;

  flex-direction: column;
  /* new*/
  padding: var(--space-2) var(--space-1);
  /* new*/

  /* color:#ff4d4f;
    font-size:28px; */

  flex-shrink: 0;
}

.attachment-thumb i {
  font-size: 28px;
  color: #dc3545;
}

.remove-file i {
  font-size: var(--text-xs);
  color: #fff;
}

.attachment-name {
  margin-top: 6px;
  width: 100%;
  font-size: 10px;
  color: #212529;
  text-align: center;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.remove-file {
  position: absolute;
  top: -7px;
  right: -7px;
  width: 18px;
  height: 18px;
  border: none;
  border-radius: 50%;
  background: #ef4444;
  /*f15c6d;*/
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: var(--text-x);
  font-weight: var(--font-bold);
  line-height: 1;
  padding: 0;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.35);
  transition: 0.2s;
}

.remove-file:hover {
  background: #dc2626;
  /*e53935;*/
  transform: scale(1.1);
}

.remove-file:active {
  transform: scale(0.9);
}

/* Add file */

.attachment-add {
  width: 50px;
  height: 50px;

  border-radius: var(--radius-md);

  border: 1px dashed #cfd4da;
  /*55626c;*/

  background: transparent;

  color: #6c757d;
  /*white;*/

  cursor: pointer;

  font-size: 30px;

  transition: 0.2s;
}

.attachment-add:hover {
  background: #202c33;
}

/* Send */

.attachment-send {
  width: 55px;
  height: 55px;

  border: none;
  border-radius: 50%;

  background: #25d366;

  color: white;

  cursor: pointer;

  font-size: 30px;

  transition: 0.2s;
}

.attachment-send:hover {
  background: #20ba5a;
  /*1eba57;*/

  transform: scale(1.04);
}

.attachment-send:active {
  transform: scale(0.95);
}

/* Extra small devices */
@media (max-width: 480px) {
  .header-row h1 {
    font-size: var(--text-lg);
  }

  .eyebrow {
    font-size: 10px;
  }

  .chat-item {
    grid-template-columns: 36px minmax(0, 1fr);
    gap: var(--space-2);
    padding: 6px 10px;
  }

  .avatar {
    width: 36px;
    height: 36px;
    font-size: var(--text-x);
  }

  .chat-name {
    font-size: var(--text-xs);
  }

  .chat-preview {
    font-size: 11px;
  }

  .search-box {
    margin: var(--space-2) 10px;
    min-height: 40px;
  }

  .search-box input {
    font-size: var(--text-sm);
  }

  .messages {
    padding: var(--space-3);
  }

  .message-bubble {
    max-width: 95%;
    padding: var(--space-2) 10px 6px;
  }

  .message-text {
    font-size: var(--text-xs);
  }
}

/* Touch-friendly improvements */
@media (hover: none) and (pointer: coarse) {
  .chat-item {
    padding: var(--space-3) var(--space-4);
  }

  .chat-item:hover {
    background: transparent;
  }

  .chat-item:active {
    background: var(--surface-hover);
  }

  .icon-button,
  .search-clear {
    min-width: 44px;
    min-height: 44px;
  }
  .message-bubble {
    max-width: 85%;
  }
}

/* =========================
   MOBILE CHAT VIEW
========================= */
@media (max-width: 768px) {
  body {
    overflow: hidden;
  }

  .app-shell {
    display: block;
    width: 100%;
    height: 100vh;
    margin: 0;
    border: 0;
    border-radius: 0;
  }

  .sidebar {
    width: 100%;
    height: 100vh;
    border: 0;
  }

  .chat-panel {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 100;
    background: var(--chat-bg);
  }

  .chat-panel.mobile-open {
    display: grid;
  }

  .messages {
    padding: var(--space-3);
  }

  .message-bubble {
    max-width: 88%;
  }

  .sidebar .sidebar-header {
    padding: 10px;
  }

  .sidebar .sidebar-footer {
    display: none;
  }

  .chat-header {
    position: sticky;
    top: 0;
    z-index: 10;
  }
}

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;

  backdrop-filter: blur(3px);
}

.modal-overlay.hidden {
  display: none;
}

.modal {
  width: 400px;
  max-width: calc(100vw - 32px);
  /* background: #fff; */

  background: var(--card);
  color: var(--text-primary);
  border: 1px solid var(--border);

  border-radius: var(--radius-lg);
  padding: var(--space-5);
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.25);
  animation: modalIn 0.18s ease;
}

@keyframes modalIn {
  from {
    opacity: 0;
    transform: scale(0.96);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

.modal-header {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  margin-bottom: var(--space-4);
  padding: 0 10px 10px;
  border-bottom: 1px solid var(--border);
}

.modal-header i {
  color: var(--warning);
  font-size: var(--text-xl);
}

.modal-header h3 {
  margin: 0;

  font-size: var(--text-lg);
  font-weight: var(--font-semibold);
}

#unsupportedFiles {
  margin-bottom: var(--space-5);
  line-height: 1.7;
}

.modal-btn {
  width: 100%;
  padding: 10px;
  border: none;
  border-radius: var(--radius-md);
  /* background: #25D366; */
  background: var(--primary);
  color: white;
  cursor: pointer;
}
.modal-btn:hover {
  background: var(--accent-dark);
}

.message-row.incoming .message-bubble {
  position: relative;
  border-radius: 8px 10px 10px 10px;
}

.message-row.incoming .message-bubble::before {
  content: "";
  position: absolute;
  left: -10px;
  top: 0;

  width: 15px;
  height: 15px;

  background: inherit;

  clip-path: polygon(100% 0, 100% 100%, 0 0);
}
.message-row.outgoing .message-bubble {
  position: relative;
  border-radius: 10px 8px 10px 10px;
}

.message-row.outgoing .message-bubble::before {
  content: "";
  position: absolute;
  right: -10px;
  top: 0;

  width: 15px;
  height: 15px;

  background: inherit;

  clip-path: polygon(0 0, 0 100%, 100% 0);
}
/* ==========================
   WhatsApp Confirm Modal
========================== */
.confirm-modal {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(11, 20, 26, 0.72);
  backdrop-filter: blur(2px);
  z-index: 10000;
  font-family:
    Roboto Variable,
    Roboto,
    Helvetica Neue,
    Helvetica,
    sans-serif;
}

.confirm-modal.hidden {
  display: none;
}

.confirm-box {
  width: 500px;
  max-width: calc(100vw - 40px);

  background: #202c33;
  color: #e9edef;

  border-radius: var(--radius-2xl);

  padding: var(--space-7) var(--space-8) var(--space-5);

  box-shadow: 0 24px 48px rgba(0, 0, 0, 0.45);
  animation: confirmIn 0.18s ease;
}
@keyframes confirmIn {
  from {
    opacity: 0;
    transform: scale(0.95);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}
.confirm-box h1 {
  margin: 0;
  font-size: 24px;
  font-weight: var(--font-medium);
  line-height: var(--leading-base);
}

.confirm-box p {
  margin: var(--space-5) 0 0;
  color: #8696a0;
  font-size: var(--text-sm);
  line-height: var(--leading-relaxed);
}

.confirm-actions {
  margin-top: 50px;
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: var(--space-2);
}

.confirm-cancel {
  border: none;
  background: transparent;
  padding: 10px var(--space-8);
  color: #25d366;
  border-radius: 999px;
  font-size: var(--text-sm);
  font-weight: 545;
  cursor: pointer;
}

.confirm-delete {
  border: none;

  padding: 10px var(--space-8);

  border-radius: 999px;

  background: #ff4f5f;
  color: #111;

  font-size: var(--text-sm);
  font-weight: 545;

  cursor: pointer;
}

.confirm-delete:hover {
  background: #ff6573;
}

.confirm-cancel:hover {
  background: #269f261b;
}

[data-theme="light"] .confirm-box {
  background: #fff;
  color: #111;
}

[data-theme="light"] .confirm-box p {
  color: #666;
}

#chatView {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
  overflow: hidden; /* NOT auto */
}
.header-actions {
  display: flex;
  gap: var(--space-2);
}
.settings-section .form-row {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--space-4);
  margin-bottom: var(--space-5);
}

@media (max-width: 768px) {
  .settings-section .form-row {
    grid-template-columns: 1fr;
  }
}

/* ===========================
   Settings Panel Styles
=========================== */
#chatView.hidden {
  display: none;
}

.settings-panel.hidden {
  display: none;
}
.settings-panel {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  background: var(--chat-bg);
  z-index: 50;
  overflow: hidden;
}

.settings-panel.hidden {
  display: none;
}

.settings-header {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  min-height: 88px;
  padding: var(--space-4) var(--space-5);
  border-bottom: 1px solid var(--border);
  background: var(--light);
  transition:
    background 0.3s,
    border-color 0.3s;
  position: relative;
  z-index: 100;
  flex-shrink: 0;
}

.settings-header h2 {
  font-size: var(--text-xl);
  line-height: var(--leading-tight);
  margin: 0;
}

.settings-header p {
  margin-top: 5px;
  color: var(--text-secondary);
  font-size: var(--text-sm);
}

.icon-back {
  display: grid;
  width: 40px;
  height: 40px;
  place-items: center;
  border: 0;
  border-radius: 50%;
  color: var(--text-secondary);
  background: var(--surface);
  cursor: pointer;
}

.settings-content {
  flex: 1;
  overflow-y: auto;
  padding: 24px clamp(24px, 5vw, 90px);
  scrollbar-color: #e0dede transparent;
  scrollbar-width: thin;
}

.settings-content::-webkit-scrollbar {
  width: 8px;
}

.settings-content::-webkit-scrollbar-track {
  background: transparent;
}

.settings-content::-webkit-scrollbar-thumb {
  border: 2px solid var(--chat-bg);
  border-radius: 999px;
  background: var(--secondary);
}

.settings-section {
  margin-bottom: var(--space-7);
  padding-bottom: var(--space-7);
  border-bottom: 1px solid var(--border);
}

.settings-section:last-of-type {
  border-bottom: none;
}

.settings-section h3 {
  font-size: var(--text-base);
  font-weight: var(--font-bold);
  color: var(--text-primary);
  margin: 0 0 var(--space-4) 0;
  padding-bottom: 8px;
  border-bottom: 2px solid var(--primary);
  display: inline-block;
}

.form-group {
  margin-bottom: var(--space-4);
}

.settings-section .form-group label {
  display: block;
  font-size: var(--text-xs);
  font-weight: var(--font-semibold);
  color: var(--text-secondary);
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.form-group input,
.form-group textarea {
  width: 100%;
  padding: var(--space-3) 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--card);
  color: var(--text-primary);
  font-size: var(--text-sm);
  font-family: inherit;
  transition:
    border-color 0.2s,
    box-shadow 0.2s;
  outline: none;
}

.form-group input:focus,
.form-group textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(0, 123, 255, 0.1);
}

.form-group input::placeholder,
.form-group textarea::placeholder {
  color: var(--text-secondary);
  opacity: 0.6;
}

.form-group textarea {
  resize: vertical;
  min-height: 80px;
  line-height: var(--leading-normal);
}

.input-wrapper {
  display: flex;
  align-items: center;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--card);
  transition:
    border-color 0.2s,
    box-shadow 0.2s;
  overflow: hidden;
}

.input-wrapper:focus-within {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(0, 123, 255, 0.1);
}

.input-prefix {
  padding: var(--space-3) 10px var(--space-3) 14px;
  color: var(--text-secondary);
  font-size: var(--text-sm);
  font-weight: var(--font-semibold);
  border-right: 1px solid var(--border);
  background: var(--surface);
  user-select: none;
}

.input-wrapper input {
  border: none;
  border-radius: 0;
  flex: 1;
  padding: var(--space-3) 14px;
  background: transparent;
  box-shadow: none;
}

.input-wrapper input:focus {
  box-shadow: none;
}

.password-wrapper {
  display: flex;
  align-items: center;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--card);
  transition:
    border-color 0.2s,
    box-shadow 0.2s;
  overflow: hidden;
}

.password-wrapper:focus-within {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(0, 123, 255, 0.1);
}

.password-wrapper input {
  border: none;
  border-radius: 0;
  flex: 1;
  padding: var(--space-3) 14px;
  background: transparent;
  box-shadow: none;
}

.password-wrapper input:focus {
  box-shadow: none;
}

.toggle-password {
  width: 44px;
  height: 44px;
  border: none;
  background: transparent;
  color: var(--text-secondary);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: var(--text-base);
  transition:
    color 0.2s,
    background 0.2s;
}

.brochure-info {
  background: var(--surface);
  border-radius: var(--radius-md);
  padding: 14px var(--space-4);
  margin-bottom: 14px;
  display: grid;
  grid-template-columns: 1fr 1fr;
}

.brochure-row {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  margin-bottom: var(--space-2);
}

.brochure-row:last-child {
  margin-bottom: 0;
}

.brochure-label {
  font-size: var(--text-xs);
  font-weight: var(--font-semibold);
  color: var(--text-secondary);
  min-width: 100px;
  flex-shrink: 0;
}

.brochure-value {
  font-size: var(--text-sm);
  color: var(--text-primary);
  word-break: break-all;
}

.brochure-note {
  margin-top: var(--space-3);
  padding: 10px var(--space-3);
  border-radius: var(--radius-md);
  background: #fff8e6;
  border: 1px solid #f5d67a;
  color: #8a6d3b;
  font-size: var(--text-xs);
  line-height: var(--leading-normal);
  grid-column: 1 / -1;
}

.brochure-note i {
  margin-right: 6px;
  color: #d97706;
}
[data-theme="dark"] .brochure-note {
  background: #3d3116;
  border: 1px solid #6b5215;
  color: #f4d58d;
}

[data-theme="dark"] .brochure-note i {
  color: #fbbf24;
}
.upload-brochure-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  width: 100%;
  padding: var(--space-3) var(--space-4);
  border: 1px dashed var(--border);
  border-radius: var(--radius-md);
  background: var(--surface);
  color: var(--text-primary);
  font-size: var(--text-sm);
  font-weight: var(--font-semibold);
  cursor: pointer;
  transition: all 0.2s ease;
  font-family: inherit;
}

.upload-brochure-btn:hover {
  border-color: var(--primary);
  background: var(--surface-hover);
  color: var(--primary);
}

.upload-brochure-btn i {
  font-size: var(--text-base);
}

.settings-footer {
  display: flex;
  justify-content: flex-end;
  padding-top: 8px;
}

.save-config-btn {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-3) 28px;
  border: none;
  border-radius: var(--radius-md);
  background: var(--primary);
  color: #ffffff;
  font-size: var(--text-sm);
  font-weight: var(--font-semibold);
  cursor: pointer;
  transition:
    background 0.2s,
    transform 0.2s;
  font-family: inherit;
}

.save-config-btn:hover {
  background: var(--accent-dark);
  transform: translateY(-1px);
}

.save-config-btn:active {
  transform: translateY(0);
}

.save-config-btn i {
  font-size: var(--text-base);
}

/* Dark theme settings panel */
[data-theme="dark"] .settings-panel {
  background: var(--chat-bg);
}

[data-theme="dark"] .settings-header {
  background: var(--light);
}

[data-theme="dark"] .brochure-info {
  background: rgba(255, 255, 255, 0.04);
}

[data-theme="dark"] .upload-brochure-btn {
  background: rgba(255, 255, 255, 0.04);
  border-color: #3b454b;
}

[data-theme="dark"] .upload-brochure-btn:hover {
  background: rgba(255, 255, 255, 0.08);
  border-color: var(--primary);
}

/* Mobile responsive for settings */
@media (max-width: 768px) {
  .settings-content {
    padding: var(--space-4);
  }

  .settings-header {
    min-height: 64px;
    padding: var(--space-3) var(--space-4);
  }

  .settings-header h2 {
    font-size: var(--text-lg);
  }
}

.brochure-actions {
  display: flex;
  gap: var(--space-3);
  margin-top: var(--space-4);
  font-family: inherit;
}

.open-brochure-btn,
.upload-brochure-btn,
.delete-brochure-btn {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
}

.open-brochure-btn {
  background: #fff;
  color: #2563eb;
  border: 1px solid #2563eb;
  font-family: inherit;
  font-size: var(--text-sm);
  font-weight: var(--font-semibold);
  cursor: pointer;
  transition: all 0.2s ease;
  border-radius: var(--radius-md);
}

.open-brochure-btn:hover {
  background: #eff6ff;
}

.delete-brochure-btn {
  background: #dc3545;
  color: #fff;
  border: none;
  padding: 10px 18px;
  border-radius: 8px;
  cursor: pointer;
}

.delete-brochure-btn:hover {
  background: #bb2d3b;
}

[data-theme="dark"] .open-brochure-btn {
  background: transparent;
  color: #60a5fa;
  border-color: #60a5fa;
}

[data-theme="dark"] .open-brochure-btn:hover {
  background: rgba(96, 165, 250, 0.12);
}

[hidden] {
    display: none !important;
}

/* Full-width application navigation above the dashboard. */
.global-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-6);
  min-height: 66px;
  padding: var(--space-3) 18px;
  background: var(--card);
}

.global-brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--text-primary);
  font-size: var(--text-base);
  font-weight: var(--font-extrabold);
  text-decoration: none;
  white-space: nowrap;
}

.brand-mark {
  display: grid;
  width: 32px;
  height: 32px;
  place-items: center;
  border-radius: 9px;
  color: #fff;
  background: var(--accent-dark);
  font-size: 10px;
}

.global-nav {
  margin-left: auto;
}

.global-nav #logoutButton:hover {
  color: #b42318;
  border-color: #fecdca;
  background: #fef3f2;
}

body > .app-shell {
  height: min(860px, calc(100vh - 116px));
  margin: 14px auto 17px;
}

/* Per-contact AI controls in the chat header. */
.chat-ai-controls {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  margin-left: auto;
}

.auto-reply-label {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  color: #52637d;
  font-size: var(--text-sm);
  font-weight: var(--font-bold);
}

.chat-header .chat-menu-wrapper {
  margin-left: var(--space-1);
}

.ai-switch {
  position: relative;
  display: inline-block;
  width: 68px;
  height: 36px;
}
.ai-switch input {
  width: 0;
  height: 0;
  opacity: 0;
}
.ai-switch-slider {
  position: absolute;
  inset: 0;
  border-radius: 999px;
  background: #98a2b3;
  cursor: pointer;
  transition: 0.2s;
}
.ai-switch-slider::before {
  position: absolute;
  content: "";
  width: 28px;
  height: 28px;
  left: var(--space-1);
  top: var(--space-1);
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 3px #0003;
  transition: 0.2s;
}
.ai-switch input:checked + .ai-switch-slider {
  background: #155eef;
}
.ai-switch input:checked + .ai-switch-slider::before {
  transform: translateX(32px);
}
.ai-switch input:focus + .ai-switch-slider {
  box-shadow: 0 0 0 3px #dbe7ff;
}
.ai-switch input:disabled + .ai-switch-slider {
  opacity: 0.5;
  cursor: not-allowed;
}

.contact-meta {
  display: flex;
  align-items: center;
  gap: var(--space-2);
}
.contact-meta p {
  margin: 5px 0 0;
}
.ai-status {
  margin-top: 5px;
  font-size: var(--text-x);
  font-weight: var(--font-bold);
  color: #b54708;
}
.ai-status.active {
  color: #067647;
}

@media (max-width: 700px) {
  .chat-header {
    flex-wrap: wrap;
    padding: var(--space-3);
  }
  .chat-ai-controls {
    width: 100%;
    margin-left: 0;
  }
  .chat-header .chat-menu-wrapper {
    margin-left: auto;
  }
  .auto-reply-label {
    font-size: var(--text-xs);
  }
}

@media (max-width: 768px) {
  .global-header {
    width: calc(100vw - 16px);
    margin-top: var(--space-2);
    padding: 9px;
    gap: var(--space-2);
  }
  .global-brand {
    display: none;
  }
  .global-nav {
    width: 100%;
    margin: 0;
    justify-content: space-between;
  }
  body > .app-shell {
    height: calc(100vh - 76px);
    margin-top: var(--space-2);
  }
}
