/* ========================================
   MATERIAL DESIGN 3 - MESSAGE STYLES
   Abie Messenger
   ======================================== */

/* ========================================
   CONTEXT MENU
   ======================================== */
.context-menu {
  position: absolute;
  background: var(--md-sys-color-surface-container);
  border: 1px solid var(--md-sys-color-outline-variant);
  border-radius: var(--md-sys-shape-corner-medium);
  box-shadow: var(--md-sys-elevation-level2);
  padding: 8px 0;
  z-index: 9999;
  min-width: 200px;
  animation: md-scale-in var(--md-sys-motion-duration-medium2) var(--md-sys-motion-easing-emphasized-decelerate);
}

.context-menu-item {
  padding: 12px 16px;
  cursor: pointer;
  font-family: var(--md-sys-typescale-body-medium-font-family);
  font-size: var(--md-sys-typescale-body-medium-font-size);
  color: var(--md-sys-color-on-surface);
  transition: background var(--md-sys-motion-duration-short3) var(--md-sys-motion-easing-standard);
  display: flex;
  align-items: center;
  gap: 12px;
  position: relative;
}

.context-menu-item::before {
  content: '';
  position: absolute;
  inset: 0;
  background: currentColor;
  opacity: 0;
  transition: opacity var(--md-sys-motion-duration-short3) var(--md-sys-motion-easing-standard);
}

.context-menu-item:hover::before {
  opacity: var(--md-sys-state-hover-opacity);
}

.context-menu-item.danger {
  color: var(--md-sys-color-error);
}

.context-menu-item.danger:hover {
  background: var(--md-sys-color-error-container);
}

/* ========================================
   REPLY PANEL
   ======================================== */
.reply-panel {
  padding: 12px 20px;
  background: var(--md-sys-color-primary-container);
  border-left: 4px solid var(--md-sys-color-primary);
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin: 0 24px;
  border-radius: var(--md-sys-shape-corner-medium) var(--md-sys-shape-corner-medium) 0 0;
  animation: md-slide-in-bottom var(--md-sys-motion-duration-medium2) var(--md-sys-motion-easing-emphasized-decelerate);
}

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

.reply-panel-label {
  font-family: var(--md-sys-typescale-label-medium-font-family);
  font-size: var(--md-sys-typescale-label-medium-font-size);
  font-weight: var(--md-sys-typescale-label-medium-font-weight);
  color: var(--md-sys-color-primary);
  margin-bottom: 4px;
}

