/* ═══════════════════════════════════════════════════════════
   WhatsApp Backup Viewer — Premium Dark Theme
   ═══════════════════════════════════════════════════════════ */

/* ─── Design Tokens ─────────────────────────────────── */
:root {
  /* WhatsApp-inspired palette */
  --wa-green-dark: #075E54;
  --wa-green: #128C7E;
  --wa-green-light: #25D366;
  --wa-teal: #00A884;
  --wa-blue: #53BDEB;

  /* Dark theme colors */
  --bg-primary: #111B21;
  --bg-secondary: #1F2C33;
  --bg-tertiary: #233138;
  --bg-hover: #2A3942;
  --bg-active: #2A3942;

  /* Chat bubbles */
  --bubble-outgoing: #005C4B;
  --bubble-outgoing-hover: #006B58;
  --bubble-incoming: #1F2C33;
  --bubble-incoming-hover: #263640;
  --bubble-system: rgba(255, 255, 255, 0.05);

  /* Text */
  --text-primary: #E9EDEF;
  --text-secondary: #8696A0;
  --text-tertiary: #667781;
  --text-green: #00A884;
  --text-link: #53BDEB;
  --text-timestamp: rgba(255, 255, 255, 0.45);

  /* Borders & Dividers */
  --border-color: rgba(134, 150, 160, 0.15);
  --divider-color: rgba(134, 150, 160, 0.08);

  /* Shadows */
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.5);

  /* Misc */
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
  --radius-xl: 22px;
  --transition: 200ms cubic-bezier(0.4, 0, 0.2, 1);
  --font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;

  /* Chat background pattern */
  --chat-bg: #0B141A;
}

/* ─── Reset & Base ──────────────────────────────────── */
*,
*::before,
*::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

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

body {
  font-family: var(--font);
  background: var(--bg-primary);
  color: var(--text-primary);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* ─── App Layout ────────────────────────────────────── */
.app {
  display: flex;
  height: 100vh;
  width: 100%;
  overflow: hidden;
}

/* ─── Sidebar ───────────────────────────────────────── */
.sidebar {
  width: 420px;
  min-width: 320px;
  max-width: 420px;
  display: flex;
  flex-direction: column;
  background: var(--bg-secondary);
  border-right: 1px solid var(--border-color);
  z-index: 10;
}

.sidebar-header {
  padding: 12px 16px;
  background: var(--bg-tertiary);
  border-bottom: 1px solid var(--border-color);
}

.sidebar-header-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

.logo {
  display: flex;
  align-items: center;
  gap: 10px;
}

.logo-icon {
  width: 28px;
  height: 28px;
  color: var(--wa-teal);
  filter: drop-shadow(0 0 8px rgba(0, 168, 132, 0.3));
}

.logo-text {
  font-size: 18px;
  font-weight: 600;
  color: var(--text-primary);
  letter-spacing: -0.3px;
}

/* ─── Search ────────────────────────────────────────── */
.search-box {
  position: relative;
}

.search-icon {
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  width: 16px;
  height: 16px;
  color: var(--text-tertiary);
  pointer-events: none;
}

.search-input {
  width: 100%;
  padding: 8px 14px 8px 40px;
  background: var(--bg-primary);
  border: none;
  border-radius: var(--radius-md);
  color: var(--text-primary);
  font-size: 13px;
  font-family: var(--font);
  outline: none;
  transition: var(--transition);
}

.search-input::placeholder {
  color: var(--text-tertiary);
}

.search-input:focus {
  box-shadow: 0 0 0 2px rgba(0, 168, 132, 0.3);
}

/* ─── Buttons ───────────────────────────────────────── */
.btn-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border: none;
  background: transparent;
  border-radius: 50%;
  cursor: pointer;
  color: var(--text-secondary);
  transition: var(--transition);
}

.btn-icon svg {
  width: 20px;
  height: 20px;
}

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

.btn-icon.btn-small {
  width: 32px;
  height: 32px;
}

.btn-icon.btn-small svg {
  width: 16px;
  height: 16px;
}

.btn-primary {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 14px 28px;
  background: linear-gradient(135deg, var(--wa-green) 0%, var(--wa-teal) 100%);
  color: white;
  border: none;
  border-radius: var(--radius-xl);
  font-size: 15px;
  font-weight: 600;
  font-family: var(--font);
  cursor: pointer;
  transition: var(--transition);
  box-shadow: 0 4px 16px rgba(0, 168, 132, 0.3);
}

