/* WhatsApp Web Replica & August CRM Kanban Styling - Executive Edition */
:root {
  --wa-green: #00a884;
  --wa-green-dark: #008069;
  --wa-green-light: #25d366;
  --wa-green-bubble: #d9fdd3;
  --wa-green-badge: #25d366;
  --wa-bg-chat: #efeae2;
  --wa-incoming: #ffffff;
  --wa-header: #f0f2f5;
  --wa-rail: #f0f2f5;
  --wa-border: #e9edef;
  --wa-text-primary: #111b21;
  --wa-text-secondary: #667781;
  --wa-text-muted: #8696a0;
  --wa-blue-tick: #53bdeb;
  --app-height: 100dvh;
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html, body {
  height: 100%;
  width: 100%;
  margin: 0;
  padding: 0;
  overflow: hidden;
  position: fixed;
  inset: 0;
  overscroll-behavior: none;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  color: var(--wa-text-primary);
  background-color: #d1d7db;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

.app-viewport-height {
  height: 100% !important;
  height: 100dvh !important;
  height: var(--app-height, 100dvh) !important;
  max-height: var(--app-height, 100dvh) !important;
}

#screen-app {
  height: 100%;
  height: 100dvh;
  height: var(--app-height, 100dvh);
  max-height: var(--app-height, 100dvh);
  width: 100%;
  overflow: hidden;
  position: relative;
}

/* WhatsApp Chat Background (Pure Solid Color #efeae2 for Maximum Speed & Zero GPU Lag) */
.wa-wallpaper {
  background-color: #efeae2 !important;
  background-image: none !important;
}

#chat-messages-container {
  background-color: #efeae2 !important;
  background-image: none !important;
  transform: translateZ(0);
  will-change: scroll-position;
  -webkit-overflow-scrolling: touch;
  scroll-behavior: auto;
}

/* Custom Scrollbar */
::-webkit-scrollbar {
  width: 5px;
  height: 5px;
}
::-webkit-scrollbar-track {
  background: transparent;
}
::-webkit-scrollbar-thumb {
  background: rgba(11, 20, 26, 0.18);
  border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
  background: rgba(11, 20, 26, 0.32);
}

/* WhatsApp Message Bubble Tails */
.bubble-tail-in::before {
  content: "";
  position: absolute;
  top: 0;
  left: -8px;
  width: 8px;
  height: 13px;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 8 13' width='8' height='13' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath opacity='0.13' fill='%23000000' d='M1.533 3.568L8 12.193V1H2.812C1.042 1 .474 2.156 1.533 3.568z'/%3E%3Cpath fill='%23ffffff' d='M1.533 2.568L8 11.193V0H2.812C1.042 0 .474 1.156 1.533 2.568z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
}

.bubble-tail-out::after {
  content: "";
  position: absolute;
  top: 0;
  right: -8px;
  width: 8px;
  height: 13px;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 8 13' width='8' height='13' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath opacity='0.13' fill='%23000000' d='M5.188 1H0v11.193l6.467-8.625C7.526 2.156 6.958 1 5.188 1z'/%3E%3Cpath fill='%23d9fdd3' d='M5.188 0H0v11.193l6.467-8.625C7.526 1.156 6.958 0 5.188 0z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
}

/* WhatsApp Double Checkmark Vector Colors */
.wa-tick-blue {
  color: #53bdeb !important;
}

.wa-tick-grey {
  color: #8696a0 !important;
}

/* Desktop Left Navigation Rail Item Styles */
.wa-rail-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  padding: 8px 10px;
  border-radius: 8px;
  color: #54656f;
  transition: all 0.12s ease;
  cursor: pointer;
  background: transparent;
  border: none;
  text-align: left;
}

.wa-rail-item:hover {
  background-color: #e9edef;
  color: #111b21;
}

.wa-rail-item.active {
  background-color: #e9edef;
  color: #111b21;
  font-weight: 600;
}

/* Kanban Drag & Drop Styles - Executive Edition */
.kanban-col {
  min-width: 315px;
  max-width: 315px;
  border-radius: 18px;
  background-color: #f8fafc;
  border: 1px solid rgba(226, 232, 240, 0.9);
  box-shadow: 0 1px 3px rgba(15, 23, 42, 0.04);
}

.kanban-card {
  transition: transform 0.2s cubic-bezier(0.16, 1, 0.3, 1), box-shadow 0.2s ease, border-color 0.2s ease;
  cursor: grab;
  background-color: #ffffff;
  border-radius: 14px;
  border: 1px solid rgba(226, 232, 240, 0.95);
  box-shadow: 0 1px 3px rgba(15, 23, 42, 0.04), 0 1px 2px rgba(15, 23, 42, 0.02);
}

.kanban-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 10px 20px -3px rgba(15, 23, 42, 0.08), 0 4px 6px -2px rgba(15, 23, 42, 0.04);
  border-color: rgba(0, 168, 132, 0.4);
}

.kanban-card:active {
  cursor: grabbing;
}

.kanban-card.dragging {
  opacity: 0.4;
  transform: rotate(1.5deg) scale(0.98);
}