.reply-panel-text {
  font-family: var(--md-sys-typescale-body-small-font-family);
  font-size: var(--md-sys-typescale-body-small-font-size);
  color: var(--md-sys-color-on-primary-container);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.reply-panel-close {
  background: none;
  border: none;
  font-size: 18px;
  color: var(--md-sys-color-on-primary-container);
  cursor: pointer;
  padding: 8px;
  border-radius: var(--md-sys-shape-corner-full);
  transition: all var(--md-sys-motion-duration-short3) var(--md-sys-motion-easing-standard);
  position: relative;
}

.reply-panel-close::before {
  content: '';
  position: absolute;
  inset: 0;
  background: currentColor;
  opacity: 0;
  border-radius: inherit;
  transition: opacity var(--md-sys-motion-duration-short3) var(--md-sys-motion-easing-standard);
}

.reply-panel-close:hover::before {
  opacity: var(--md-sys-state-hover-opacity);
}

/* ========================================
   MESSAGE BUBBLE (container for reply + text)
   ======================================== */
.message-bubble {
  display: inline-block;
  max-width: 70%;
  border-radius: var(--md-sys-shape-corner-large);
  overflow: hidden;
}

.message-bubble.has-reply {
  background: var(--md-sys-color-surface-container-high);
}

.message.own .message-bubble.has-reply {
  background: var(--md-sys-color-primary-container);
}

.message-bubble.has-reply .message-text {
  background: transparent;
  border-radius: 0;
}

/* ========================================
   REPLY IN MESSAGE
   ======================================== */
.message-reply {
  background: var(--md-sys-color-tertiary-container);
  border-left: 3px solid var(--md-sys-color-tertiary);
  padding: 8px 12px;
  margin: 0;
  border-radius: 0;
  cursor: pointer;
  transition: background var(--md-sys-motion-duration-short3) var(--md-sys-motion-easing-standard);
}

.message-reply:hover {
  background: color-mix(in srgb, var(--md-sys-color-tertiary-container) 85%, var(--md-sys-color-tertiary) 15%);
}

.message-reply-author {
  font-family: var(--md-sys-typescale-label-medium-font-family);
  font-size: var(--md-sys-typescale-label-medium-font-size);
  font-weight: 600;
  color: var(--md-sys-color-tertiary);
  margin-bottom: 2px;
}

.message-reply-text {
  font-family: var(--md-sys-typescale-body-small-font-family);
  font-size: var(--md-sys-typescale-body-small-font-size);
  color: var(--md-sys-color-on-tertiary-container);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Own message reply */
.message.own .message-reply {
  background: color-mix(in srgb, var(--md-sys-color-primary) 20%, var(--md-sys-color-primary-container) 80%);
  border-left: 3px solid var(--md-sys-color-primary);
  border-right: none;
  text-align: left;
}

.message.own .message-reply:hover {
  background: color-mix(in srgb, var(--md-sys-color-primary) 30%, var(--md-sys-color-primary-container) 70%);
}

.message.own .message-reply-author {
  color: var(--md-sys-color-primary);
  font-weight: 600;
}

.message.own .message-reply-text {
  color: var(--md-sys-color-on-primary-container);
}

/* Бордер на всём bubble для сообщений с reply */
.message-bubble.has-reply {
  border-left: 3px solid var(--md-sys-color-tertiary);
}

.message.own .message-bubble.has-reply {
  border-left: none;
  border-right: 3px solid var(--md-sys-color-primary);
}

/* Убираем двойной бордер с reply внутри bubble */
.message-bubble.has-reply .message-reply {
  border-left: none;
  border-right: none;
}

/* ========================================
   MESSAGE HIGHLIGHT (при переходе к ответу)
   ======================================== */
.message-bubble.highlight,
.message-bubble.highlight .message-text,
.message-text.highlight {
  background: var(--md-sys-color-tertiary) !important;
  color: var(--md-sys-color-on-tertiary) !important;
  transition: background 0.3s ease-out, color 0.3s ease-out;
}

.message-bubble.highlight-fade,
.message-bubble.highlight-fade .message-text,
.message-text.highlight-fade {
  background: var(--md-sys-color-surface-container-high) !important;
  transition: background 1.5s ease-out, color 1.5s ease-out;
}

.message.own .message-bubble.highlight-fade,
.message.own .message-bubble.highlight-fade .message-text,
.message.own .message-text.highlight-fade {
  background: var(--md-sys-color-primary-container) !important;
  color: var(--md-sys-color-on-primary-container) !important;
}

/* ========================================
   MESSAGE EDITING
   ======================================== */
.message.editing {
  background: var(--md-sys-color-tertiary-container);
}

.message-edit-input {
  width: 100%;
  padding: 12px;
  border: 2px solid var(--md-sys-color-primary);
  border-radius: var(--md-sys-shape-corner-extra-small);
  font-family: var(--md-sys-typescale-body-large-font-family);
  font-size: var(--md-sys-typescale-body-large-font-size);
  resize: vertical;
  min-height: 60px;
  margin-bottom: 8px;
  background: var(--md-sys-color-surface);
  color: var(--md-sys-color-on-surface);
  transition: border-color var(--md-sys-motion-duration-short3) var(--md-sys-motion-easing-standard);
}

.message-edit-input:focus {
  outline: none;
  border-color: var(--md-sys-color-secondary);
}

.message-edit-actions {
  display: flex;
  gap: 8px;
}

.btn-save-edit,
.btn-cancel-edit {
  padding: 8px 16px;
  border: none;
  border-radius: var(--md-sys-shape-corner-full);
  font-family: var(--md-sys-typescale-label-medium-font-family);
  font-size: var(--md-sys-typescale-label-medium-font-size);
  font-weight: var(--md-sys-typescale-label-medium-font-weight);
  cursor: pointer;
  transition: all var(--md-sys-motion-duration-short3) var(--md-sys-motion-easing-standard);
}

.btn-save-edit {
  background: var(--md-sys-color-primary);
  color: var(--md-sys-color-on-primary);
}

.btn-save-edit:hover {
  box-shadow: var(--md-sys-elevation-level1);
}

.btn-cancel-edit {
  background: var(--md-sys-color-surface-container-high);
  color: var(--md-sys-color-on-surface);
}

.btn-cancel-edit:hover {
  background: var(--md-sys-color-surface-container-highest);
}

/* ========================================
   MESSAGE BADGES
   ======================================== */
.message-edited-badge {
  font-family: var(--md-sys-typescale-label-small-font-family);
  font-size: var(--md-sys-typescale-label-small-font-size);
  color: var(--md-sys-color-on-surface-variant);
  font-style: italic;
  margin-left: 6px;
}

.message-forwarded-badge {
  font-family: var(--md-sys-typescale-label-small-font-family);
  font-size: var(--md-sys-typescale-label-small-font-size);
  font-weight: var(--md-sys-typescale-label-small-font-weight);
  color: var(--md-sys-color-tertiary);
  display: block;
  margin-bottom: 2px;
}

.message.own .message-forwarded-badge {
  color: var(--md-sys-color-on-primary-container);
  opacity: 0.85;
}

/* ========================================
   FORWARD MODAL
   ======================================== */
.forward-chat-list {
  max-height: 300px;
  overflow-y: auto;
  border: 1px solid var(--md-sys-color-outline-variant);
  border-radius: var(--md-sys-shape-corner-medium);
  background: var(--md-sys-color-surface-container-lowest);
}

.forward-chat-item {
  padding: 14px 16px;
  border-bottom: 1px solid var(--md-sys-color-outline-variant);
  cursor: pointer;
  transition: background var(--md-sys-motion-duration-short3) var(--md-sys-motion-easing-standard);
  position: relative;
}

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

.forward-chat-item::before {
  content: '';
  position: absolute;
  inset: 0;
  background: currentColor;
  opacity: 0;
  transition: opacity var(--md-sys-motion-duration-short3) var(--md-sys-motion-easing-standard);
}

.forward-chat-item:hover::before {
  opacity: var(--md-sys-state-hover-opacity);
}

.forward-chat-item.selected {
  background: var(--md-sys-color-primary-container);
  border-left: 4px solid var(--md-sys-color-primary);
}

/* ========================================
   FORWARD NOTIFICATION
   ======================================== */
.forward-notification {
  position: fixed;
  top: 20px;
  right: 20px;
  background: var(--md-sys-color-success-container);
  color: var(--md-sys-color-on-success-container);
  padding: 16px 24px;
  border-radius: var(--md-sys-shape-corner-medium);
  box-shadow: var(--md-sys-elevation-level3);
  font-family: var(--md-sys-typescale-body-medium-font-family);
  font-size: var(--md-sys-typescale-body-medium-font-size);
  font-weight: 600;
  z-index: 10000;
  opacity: 0;
  transform: translateY(-20px);
  transition: all var(--md-sys-motion-duration-medium2) var(--md-sys-motion-easing-emphasized);
}

.forward-notification.show {
  opacity: 1;
  transform: translateY(0);
}

/* ========================================
   PAGINATION / LOAD MORE
   ======================================== */
.load-more-btn {
  display: block;
  width: calc(100% - 48px);
  margin: 12px 24px;
  padding: 12px 24px;
  background: var(--md-sys-color-surface-container-high);
  border: 1px solid var(--md-sys-color-outline-variant);
  border-radius: var(--md-sys-shape-corner-full);
  color: var(--md-sys-color-on-surface);
  font-family: var(--md-sys-typescale-label-large-font-family);
  font-size: var(--md-sys-typescale-label-large-font-size);
  font-weight: var(--md-sys-typescale-label-large-font-weight);
  cursor: pointer;
  transition: all var(--md-sys-motion-duration-short3) var(--md-sys-motion-easing-standard);
  position: relative;
  overflow: hidden;
}

.load-more-btn::before {
  content: '';
  position: absolute;
  inset: 0;
  background: var(--md-sys-color-primary);
  opacity: 0;
  transition: opacity var(--md-sys-motion-duration-short3) var(--md-sys-motion-easing-standard);
}

.load-more-btn:hover:not(:disabled)::before {
  opacity: var(--md-sys-state-hover-opacity);
}

.load-more-btn:hover:not(:disabled) {
  background: var(--md-sys-color-primary);
  color: var(--md-sys-color-on-primary);
  border-color: transparent;
}

.load-more-btn:disabled {
  cursor: not-allowed;
  opacity: 0.38;
}

/* ========================================
   MESSAGE WITH AVATAR
   ======================================== */
.message-with-avatar {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  max-width: 75%;
}

.message.own.message-with-avatar {
  margin-left: auto;
  flex-direction: row-reverse;
}

.message:not(.own).message-with-avatar {
  margin-right: auto;
}

.message.own .message-content-wrapper {
  text-align: right;
}

.message.own .message-header {
  justify-content: flex-end;
}

.message.own .message-text {
  text-align: left;
}

.message-avatar {
  width: 36px;
  height: 36px;
  border-radius: var(--md-sys-shape-corner-full);
  background: var(--md-sys-color-primary-container);
  color: var(--md-sys-color-on-primary-container);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--md-sys-typescale-label-large-font-family);
  font-weight: 600;
  font-size: 14px;
  flex-shrink: 0;
  cursor: pointer;
  overflow: hidden;
  transition: transform var(--md-sys-motion-duration-short3) var(--md-sys-motion-easing-standard);
}

.message-avatar:hover {
  transform: scale(1.1);
}

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

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

.message-username.clickable {
  cursor: pointer;
  transition: color var(--md-sys-motion-duration-short3) var(--md-sys-motion-easing-standard);
}

.message-username.clickable:hover {
  color: var(--md-sys-color-primary);
  text-decoration: underline;
}

/* ========================================
   REVENUE MESSAGE - Material Design 3
   ======================================== */
.message-revenue {
  background: transparent !important;
  border: none !important;
  padding: 8px 0 !important;
}

.message-revenue .message-content-wrapper {
  background: transparent;
}

.revenue-card {
  display: grid;
  grid-template-columns: 48px 1fr auto;
  grid-template-rows: auto auto;
  gap: 4px 12px;
  padding: 16px;
  background: var(--md-sys-color-success-container);
  border-radius: var(--md-sys-shape-corner-large);
  box-shadow: var(--md-sys-elevation-level1);
  border: 1px solid var(--md-sys-color-outline-variant);
  margin-top: 6px;
  min-width: 260px;
  transition: all var(--md-sys-motion-duration-short3) var(--md-sys-motion-easing-standard);
}

.revenue-card:hover {
  box-shadow: var(--md-sys-elevation-level2);
  transform: translateY(-1px);
}

.revenue-card-icon {
  grid-row: 1 / 3;
  width: 48px;
  height: 48px;
  background: var(--md-sys-color-success);
  border-radius: var(--md-sys-shape-corner-medium);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--md-sys-color-on-success);
  box-shadow: var(--md-sys-elevation-level1);
}

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