.btn-primary svg {
  width: 20px;
  height: 20px;
}

.btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 24px rgba(0, 168, 132, 0.4);
}

.btn-primary:active {
  transform: translateY(0);
}

/* ─── Account Bar ───────────────────────────────────── */
.account-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 16px;
  background: var(--bg-primary);
  border-bottom: 1px solid var(--divider-color);
}

.account-selector {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  padding: 4px 10px;
  border-radius: 8px;
  transition: var(--transition);
}

.account-selector:hover {
  background: var(--bg-hover);
}

.account-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
  transition: background 0.3s ease;
}

.account-dot.status-active {
  background: #25D366 !important;
  box-shadow: 0 0 6px rgba(37, 211, 102, 0.4);
  animation: dotPulse 2s ease-in-out infinite;
}

.account-dot.status-empty {
  background: #6B7B8D !important;
  opacity: 0.7;
}

@keyframes dotPulse {

  0%,
  100% {
    box-shadow: 0 0 4px rgba(37, 211, 102, 0.3);
  }

  50% {
    box-shadow: 0 0 10px rgba(37, 211, 102, 0.6);
  }
}

.account-option-dot.status-active {
  background: #25D366 !important;
  box-shadow: 0 0 4px rgba(37, 211, 102, 0.3);
}

.account-option-dot.status-empty {
  background: #6B7B8D !important;
  opacity: 0.6;
}

.account-label {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-primary);
}

.account-user {
  display: flex;
  align-items: center;
  gap: 4px;
}

.account-dropdown {
  background: var(--bg-primary);
  border-bottom: 1px solid var(--divider-color);
  padding: 4px 8px;
  animation: slideDown 0.15s ease;
}

@keyframes slideDown {
  from {
    opacity: 0;
    max-height: 0;
  }

  to {
    opacity: 1;
    max-height: 200px;
  }
}

.account-dropdown.hidden {
  display: none;
}

.account-list .account-option {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  border-radius: 8px;
  cursor: pointer;
  transition: var(--transition);
  font-size: 13px;
  color: var(--text-primary);
  border: none;
  background: none;
  width: 100%;
  text-align: left;
}

.account-list .account-option:hover {
  background: var(--bg-hover);
}

.account-list .account-option.active {
  background: rgba(0, 168, 132, 0.1);
  color: var(--wa-teal);
}

.account-list .account-option .account-option-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

.account-list .account-option .account-option-count {
  margin-left: auto;
  font-size: 11px;
  color: var(--text-tertiary);
}

.account-add-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 8px 12px;
  border: 1px dashed var(--border-color);
  background: none;
  color: var(--text-secondary);
  font-size: 12px;
  font-family: var(--font);
  border-radius: 8px;
  cursor: pointer;
  transition: var(--transition);
  margin-top: 4px;
}

.account-add-btn:hover {
  border-color: var(--wa-teal);
  color: var(--wa-teal);
  background: rgba(0, 168, 132, 0.05);
}

.account-delete-btn {
  margin-left: 4px;
  font-size: 13px;
  opacity: 0.4;
  cursor: pointer;
  transition: var(--transition);
  padding: 2px 4px;
  border-radius: 4px;
}

.account-delete-btn:hover {
  opacity: 1;
  background: rgba(255, 80, 80, 0.15);
}

/* ─── Chat Filter Tabs (WhatsApp-style) ──────────── */
.chat-filters {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  background: var(--bg-primary);
  border-bottom: 1px solid var(--divider-color);
  overflow-x: auto;
  scrollbar-width: none;
  -ms-overflow-style: none;
}

.chat-filters::-webkit-scrollbar {
  display: none;
}

.chat-filter-btn {
  flex-shrink: 0;
  padding: 5px 14px;
  border: none;
  border-radius: 18px;
  background: var(--bg-tertiary);
  color: var(--text-secondary);
  font-family: var(--font);
  font-size: 12.5px;
  font-weight: 400;
  cursor: pointer;
  transition: all 0.2s ease;
  white-space: nowrap;
  line-height: 1.4;
}

.chat-filter-btn:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