.kanban-drop-zone.drag-over {
  background-color: rgba(0, 168, 132, 0.07) !important;
  border: 2px dashed #00a884 !important;
  border-radius: 16px;
}

/* Voice Message Audio Progress & Waveform */
.wa-waveform {
  display: flex;
  align-items: center;
  gap: 2px;
  height: 28px;
  cursor: pointer;
}

.wa-wave-bar {
  width: 2.5px;
  background-color: #cbd5e1;
  border-radius: 2px;
  transition: background-color 0.1s ease;
}

.wa-wave-bar.played {
  background-color: #00a884;
}

/* Image Message Flush Edge */
.wa-image-card {
  overflow: hidden;
  border-radius: 8px 8px 0 0;
  cursor: pointer;
  background: #0000000a;
}

.wa-image-card img {
  width: 100%;
  max-width: 360px;
  max-height: 380px;
  object-fit: cover;
  display: block;
}

.wa-quote-container {
  border-left: 3.5px solid #00a884;
  background: rgba(0, 0, 0, 0.04);
  border-radius: 0 6px 6px 0;
  padding: 4px 8px;
  margin-bottom: 4px;
}

/* Unread Divider Banner */
.wa-unread-divider {
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 12px 0;
}

.wa-unread-divider span {
  background: #ffffff;
  color: #54656f;
  font-size: 11.5px;
  font-weight: 500;
  padding: 4px 14px;
  border-radius: 8px;
  box-shadow: 0 1px 0.5px rgba(11,20,26,0.13);
}

/* Document File Card */
.wa-doc-card {
  background: rgba(0, 0, 0, 0.05);
  border-radius: 8px;
  padding: 8px 10px;
  display: flex;
  align-items: center;
  gap: 10px;
}

/* Touch & Instant Interaction Optimizations (Zero Tap Delay) */
*, *::before, *::after {
  -webkit-tap-highlight-color: transparent;
}

button, a, input, select, textarea, .chat-list-row, .wa-rail-item, [role="button"] {
  touch-action: manipulation;
}

/* Chat list row high performance & smooth touch feedback */
.chat-list-row {
  touch-action: manipulation;
  content-visibility: auto;
  contain-intrinsic-size: 72px;
  user-select: none;
  -webkit-user-select: none;
}

.chat-list-row:active {
  background-color: #e9edef !important;
}

/* ==================== MOBILE SCREEN RESPONSIVE STYLES (1:1 WHATSAPP MOBILE) ==================== */
@media (max-width: 767.98px) {
  /* Strictly hide desktop rail on mobile */
  #sidebar-rail {
    display: none !important;
  }

  /* Make sure app takes 100% of viewport without grey outer edges */
  body, #screen-app {
    background-color: #ffffff;
  }

  /* Header safe area on modern notched / Dynamic Island devices */
  .mobile-header-bar {
    padding-top: env(safe-area-inset-top, 0px) !important;
    height: calc(60px + env(safe-area-inset-top, 0px)) !important;
  }

  #sidebar-pane {
    width: 100% !important;
    height: 100% !important;
    height: var(--app-height, 100dvh) !important;
    max-height: var(--app-height, 100dvh) !important;
    position: fixed !important;
    inset: 0 !important;
    top: 0 !important;
    bottom: 0 !important;
    left: 0 !important;
    right: 0 !important;
    z-index: 20 !important;
    display: flex !important;
    flex-direction: column !important;
    will-change: transform;
    background-color: #ffffff;
  }

  /* Hide chat list when active chat is open */
  .mobile-hide-chat {
    display: none !important;
  }

  /* Expand chat pane to 100% width and exact dynamic height on mobile */
  .mobile-show-full {
    display: flex !important;
    flex-direction: column !important;
    width: 100% !important;
    height: var(--app-height, 100dvh) !important;
    max-height: var(--app-height, 100dvh) !important;
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    right: 0 !important;
    z-index: 30 !important;
    will-change: transform;
    animation: mobileSlideIn 0.1s cubic-bezier(0.16, 1, 0.3, 1);
    background-color: #ffffff;
    overflow: hidden !important;
  }

  @keyframes mobileSlideIn {
    from {
      transform: translate3d(24px, 0, 0);
      opacity: 0.96;
    }
    to {
      transform: translate3d(0, 0, 0);
      opacity: 1;
    }
  }

  /* Chat input bar safe-area padding for Safari floating bar and Chrome bottom bar */
  .wa-chat-input-bar {
    padding-bottom: max(12px, calc(env(safe-area-inset-bottom, 0px) + 8px)) !important;
    background-color: #f0f2f5 !important;
  }

  /* Position emoji, attachments, and snippet popups safely above the input bar */
  #emoji-dropdown, #attachment-menu, #snippets-dropdown {
    bottom: calc(56px + max(12px, env(safe-area-inset-bottom, 0px))) !important;
  }

  /* Support iOS safe area at bottom */
  #mobile-bottom-dock {
    padding-bottom: max(8px, calc(0.375rem + env(safe-area-inset-bottom, 0px))) !important;
  }
}