.revenue-card-body {
  display: flex;
  flex-direction: column;
  justify-content: center;
  min-width: 0;
}

.revenue-card-label {
  font-family: var(--md-sys-typescale-label-small-font-family);
  font-size: var(--md-sys-typescale-label-small-font-size);
  font-weight: var(--md-sys-typescale-label-small-font-weight);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--md-sys-color-on-success-container);
  margin-bottom: 2px;
}

.revenue-card-store {
  font-family: var(--md-sys-typescale-title-medium-font-family);
  font-size: var(--md-sys-typescale-title-medium-font-size);
  font-weight: var(--md-sys-typescale-title-medium-font-weight);
  color: var(--md-sys-color-on-success-container);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.revenue-card-amount {
  grid-column: 3;
  grid-row: 1 / 3;
  display: flex;
  align-items: center;
  font-family: var(--md-sys-typescale-headline-small-font-family);
  font-size: 22px;
  font-weight: 700;
  color: var(--md-sys-color-success);
  white-space: nowrap;
  padding-left: 12px;
}

.revenue-currency {
  font-size: 16px;
  font-weight: 500;
  margin-left: 2px;
  opacity: 0.7;
}

.revenue-card-date {
  grid-column: 1 / 4;
  font-family: var(--md-sys-typescale-body-small-font-family);
  font-size: var(--md-sys-typescale-body-small-font-size);
  color: var(--md-sys-color-on-success-container);
  opacity: 0.8;
  margin-top: 8px;
  padding-top: 10px;
  border-top: 1px solid rgba(0, 0, 0, 0.08);
  text-align: center;
}

.message-revenue.own .revenue-card {
  background: var(--md-sys-color-success-container);
}

/* Revenue notification */
.revenue-notification {
  position: fixed;
  top: 20px;
  right: 20px;
  background: var(--md-sys-color-success);
  color: var(--md-sys-color-on-success);
  padding: 16px 24px;
  border-radius: var(--md-sys-shape-corner-medium);
  box-shadow: var(--md-sys-elevation-level3);
  font-family: var(--md-sys-typescale-body-medium-font-family);
  font-size: var(--md-sys-typescale-body-medium-font-size);
  font-weight: 600;
  z-index: 10000;
  opacity: 0;
  transform: translateY(-20px);
  transition: all var(--md-sys-motion-duration-medium2) var(--md-sys-motion-easing-emphasized);
}

.revenue-notification.show {
  opacity: 1;
  transform: translateY(0);
}

.revenue-notification-content {
  display: flex;
  align-items: center;
  gap: 12px;
}

.revenue-notification-icon {
  font-size: 20px;
}

/* ========================================
   ATTACHMENT MENU
   ======================================== */
.attach-menu {
  background: var(--md-sys-color-surface-container);
  border-radius: var(--md-sys-shape-corner-medium);
  box-shadow: var(--md-sys-elevation-level2);
  padding: 8px 0;
  min-width: 180px;
  z-index: 1000;
  animation: md-scale-in var(--md-sys-motion-duration-medium2) var(--md-sys-motion-easing-emphasized-decelerate);
}

.attach-menu-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  cursor: pointer;
  transition: background var(--md-sys-motion-duration-short3) var(--md-sys-motion-easing-standard);
  position: relative;
}