.chat-filter-btn.active {
  background: var(--wa-teal);
  color: #111B21;
  font-weight: 500;
}

/* ─── Contact List ──────────────────────────────────── */
.contact-list {
  flex: 1;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: var(--bg-hover) transparent;
}

.contact-list::-webkit-scrollbar {
  width: 6px;
}

.contact-list::-webkit-scrollbar-track {
  background: transparent;
}

.contact-list::-webkit-scrollbar-thumb {
  background: var(--bg-hover);
  border-radius: 3px;
}

.contact-item {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 16px;
  cursor: pointer;
  transition: var(--transition);
  border-bottom: 1px solid var(--divider-color);
  position: relative;
}

.contact-item:hover {
  background: var(--bg-hover);
}

.contact-item.active {
  background: var(--bg-active);
}

.contact-item.active::before {
  content: '';
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 3px;
  background: var(--wa-teal);
  border-radius: 0 3px 3px 0;
}

/* Protected chat styling */
.contact-item.is-protected {
  border-left: 2px solid rgba(78, 205, 196, 0.3);
}

.contact-item.is-protected .contact-avatar {
  box-shadow: 0 0 0 2px rgba(78, 205, 196, 0.25);
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: scale(0.95);
  }

  to {
    opacity: 1;
    transform: scale(1);
  }
}

.contact-avatar {
  flex-shrink: 0;
  width: 50px;
  height: 50px;
  border-radius: 50%;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  font-weight: 600;
  color: white;
  text-transform: uppercase;
  position: relative;
}

.contact-info {
  flex: 1;
  min-width: 0;
  overflow: hidden;
}

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

.contact-last-message {
  font-size: 13px;
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-top: 3px;
  display: flex;
  align-items: center;
  gap: 4px;
}

.contact-meta {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 6px;
  flex-shrink: 0;
}

.contact-time {
  font-size: 11px;
  color: var(--text-tertiary);
  white-space: nowrap;
}

.contact-badge {
  min-width: 20px;
  height: 20px;
  border-radius: 10px;
  background: var(--wa-teal);
  color: white;
  font-size: 11px;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 6px;
}

.contact-list-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 40px 20px;
  color: var(--text-tertiary);
  text-align: center;
  gap: 12px;
}

.contact-list-empty svg {
  width: 48px;
  height: 48px;
  opacity: 0.3;
}

/* ─── Chat Divider (between pinned and regular) ───── */
.chat-divider {
  height: 1px;
  background: var(--divider-color);
  margin: 0 16px;
  opacity: 0.5;
}

/* ─── Pinned Chats ─────────────────────────────────── */
.contact-item.is-pinned {
  background: rgba(78, 205, 196, 0.03);
}

/* ─── Archived Section ─────────────────────────────── */
.archived-section {
  border-top: 1px solid var(--divider-color);
  margin-top: 4px;
}

.archived-toggle {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 14px 20px;
  background: none;
  border: none;
  color: var(--wa-teal);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s ease;
}

.archived-toggle:hover {
  background: var(--bg-hover);
}

.archived-count {
  font-size: 11px;
  background: rgba(78, 205, 196, 0.15);
  color: var(--wa-teal);
  padding: 2px 8px;
  border-radius: 10px;
  font-weight: 600;
}

.archived-list {
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.3s ease;
}

.archived-section.expanded .archived-list {
  max-height: 5000px;
}

.archived-section.expanded .archived-chevron {
  transform: rotate(180deg);
}

.archived-list .contact-item {
  opacity: 0.75;
}

.archived-list .contact-item:hover {
  opacity: 1;
}

/* ─── Main Area ─────────────────────────────────────── */
.main-area {
  flex: 1;
  display: flex;
  flex-direction: column;
  background: var(--chat-bg);
  position: relative;
  overflow: hidden;
}

/* ─── Empty State ───────────────────────────────────── */
.empty-state {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100%;
  background: var(--bg-primary);
  padding: 40px;
}

.empty-state-content {
  max-width: 520px;
  text-align: center;
}

.empty-state-icon {
  width: 80px;
  height: 80px;
  margin: 0 auto 24px;
  color: var(--wa-teal);
  opacity: 0.6;
  animation: float 3s ease-in-out infinite;
}

.empty-state-icon svg {
  width: 100%;
  height: 100%;
}

