:root {
  --bg-primary: #ffffff;
  --bg-secondary: #f0f2f5;
  --bg-tertiary: #ffffff;
  --accent-primary: #00a884;
  --accent-secondary: #008069;
  --text-primary: #111b21;
  --text-secondary: #667781;
  --text-dim: #8696a0;
  --bubble-out: #dcf8c6;
  --bubble-in: #ffffff;
  --status-blue: #53bdeb;
  --border-color: #e9edef;
  --shadow: 0 1px 0.5px rgba(0,0,0,0.13);
  --font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

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

body {
  margin: 0;
  padding: 0;
  font-family: var(--font-family);
  background-color: var(--bg-primary);
  color: var(--text-primary);
  overflow-x: hidden;
  height: 100vh;
  width: 100vw;
}

/* Layout Containers */
.app-container {
  display: flex;
  flex-direction: column;
  height: 100vh;
  width: 100%;
  position: relative;
}

.chat-view {
  display: flex;
  flex-direction: column;
  height: 100%;
  width: 100%;
  background-image: url('https://user-images.githubusercontent.com/15075759/28719144-86dc0f70-73b1-11e7-911d-60d70fcded21.png'); /* Traditional WhatsApp-style pattern */
  background-blend-mode: multiply;
  background-color: #efeae2; /* WhatsApp light mode chat background color */
  background-opacity: 0.06;
}

/* Header */
.header {
  height: 60px;
  background-color: #f0f2f5;
  display: flex;
  align-items: center;
  padding: 0 16px;
  gap: 12px;
  z-index: 100;
}

.header-back {
  display: flex;
  align-items: center;
  gap: 4px;
  cursor: pointer;
  color: var(--text-primary);
  min-width: 44px;
  min-height: 44px;
}

.avatar-container {
  position: relative;
  width: 40px;
  height: 40px;
}

.avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background-color: var(--text-dim);
  overflow: hidden;
}

.avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.status-indicator {
  position: absolute;
  bottom: 2px;
  right: 2px;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background-color: var(--accent-primary);
  border: 2px solid var(--bg-tertiary);
}

.header-info {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  overflow: hidden;
}

.header-name {
  font-weight: 600;
  font-size: 16px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.header-status {
  font-size: 12px;
  color: var(--text-secondary);
}

.header-actions {
  display: flex;
  gap: 20px;
  color: var(--text-secondary);
}

.header-icon {
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 40px;
  min-height: 40px;
}

/* Chat Body */
.chat-body {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  scroll-behavior: smooth;
}

.date-separator {
  align-self: center;
  background-color: #ffffff;
  padding: 6px 12px;
  border-radius: 8px;
  font-size: 12.5px;
  color: #54656f;
  margin: 16px 0;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  box-shadow: 0 1px 0.5px rgba(0,0,0,0.13);
}

.message-wrapper {
  max-width: 85%;
  display: flex;
  flex-direction: column;
  position: relative;
}

.message-wrapper.out {
  align-self: flex-end;
}

.message-wrapper.in {
  align-self: flex-start;
}

.message-bubble {
  padding: 8px 12px;
  border-radius: 8px;
  position: relative;
  font-size: 14.5px;
  line-height: 1.4;
  box-shadow: var(--shadow);
}

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

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

.reply-preview {
  background: rgba(0,0,0,0.05);
  border-left: 4px solid var(--accent-primary);
  border-radius: 4px;
  padding: 4px 8px;
  margin-bottom: 4px;
  font-size: 12px;
}

.reply-preview .reply-name {
  font-weight: bold;
  color: var(--accent-primary);
}

.message-meta {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 4px;
  margin-top: 4px;
  font-size: 11px;
  color: var(--text-secondary);
}

.message-wrapper.out .message-meta {
  color: #667781;
}

.status-icon {
  display: flex;
}

/* Media */
.media-container {
  margin-bottom: 4px;
  border-radius: 6px;
  overflow: hidden;
  background: var(--bg-primary);
}

.media-image {
  width: 100%;
  display: block;
}

.media-file {
  display: flex;
  align-items: center;
  gap: 12px;
  background: rgba(0,0,0,0.05);
  padding: 10px;
  border-radius: 6px;
}

.file-icon {
  width: 40px;
  height: 40px;
  background: var(--bg-tertiary);
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.file-info {
  flex: 1;
}

.file-name {
  font-size: 14px;
  font-weight: 500;
}

.file-size {
  font-size: 11px;
  color: var(--text-secondary);
}

/* Input Bar */
.input-bar {
  background-color: #f0f2f5;
  padding: 8px 12px;
  display: flex;
  align-items: flex-end;
  gap: 8px;
  min-height: 60px;
}

.input-container {
  flex: 1;
  background-color: #ffffff;
  border-radius: 24px;
  display: flex;
  align-items: flex-end;
  padding: 8px 12px;
  gap: 12px;
}

.input-field {
  flex: 1;
  background: transparent;
  border: none;
  outline: none;
  color: var(--text-primary);
  font-size: 16px;
  max-height: 120px;
  overflow-y: auto;
  padding: 4px 0;
  resize: none;
}

.input-icon {
  color: var(--text-secondary);
  cursor: pointer;
  padding: 4px;
}

.send-btn {
  width: 45px;
  height: 45px;
  border-radius: 50%;
  background-color: var(--accent-primary);
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  flex-shrink: 0;
  cursor: pointer;
  box-shadow: var(--shadow);
}

/* Pinned Banner */
.pinned-banner {
  background-color: #ffffff;
  padding: 8px 16px;
  display: flex;
  align-items: center;
  gap: 12px;
  border-bottom: 1px solid var(--border-color);
  font-size: 13px;
  color: var(--text-secondary);
}

.pinned-content {
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: var(--text-primary);
}

/* Modals & Overlays */
.overlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0,0,0,0.8);
  z-index: 1000;
  display: flex;
  flex-direction: column;
}