.attach-menu-item::before {
  content: '';
  position: absolute;
  inset: 0;
  background: currentColor;
  opacity: 0;
  transition: opacity var(--md-sys-motion-duration-short3) var(--md-sys-motion-easing-standard);
}

.attach-menu-item:hover::before {
  opacity: var(--md-sys-state-hover-opacity);
}

.attach-menu-icon {
  font-size: 20px;
  width: 28px;
  text-align: center;
  color: var(--md-sys-color-on-surface-variant);
}

.attach-menu-text {
  font-family: var(--md-sys-typescale-body-large-font-family);
  font-size: var(--md-sys-typescale-body-large-font-size);
  color: var(--md-sys-color-on-surface);
}

/* ========================================
   REVENUE FORM (Modal)
   ======================================== */
.revenue-form .form-group {
  margin-bottom: 20px;
}

.revenue-form label {
  display: block;
  margin-bottom: 8px;
  font-family: var(--md-sys-typescale-label-large-font-family);
  font-size: var(--md-sys-typescale-label-large-font-size);
  font-weight: var(--md-sys-typescale-label-large-font-weight);
  color: var(--md-sys-color-on-surface);
}

.revenue-form .form-input,
.revenue-form .form-select {
  width: 100%;
  padding: 14px 16px;
  border: 1px solid var(--md-sys-color-outline);
  border-radius: var(--md-sys-shape-corner-extra-small);
  font-family: var(--md-sys-typescale-body-large-font-family);
  font-size: var(--md-sys-typescale-body-large-font-size);
  background: var(--md-sys-color-surface);
  color: var(--md-sys-color-on-surface);
  box-sizing: border-box;
  transition: border-color var(--md-sys-motion-duration-short3) var(--md-sys-motion-easing-standard);
}