@keyframes float {

  0%,
  100% {
    transform: translateY(0);
  }

  50% {
    transform: translateY(-10px);
  }
}

.empty-state h2 {
  font-size: 28px;
  font-weight: 300;
  color: var(--text-primary);
  margin-bottom: 12px;
  letter-spacing: -0.5px;
}

.empty-state>.empty-state-content>p {
  font-size: 14px;
  color: var(--text-secondary);
  line-height: 1.6;
  margin-bottom: 32px;
}

.empty-state-steps {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-bottom: 32px;
  text-align: left;
}

.step {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 12px 16px;
  background: var(--bg-secondary);
  border-radius: var(--radius-md);
  font-size: 13px;
  color: var(--text-secondary);
  border: 1px solid var(--border-color);
}

.step-number {
  flex-shrink: 0;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--wa-teal);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 700;
}

/* ─── Chat View ─────────────────────────────────────── */
.chat-view {
  display: flex;
  flex-direction: column;
  height: 100%;
}

.chat-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 16px;
  background: var(--bg-tertiary);
  border-bottom: 1px solid var(--border-color);
  min-height: 60px;
  z-index: 5;
}

.btn-back {
  display: none;
}

.chat-avatar {
  flex-shrink: 0;
  width: 42px;
  height: 42px;
  border-radius: 50%;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  font-weight: 600;
  color: white;
  text-transform: uppercase;
}

.chat-header-info {
  flex: 1;
  min-width: 0;
}

.chat-contact-name {
  font-size: 16px;
  font-weight: 500;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.chat-subtitle {
  font-size: 12px;
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-top: 1px;
}

.chat-header-actions {
  display: flex;
  gap: 4px;
}

/* ─── Chat Search Bar ───────────────────────────────── */
.chat-search-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 16px;
  background: var(--bg-tertiary);
  border-bottom: 1px solid var(--border-color);
}

.chat-search-bar .search-input {
  flex: 1;
}

.chat-search-count {
  font-size: 12px;
  color: var(--text-tertiary);
  white-space: nowrap;
}

/* ─── Chat Messages ─────────────────────────────────── */
.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px 60px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  background: var(--chat-bg);
  background-image: url("data:image/svg+xml,%3Csvg width='60' height='60' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M30 5 L35 15 L30 12 L25 15 Z' fill='%23ffffff' fill-opacity='0.02'/%3E%3Cpath d='M10 35 L15 45 L10 42 L5 45 Z' fill='%23ffffff' fill-opacity='0.015'/%3E%3Cpath d='M50 40 L55 50 L50 47 L45 50 Z' fill='%23ffffff' fill-opacity='0.02'/%3E%3C/svg%3E");
  scrollbar-width: thin;
  scrollbar-color: rgba(134, 150, 160, 0.2) transparent;
}

.chat-messages::-webkit-scrollbar {
  width: 6px;
}

.chat-messages::-webkit-scrollbar-track {
  background: transparent;
}

.chat-messages::-webkit-scrollbar-thumb {
  background: rgba(134, 150, 160, 0.2);
  border-radius: 3px;
}

/* Date divider */
.date-divider {
  display: flex;
  justify-content: center;
  margin: 16px 0;
}