.bottom-sheet {
  margin-top: auto;
  background: var(--bg-secondary);
  border-top-left-radius: 20px;
  border-top-right-radius: 20px;
  padding: 20px;
  animation: slideUp 0.3s ease-out;
}

@keyframes slideUp {
  from { transform: translateY(100%); }
  to { transform: translateY(0); }
}

.menu-item {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 16px 12px;
  font-size: 16px;
  border-bottom: 1px solid var(--border-color);
  margin: 0 -12px;
}

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

.menu-item.danger {
  color: #ef5350;
}

/* Typing Indicator */
.typing-indicator {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 4px 12px;
  font-size: 12px;
  color: var(--accent-primary);
  font-style: italic;
}

.dot {
  width: 4px;
  height: 4px;
  background: var(--accent-primary);
  border-radius: 50%;
  animation: bounce 1.4s infinite ease-in-out both;
}

.dot:nth-child(1) { animation-delay: -0.32s; }
.dot:nth-child(2) { animation-delay: -0.16s; }

@keyframes bounce {
  0%, 80%, 100% { transform: scale(0); }
  40% { transform: scale(1); }
}

/* Responsive Adjustments */
@media (max-width: 600px) {
  .header {
    padding: 0 12px;
    gap: 8px;
  }

  .header-actions {
    gap: 12px;
  }

  .header-name {
    font-size: 15px;
  }

  .header-status {
    font-size: 11px;
  }

  .message-wrapper {
    max-width: 90%;
  }

  .message-bubble {
    font-size: 14px;
    padding: 6px 10px;
  }

  .input-bar {
    padding: 6px 8px;
    gap: 6px;
  }

  .input-container {
    padding: 6px 10px;
    gap: 8px;
  }

  .input-field {
    font-size: 14px;
  }

  .send-btn {
    width: 40px;
    height: 40px;
  }

  /* Settings Page Adjustments */
  .profile-avatar {
    width: 100px;
    height: 100px;
  }

  .quick-actions {
    gap: 20px;
  }

  .attachment-grid {
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
    padding: 12px;
  }

  .attachment-icon {
    width: 50px;
    height: 50px;
  }

  .attachment-label {
    font-size: 11px;
  }
}

/* UI Helpers */
.badge {
  background: var(--accent-primary);
  color: white;
  padding: 2px 6px;
  border-radius: 10px;
  font-size: 10px;
  font-weight: bold;
}

.placeholder-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: linear-gradient(135deg, #1f2c33, #0b141a);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-secondary);
}

.reaction-bar {
  display: flex;
  gap: 8px;
  background: var(--bg-tertiary);
  padding: 4px 12px;
  border-radius: 20px;
  position: absolute;
  top: -30px;
  left: 0;
  box-shadow: var(--shadow);
  z-index: 10;
}

.reaction-bubble {
  position: absolute;
  bottom: -10px;
  right: -5px;
  background: var(--bg-tertiary);
  padding: 2px 4px;
  border-radius: 10px;
  font-size: 10px;
  display: flex;
  gap: 2px;
  border: 1px solid var(--border-color);
}

/* Attachment Grid */
.attachment-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 20px;
    padding: 20px;
}

.attachment-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    cursor: pointer;
}

.attachment-icon {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    box-shadow: var(--shadow);
}

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

/* Settings / Group Info */
.profile-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 30px 20px;
    background: var(--bg-tertiary);
}

.profile-avatar {
    width: 120px;
    height: 120px;
    border-radius: 50%;
    margin-bottom: 16px;
    overflow: hidden;
}

.profile-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.profile-name {
    margin: 0;
    font-size: 22px;
    font-weight: 600;
}

.profile-subtitle {
    color: var(--text-secondary);
    margin: 8px 0;
}

.quick-actions {
    display: flex;
    gap: 30px;
    margin-top: 20px;
}

.quick-action-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    color: var(--accent-primary);
    cursor: pointer;
}

.quick-action-label {
    font-size: 12px;
}

.section-label {
    margin-top: 20px;
    font-size: 14px;
    color: var(--accent-primary);
    font-weight: 600;
    padding: 8px 0;
}

.item-main {
    flex: 1;
}

.item-title {
    font-weight: 500;
}

.item-subtitle {
    font-size: 13px;
    color: var(--text-secondary);
}

/* Message Actions Specific */
.action-message-container {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: flex-end;
    padding: 20px;
    height: 40%;
}

.switch-placeholder {
    width: 40px;
    height: 20px;
    background: var(--bg-tertiary);
    border-radius: 10px;
    position: relative;
}

.switch-knob {
    width: 16px;
    height: 16px;
    background: white;
    border-radius: 50%;
    position: absolute;
    top: 2px;
    left: 2px;
}