.revenue-form .form-input:hover,
.revenue-form .form-select:hover {
  border-color: var(--md-sys-color-on-surface);
}

.revenue-form .form-input:focus,
.revenue-form .form-select:focus {
  outline: none;
  border-color: var(--md-sys-color-success);
  border-width: 2px;
}

.revenue-form .form-input.readonly {
  background: var(--md-sys-color-surface-container);
  color: var(--md-sys-color-on-surface-variant);
  cursor: not-allowed;
}

.revenue-form .form-input[type="number"] {
  font-size: var(--md-sys-typescale-title-large-font-size);
  font-weight: 600;
}

.revenue-form .form-actions {
  display: flex;
  gap: 12px;
  margin-top: 24px;
}

.revenue-form .btn-primary {
  flex: 1;
  padding: 16px 24px;
  background: var(--md-sys-color-success);
  color: var(--md-sys-color-on-success);
  border: none;
  border-radius: var(--md-sys-shape-corner-full);
  font-family: var(--md-sys-typescale-label-large-font-family);
  font-size: var(--md-sys-typescale-label-large-font-size);
  font-weight: var(--md-sys-typescale-label-large-font-weight);
  cursor: pointer;
  transition: all var(--md-sys-motion-duration-short3) var(--md-sys-motion-easing-standard);
  position: relative;
  overflow: hidden;
}