.date-divider-label {
  padding: 5px 14px;
  background: rgba(17, 27, 33, 0.9);
  border-radius: var(--radius-md);
  font-size: 12px;
  color: var(--text-secondary);
  box-shadow: var(--shadow-sm);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

/* Message bubbles */
.message-row {
  display: flex;
  margin-bottom: 1px;
  animation: messageIn 0.2s ease-out;
}

@keyframes messageIn {
  from {
    opacity: 0;
    transform: translateY(8px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

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

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

.message-bubble {
  max-width: 65%;
  min-width: 100px;
  padding: 6px 8px 6px 9px;
  border-radius: var(--radius-md);
  position: relative;
  word-wrap: break-word;
  overflow-wrap: break-word;
  line-height: 1.45;
  font-size: 14px;
}

.message-row.outgoing .message-bubble {
  background: var(--bubble-outgoing);
  border-top-right-radius: 4px;
}

.message-row.incoming .message-bubble {
  background: var(--bubble-incoming);
  border-top-left-radius: 4px;
}

/* Tail on first message of a group */
.message-row.outgoing.has-tail .message-bubble {
  border-top-right-radius: 0;
}

.message-row.incoming.has-tail .message-bubble {
  border-top-left-radius: 0;
}

.message-row.outgoing.has-tail .message-bubble::after {
  content: '';
  position: absolute;
  top: 0;
  right: -8px;
  width: 8px;
  height: 13px;
  background: var(--bubble-outgoing);
  clip-path: polygon(0 0, 0 100%, 100% 0);
}

.message-row.incoming.has-tail .message-bubble::before {
  content: '';
  position: absolute;
  top: 0;
  left: -8px;
  width: 8px;
  height: 13px;
  background: var(--bubble-incoming);
  clip-path: polygon(100% 0, 0 0, 100% 100%);
}

/* Sender name in group chats */
.message-sender {
  font-size: 13px;
  font-weight: 500;
  margin-bottom: 2px;
  color: var(--wa-teal);
}

.message-text {
  color: var(--text-primary);
}

.message-text a {
  color: var(--text-link);
  text-decoration: none;
}

.message-text a:hover {
  text-decoration: underline;
}

.message-meta {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 4px;
  margin-top: 2px;
  float: right;
  margin-left: 12px;
  position: relative;
  top: 5px;
}

.message-time {
  font-size: 11px;
  color: var(--text-timestamp);
  white-space: nowrap;
}

/* System messages */
.message-system {
  display: flex;
  justify-content: center;
  margin: 8px 0;
}

.message-system-text {
  padding: 5px 14px;
  background: rgba(255, 255, 255, 0.05);
  border-radius: var(--radius-md);
  font-size: 12px;
  color: var(--text-secondary);
  text-align: center;
  font-style: italic;
}

/* ─── Media in Messages ─────────────────────────────── */
.message-image {
  max-width: 330px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: var(--transition);
  display: block;
  margin-bottom: 4px;
}

.message-image:hover {
  opacity: 0.9;
}

.message-video {
  max-width: 330px;
  border-radius: var(--radius-sm);
  display: block;
  margin-bottom: 4px;
}

.message-audio {
  width: 280px;
  margin: 4px 0;
}

.message-document {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  background: rgba(0, 0, 0, 0.15);
  border-radius: var(--radius-sm);
  margin-bottom: 4px;
  text-decoration: none;
  color: var(--text-primary);
  transition: var(--transition);
}

.message-document:hover {
  background: rgba(0, 0, 0, 0.25);
}

.message-document-icon {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-sm);
  background: rgba(83, 189, 235, 0.15);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.message-document-icon svg {
  width: 20px;
  height: 20px;
  color: var(--text-link);
}

.message-document-name {
  font-size: 13px;
  font-weight: 500;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.message-document-size {
  font-size: 11px;
  color: var(--text-secondary);
  margin-top: 2px;
}

.message-media-omitted {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  background: rgba(0, 0, 0, 0.1);
  border-radius: var(--radius-sm);
  font-size: 12px;
  color: var(--text-tertiary);
  font-style: italic;
  margin-bottom: 4px;
}

.message-media-omitted svg {
  width: 16px;
  height: 16px;
  opacity: 0.5;
}

/* ─── Loading Spinner ───────────────────────────────── */
.loading-messages {
  display: flex;
  justify-content: center;
  padding: 20px;
}

.spinner {
  width: 32px;
  height: 32px;
  border: 3px solid var(--border-color);
  border-top-color: var(--wa-teal);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

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

/* ─── Modal ─────────────────────────────────────────── */
.modal {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  animation: fadeIn 0.2s ease-out;
}

@keyframes fadeIn {
  from {
    opacity: 0;
  }

  to {
    opacity: 1;
  }
}

.modal-backdrop {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}

.modal-content {
  position: relative;
  width: 90%;
  max-width: 480px;
  max-height: 85vh;
  overflow-y: auto;
  background: var(--bg-secondary);
  border-radius: var(--radius-lg);
  padding: 32px;
  box-shadow: var(--shadow-lg);
  border: 1px solid var(--border-color);
  scrollbar-width: thin;
  scrollbar-color: rgba(134, 150, 160, 0.3) transparent;
}

.modal-close {
  position: absolute;
  top: 12px;
  right: 12px;
}

.modal-title {
  font-size: 22px;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 8px;
}

.modal-subtitle {
  font-size: 13px;
  color: var(--text-secondary);
  margin-bottom: 24px;
}

/* ─── Drop Zone ─────────────────────────────────────── */
.drop-zone {
  position: relative;
  border: 2px dashed var(--border-color);
  border-radius: var(--radius-md);
  padding: 40px 20px;
  text-align: center;
  cursor: pointer;
  transition: var(--transition);
  overflow: hidden;
}

.drop-zone:hover,
.drop-zone.drag-over {
  border-color: var(--wa-teal);
  background: rgba(0, 168, 132, 0.05);
}

.drop-zone.drag-over {
  transform: scale(1.02);
}

.drop-zone-icon {
  width: 48px;
  height: 48px;
  color: var(--text-tertiary);
  margin: 0 auto 16px;
}

.drop-zone-text {
  font-size: 15px;
  font-weight: 500;
  color: var(--text-primary);
  margin-bottom: 6px;
}

.drop-zone-subtext {
  font-size: 13px;
  color: var(--text-secondary);
  margin-bottom: 8px;
}

.drop-zone-formats {
  font-size: 11px;
  color: var(--text-tertiary);
}

.file-input {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  cursor: pointer;
}

/* ─── Upload Progress ───────────────────────────────── */
.upload-progress {
  margin-top: 24px;
}

.progress-bar {
  height: 4px;
  background: var(--bg-primary);
  border-radius: 2px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--wa-green), var(--wa-teal), var(--wa-green-light));
  background-size: 200% 100%;
  border-radius: 2px;
  width: 0%;
  transition: width 0.3s ease;
  animation: shimmer 1.5s infinite;
}

@keyframes shimmer {
  0% {
    background-position: 200% 0;
  }

  100% {
    background-position: -200% 0;
  }
}

.progress-text {
  font-size: 13px;
  color: var(--text-secondary);
  text-align: center;
  margin-top: 12px;
}

/* ─── Upload Result ─────────────────────────────────── */
.upload-result {
  margin-top: 20px;
  padding: 16px;
  border-radius: var(--radius-md);
  font-size: 14px;
}

.upload-result.success {
  background: rgba(37, 211, 102, 0.1);
  border: 1px solid rgba(37, 211, 102, 0.2);
  color: var(--wa-green-light);
}

.upload-result.error {
  background: rgba(255, 107, 107, 0.1);
  border: 1px solid rgba(255, 107, 107, 0.2);
  color: #FF6B6B;
}

/* ─── Lightbox ──────────────────────────────────────── */
.lightbox {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.92);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
  cursor: zoom-out;
  animation: fadeIn 0.2s ease-out;
}

.lightbox-close {
  position: absolute;
  top: 16px;
  right: 16px;
  color: white;
  z-index: 201;
}

.lightbox-img {
  max-width: 90vw;
  max-height: 90vh;
  object-fit: contain;
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-lg);
}

/* ─── Search Results Highlight ──────────────────────── */
.search-highlight {
  background: rgba(255, 193, 7, 0.3);
  color: var(--text-primary);
  border-radius: 2px;
  padding: 0 2px;
}

/* ─── Cloud Sync Pulse ─────────────────────────────── */
@keyframes pulse {

  0%,
  100% {
    opacity: 1;
    transform: scale(1);
  }

  50% {
    opacity: 0.5;
    transform: scale(0.8);
  }
}

/* ─── Utility Classes ───────────────────────────────── */
.hidden {
  display: none !important;
}

/* ─── Responsive Design ─────────────────────────────── */
@media (max-width: 768px) {
  .sidebar {
    width: 100%;
    max-width: 100%;
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 20;
    transition: transform var(--transition);
  }

  .sidebar.hidden-mobile {
    transform: translateX(-100%);
  }

  .btn-back {
    display: flex;
  }

  .chat-messages {
    padding: 12px 16px;
  }

  .message-bubble {
    max-width: 85%;
  }

  .modal-content {
    width: 95%;
    padding: 24px;
  }

  .empty-state {
    padding: 20px;
  }

  .empty-state h2 {
    font-size: 22px;
  }
}

@media (max-width: 480px) {
  .sidebar-header-top {
    margin-bottom: 8px;
  }

  .contact-item {
    padding: 10px 12px;
  }

  .contact-avatar {
    width: 44px;
    height: 44px;
    font-size: 18px;
  }
}

/* ═══════════════════════════════════════════════════════════
   WhatsApp Web Bridge — Styles
   ═══════════════════════════════════════════════════════════ */

/* ─── Option Cards (Empty State) ────────────────────── */
.empty-state-options {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  max-width: 500px;
  margin: 0 auto;
}

.option-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  padding: 28px 20px;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  cursor: pointer;
  transition: all 0.3s ease;
  text-align: center;
}

.option-card:hover {
  background: var(--bg-tertiary);
  border-color: var(--wa-teal);
  transform: translateY(-4px);
  box-shadow: 0 8px 24px rgba(0, 168, 132, 0.2);
}

.option-card h3 {
  font-size: 15px;
  font-weight: 600;
  color: var(--text-primary);
}

.option-card p {
  font-size: 12px;
  color: var(--text-secondary);
  margin-bottom: 0;
  line-height: 1.4;
}

.option-icon {
  width: 48px;
  height: 48px;
  min-width: 48px;
  min-height: 48px;
  max-width: 48px;
  max-height: 48px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  flex-shrink: 0;
}

.option-icon svg {
  width: 24px;
  height: 24px;
}

.option-icon-wa {
  background: rgba(0, 168, 132, 0.15);
  color: var(--wa-teal);
}

.option-icon-upload {
  background: rgba(83, 189, 235, 0.15);
  color: var(--wa-blue);
}

.option-badge {
  padding: 4px 12px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 600;
  background: linear-gradient(135deg, var(--wa-green), var(--wa-teal));
  color: white;
}

.badge-secondary {
  background: rgba(134, 150, 160, 0.2);
  color: var(--text-secondary);
}

/* ─── WA Modal ──────────────────────────────────────── */
.wa-modal-content {
  max-width: 520px;
  max-height: 85vh;
  overflow-y: auto;
}

.wa-step {
  animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(10px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* QR Container */
.wa-qr-container {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 400px;
  margin: 20px 0;
  background: rgba(255, 255, 255, 0.03);
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
}

.wa-qr-loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  color: var(--text-secondary);
}

.spinner {
  width: 40px;
  height: 40px;
  border: 3px solid var(--border-color);
  border-top-color: var(--wa-teal);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

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

.wa-qr-image {
  width: 380px;
  height: 380px;
  border-radius: var(--radius-md);
  background: white;
  padding: 12px;
}

.wa-instructions {
  display: flex;
  flex-direction: column;
  gap: 8px;
  text-align: left;
}

/* ─── WA Chat List ──────────────────────────────────── */
.wa-chat-actions {
  display: flex;
  gap: 8px;
  margin-bottom: 16px;
}

.btn-secondary {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 20px;
  background: var(--bg-tertiary);
  color: var(--text-primary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-xl);
  font-size: 13px;
  font-weight: 500;
  font-family: var(--font);
  cursor: pointer;
  transition: var(--transition);
}

.btn-secondary:hover {
  background: var(--bg-hover);
  border-color: var(--wa-teal);
}

.btn-primary.btn-small,
.btn-secondary.btn-small {
  padding: 8px 16px;
  font-size: 13px;
}

.wa-chat-list {
  max-height: 400px;
  overflow-y: auto;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  scrollbar-width: thin;
  scrollbar-color: var(--bg-hover) transparent;
}

.wa-chat-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--divider-color);
  cursor: pointer;
  transition: var(--transition);
}

.wa-chat-item:hover {
  background: var(--bg-hover);
}

.wa-chat-item:last-child {
  border-bottom: none;
}

.wa-chat-checkbox {
  width: 20px;
  height: 20px;
  border-radius: 4px;
  border: 2px solid var(--text-tertiary);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: var(--transition);
}

.wa-chat-item.selected .wa-chat-checkbox {
  background: var(--wa-teal);
  border-color: var(--wa-teal);
}

.wa-chat-item.selected .wa-chat-checkbox::after {
  content: '✓';
  color: white;
  font-size: 12px;
  font-weight: bold;
}

.wa-chat-info {
  flex: 1;
  min-width: 0;
}

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

.wa-chat-preview {
  font-size: 12px;
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-top: 2px;
}

.wa-chat-status {
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 10px;
  flex-shrink: 0;
}

.wa-chat-status.backed-up {
  background: rgba(0, 168, 132, 0.15);
  color: var(--wa-teal);
}

.wa-chat-status.pending {
  background: rgba(255, 255, 255, 0.05);
  color: var(--text-tertiary);
}

/* ─── WA Progress ───────────────────────────────────── */
.wa-progress-info {
  margin: 24px 0;
}

.wa-progress-chat {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}

#wa-progress-name {
  font-size: 15px;
  font-weight: 500;
  color: var(--text-primary);
}

.wa-progress-count {
  font-size: 13px;
  color: var(--text-secondary);
}

.wa-progress-detail {
  font-size: 12px;
  color: var(--text-secondary);
  margin-top: 8px;
  text-align: center;
}

.wa-progress-log {
  max-height: 200px;
  overflow-y: auto;
  padding: 12px;
  background: rgba(0, 0, 0, 0.2);
  border-radius: var(--radius-md);
  font-family: 'SF Mono', 'Consolas', monospace;
  font-size: 11px;
  color: var(--text-secondary);
  line-height: 1.8;
}

.wa-progress-log .log-success {
  color: var(--wa-teal);
}

.wa-progress-log .log-error {
  color: #FF6B6B;
}

/* ─── WA Complete ───────────────────────────────────── */
.wa-complete-icon {
  font-size: 64px;
  margin-bottom: 16px;
  animation: bounceIn 0.5s ease;
}

@keyframes bounceIn {
  0% {
    transform: scale(0);
  }

  60% {
    transform: scale(1.2);
  }

  100% {
    transform: scale(1);
  }
}

/* ─── Responsive Overrides for WA ───────────────────── */
@media (max-width: 768px) {
  .empty-state-options {
    grid-template-columns: 1fr;
    gap: 12px;
  }

  .option-card {
    padding: 20px 16px;
  }

  .wa-modal-content {
    max-width: 95%;
  }
}