.revenue-form .btn-primary::before {
  content: '';
  position: absolute;
  inset: 0;
  background: currentColor;
  opacity: 0;
  transition: opacity var(--md-sys-motion-duration-short3) var(--md-sys-motion-easing-standard);
}

.revenue-form .btn-primary:hover {
  box-shadow: var(--md-sys-elevation-level2);
}

.revenue-form .btn-primary:hover::before {
  opacity: var(--md-sys-state-hover-opacity);
}

.revenue-form .btn-secondary {
  flex: 1;
  padding: 16px 24px;
  background: var(--md-sys-color-surface-container-high);
  color: var(--md-sys-color-on-surface);
  border: none;
  border-radius: var(--md-sys-shape-corner-full);
  font-family: var(--md-sys-typescale-label-large-font-family);
  font-size: var(--md-sys-typescale-label-large-font-size);
  font-weight: var(--md-sys-typescale-label-large-font-weight);
  cursor: pointer;
  transition: all var(--md-sys-motion-duration-short3) var(--md-sys-motion-easing-standard);
}

.revenue-form .btn-secondary:hover {
  background: var(--md-sys-color-surface-container-highest);
}

/* ========================================
   NEW MESSAGE ANIMATION
   ======================================== */
@keyframes message-appear {
  from {
    opacity: 0;
    transform: translateY(12px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.message.new-message {
  animation: message-appear var(--md-sys-motion-duration-medium2) var(--md-sys-motion-easing-emphasized-decelerate);
}

/* Own messages slide from right */
.message.own.new-message {
  animation: message-appear-own var(--md-sys-motion-duration-medium2) var(--md-sys-motion-easing-emphasized-decelerate);
}

@keyframes message-appear-own {
  from {
    opacity: 0;
    transform: translateX(12px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

/* ========================================
   TYPING INDICATOR
   ======================================== */
.typing-indicator {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 12px 16px;
  background: var(--md-sys-color-surface-container);
  border-radius: var(--md-sys-shape-corner-large);
  width: fit-content;
  margin: 8px 0;
  font-family: var(--md-sys-typescale-body-small-font-family);
  font-size: var(--md-sys-typescale-body-small-font-size);
  color: var(--md-sys-color-on-surface-variant);
}

.typing-name {
  font-weight: 500;
  color: var(--md-sys-color-on-surface);
}

.typing-dots {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  margin-left: 4px;
}

.typing-dot {
  width: 8px;
  height: 8px;
  background: var(--md-sys-color-on-surface-variant);
  border-radius: var(--md-sys-shape-corner-full);
  animation: typing-bounce 1.4s infinite ease-in-out both;
}

.typing-dot:nth-child(1) {
  animation-delay: 0s;
}

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

.typing-dot:nth-child(3) {
  animation-delay: 0.32s;
}

@keyframes typing-bounce {
  0%, 80%, 100% {
    transform: scale(0.6);
    opacity: 0.4;
  }
  40% {
    transform: scale(1);
    opacity: 1;
  }
}

/* Typing indicator text */
.typing-text {
  font-family: var(--md-sys-typescale-body-small-font-family);
  font-size: var(--md-sys-typescale-body-small-font-size);
  color: var(--md-sys-color-on-surface-variant);
  margin-left: 8px;
}

/* ========================================
   MESSAGE REACTIONS
   ======================================== */

/* Quick reaction bar - appears on hover */
.message-reaction-bar {
  position: absolute;
  top: -36px;
  right: 8px;
  background: var(--md-sys-color-surface-container-high);
  border-radius: var(--md-sys-shape-corner-full);
  padding: 4px 8px;
  display: flex;
  gap: 2px;
  box-shadow: var(--md-sys-elevation-level2);
  opacity: 0;
  visibility: hidden;
  transform: translateY(8px) scale(0.95);
  transition:
    opacity var(--md-sys-motion-duration-short3) var(--md-sys-motion-easing-standard),
    visibility var(--md-sys-motion-duration-short3) var(--md-sys-motion-easing-standard),
    transform var(--md-sys-motion-duration-short3) var(--md-sys-motion-easing-standard);
  z-index: 10;
}

/* Desktop: show on hover */
@media (hover: hover) {
  .message:hover .message-reaction-bar {
    opacity: 1;
    visibility: visible;
    transform: translateY(0) scale(1);
  }
}

/* Mobile: show via JS class on long press */
.message-reaction-bar.visible {
  opacity: 1;
  visibility: visible;
  transform: translateY(0) scale(1);
}

.message:not(.own) .message-reaction-bar {
  right: auto;
  left: 8px;
}

.reaction-btn {
  width: 32px;
  height: 32px;
  border: none;
  background: transparent;
  border-radius: var(--md-sys-shape-corner-full);
  font-size: 18px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition:
    background var(--md-sys-motion-duration-short3) var(--md-sys-motion-easing-standard),
    transform var(--md-sys-motion-duration-short3) var(--md-sys-motion-easing-standard);
}

.reaction-btn:hover {
  background: var(--md-sys-color-surface-container-highest);
  transform: scale(1.2);
}

.reaction-btn:active {
  transform: scale(0.9);
}

/* Reactions container - overlaid on message (Telegram style) */
.message-reactions {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: -10px;
  margin-left: 8px;
  position: relative;
  z-index: 10;
}

.message.own .message-reactions {
  justify-content: flex-end;
  margin-left: 0;
  margin-right: 8px;
}

/* Individual reaction chip */
.reaction-chip {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  padding: 2px 6px;
  background: var(--md-sys-color-surface-container-high);
  border: none;
  border-radius: var(--md-sys-shape-corner-full);
  font-size: 13px;
  cursor: pointer;
  box-shadow: var(--md-sys-elevation-level1);
  transition:
    background var(--md-sys-motion-duration-short3) var(--md-sys-motion-easing-standard),
    transform var(--md-sys-motion-duration-short3) var(--md-sys-motion-easing-standard);
}

.reaction-chip:hover {
  background: var(--md-sys-color-surface-container-highest);
  transform: scale(1.1);
}

.reaction-chip.active {
  background: var(--md-sys-color-primary-container);
}

.reaction-count {
  font-size: 12px;
  font-weight: 500;
  color: var(--md-sys-color-on-surface-variant);
}

.reaction-chip.active .reaction-count {
  color: var(--md-sys-color-on-primary-container);
}

.reaction-emoji {
  font-size: 16px;
  line-height: 1;
}

.reaction-count {
  font-family: var(--md-sys-typescale-label-small-font-family);
  font-size: var(--md-sys-typescale-label-small-font-size);
  font-weight: var(--md-sys-typescale-label-small-font-weight);
  color: var(--md-sys-color-on-surface-variant);
  min-width: 12px;
  text-align: center;
}

.reaction-chip.active .reaction-count {
  color: var(--md-sys-color-on-primary-container);
}

/* Add reaction button */
.add-reaction-btn {
  width: 28px;
  height: 28px;
  border: 1px dashed var(--md-sys-color-outline-variant);
  background: transparent;
  border-radius: var(--md-sys-shape-corner-full);
  font-size: 14px;
  color: var(--md-sys-color-on-surface-variant);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition:
    background var(--md-sys-motion-duration-short3) var(--md-sys-motion-easing-standard),
    border-color var(--md-sys-motion-duration-short3) var(--md-sys-motion-easing-standard);
}

.add-reaction-btn:hover {
  background: var(--md-sys-color-surface-container);
  border-color: var(--md-sys-color-outline);
}

/* Reaction animation */
@keyframes reaction-pop {
  0% {
    transform: scale(0);
  }
  50% {
    transform: scale(1.3);
  }
  100% {
    transform: scale(1);
  }
}

.reaction-chip.just-added {
  animation: reaction-pop var(--md-sys-motion-duration-medium2) var(--md-sys-motion-easing-emphasized);
}

/* Reaction picker popup */
.reaction-picker {
  position: absolute;
  bottom: calc(100% + 8px);
  right: 0;
  background: var(--md-sys-color-surface-container-high);
  border-radius: var(--md-sys-shape-corner-large);
  padding: 8px;
  box-shadow: var(--md-sys-elevation-level3);
  display: flex;
  gap: 4px;
  animation: md-scale-in var(--md-sys-motion-duration-short4) var(--md-sys-motion-easing-emphasized-decelerate);
  z-index: 100;
}

.message:not(.own) .reaction-picker {
  right: auto;
  left: 0;
}

.reaction-picker-btn {
  width: 36px;
  height: 36px;
  border: none;
  background: transparent;
  border-radius: var(--md-sys-shape-corner-medium);
  font-size: 22px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition:
    background var(--md-sys-motion-duration-short3) var(--md-sys-motion-easing-standard),
    transform var(--md-sys-motion-duration-short3) var(--md-sys-motion-easing-standard);
}

.reaction-picker-btn:hover {
  background: var(--md-sys-color-surface-container-highest);
  transform: scale(1.15);
}