/* ─── Extraction Progress Banner ────────────────────── */
.extraction-banner {
  padding: 10px 16px 12px;
  background: linear-gradient(135deg, rgba(0, 168, 132, 0.12), rgba(18, 140, 126, 0.08));
  border-bottom: 1px solid rgba(0, 168, 132, 0.25);
  transition: all 0.3s ease;
}

.extraction-banner.hidden {
  display: none;
}

.extraction-banner.complete {
  background: linear-gradient(135deg, rgba(37, 211, 102, 0.15), rgba(0, 168, 132, 0.08));
}

.extraction-banner-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
}

.extraction-banner-icon {
  font-size: 14px;
  animation: spin 2s linear infinite;
}

.extraction-banner.complete .extraction-banner-icon {
  animation: none;
}

@keyframes spin {
  from {
    transform: rotate(0deg);
  }

  to {
    transform: rotate(360deg);
  }
}

.extraction-banner-title {
  flex: 1;
  font-size: 13px;
  font-weight: 600;
  color: var(--wa-teal);
}

.extraction-banner-percent {
  font-size: 14px;
  font-weight: 700;
  color: var(--wa-green-light);
  font-variant-numeric: tabular-nums;
}

.extraction-progress-bar {
  height: 6px;
  background: rgba(255, 255, 255, 0.08);
  border-radius: 3px;
  overflow: hidden;
  margin-bottom: 8px;
}

.extraction-progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--wa-green), var(--wa-green-light), var(--wa-teal));
  border-radius: 3px;
  width: 0%;
  transition: width 0.8s ease;
  position: relative;
}

.extraction-progress-fill::after {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.3), transparent);
  animation: shimmer 2s infinite;
}

@keyframes shimmer {
  0% {
    transform: translateX(-100%);
  }

  100% {
    transform: translateX(100%);
  }
}

.extraction-details {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
}

.extraction-details span {
  font-size: 11px;
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

#extraction-chat {
  flex: 1;
  min-width: 0;
}

#extraction-stats {
  flex-shrink: 0;
  color: var(--text-tertiary);
  font-variant-numeric: tabular-nums;
}

/* ─── Loading Spinner ────────────────────────────────── */
.spinner {
  width: 32px;
  height: 32px;
  border: 3px solid rgba(255, 255, 255, 0.15);
  border-top-color: var(--wa-green);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

.contact-phone {
  font-size: 11px;
  color: var(--text-tertiary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-top: -1px;
}