/* 23G — Uygulama içi mesajlaşma */
.spa-view[data-view="messages"].spa-view--active {
  display: flex;
  flex-direction: column;
  height: calc(100dvh - 72px);
  max-height: calc(100dvh - 72px);
  overflow: hidden;
}

.msg-app {
  max-width: 1100px;
  margin: 0 auto;
  padding: 1.25rem 1rem 1rem;
  width: 100%;
  box-sizing: border-box;
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.msg-app-header {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  flex-wrap: wrap;
  margin-bottom: 1rem;
}

.msg-app-header h2 {
  margin: 0;
  font-size: 1.35rem;
  color: #e8f4ef;
}

.msg-app-header .sub {
  margin: 0.25rem 0 0;
  color: #8fb3a8;
  font-size: 0.88rem;
}

.msg-layout {
  display: grid;
  grid-template-columns: minmax(240px, 320px) 1fr;
  gap: 1rem;
  flex: 1;
  min-height: 0;
  overflow: hidden;
}

@media (max-width: 768px) {
  .msg-layout {
    grid-template-columns: 1fr;
    min-height: 0;
  }
  .msg-sidebar.msg-sidebar--hidden-mobile {
    display: none;
  }
}

.msg-sidebar,
.msg-main {
  background: rgba(8, 22, 18, 0.82);
  border: 1px solid rgba(78, 207, 143, 0.14);
  border-radius: 16px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  min-height: 0;
  height: 100%;
}

.msg-sidebar__head,
.msg-main__head {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 0.85rem 1rem;
  border-bottom: 1px solid rgba(78, 207, 143, 0.1);
}

.msg-conv-list {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 0.5rem;
}

.msg-conv-item {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 0.65rem;
  width: 100%;
  text-align: left;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 12px;
  padding: 0.7rem 0.75rem;
  color: #d8ebe4;
  cursor: pointer;
  margin-bottom: 0.35rem;
}

.msg-conv-item__avatar {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  object-fit: cover;
  flex-shrink: 0;
  border: 2px solid rgba(78, 207, 143, 0.22);
}

.msg-conv-item__body {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}

.msg-conv-item__row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.45rem;
  width: 100%;
}

.msg-conv-item--unread .msg-conv-item__title,
.msg-conv-item--unread .msg-conv-item__preview {
  font-weight: 600;
  color: #f2faf6;
}

.msg-conv-item:hover,
.msg-conv-item--active {
  background: rgba(45, 143, 95, 0.12);
  border-color: rgba(78, 207, 143, 0.2);
}

.msg-conv-item__title {
  font-weight: 600;
  font-size: 0.92rem;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  flex: 1;
}

.msg-conv-item__row--preview {
  margin-top: 0.15rem;
}

.msg-conv-item__preview {
  font-size: 0.8rem;
  color: #8fb3a8;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1;
  min-width: 0;
}

.msg-conv-item__time {
  font-size: 0.72rem;
  color: #6d9488;
  flex-shrink: 0;
}

.msg-unread-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 20px;
  height: 20px;
  padding: 0 6px;
  border-radius: 999px;
  background: #25d366;
  color: #052e16;
  font-size: 0.72rem;
  font-weight: 700;
  line-height: 1;
  flex-shrink: 0;
}

.msg-nav-link {
  position: relative;
}

.msg-nav-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  margin-left: 0.35rem;
  border-radius: 999px;
  background: #25d366;
  color: #052e16;
  font-size: 0.68rem;
  font-weight: 700;
  line-height: 1;
  vertical-align: middle;
}

.msg-nav-badge.hidden,
.msg-tab-badge.hidden,
.hidden {
  display: none !important;
}

.msg-sidebar-tabs {
  display: flex;
  gap: 0.35rem;
  width: 100%;
}

.msg-sidebar-tab {
  flex: 1;
  border: 1px solid rgba(78, 207, 143, 0.16);
  background: rgba(8, 22, 18, 0.55);
  color: #9fd4b8;
  border-radius: 10px;
  padding: 0.45rem 0.55rem;
  font-size: 0.82rem;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
}

.msg-sidebar-tab--active {
  background: rgba(45, 143, 95, 0.22);
  color: #f2faf6;
  border-color: rgba(78, 207, 143, 0.35);
}

.msg-tab-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 999px;
  background: #4ecf8f;
  color: #052e16;
  font-size: 0.65rem;
  font-weight: 700;
}

.msg-notif-list {
  flex: 1;
  overflow-y: auto;
  padding: 0.5rem;
}

.msg-notif-item {
  border: 1px solid rgba(78, 207, 143, 0.12);
  border-radius: 12px;
  padding: 0.65rem 0.75rem;
  margin-bottom: 0.4rem;
  background: rgba(12, 30, 24, 0.75);
}

.msg-notif-item--unread {
  border-color: rgba(78, 207, 143, 0.32);
  background: rgba(20, 48, 36, 0.85);
}

.msg-notif-item--warn {
  border-left: 3px solid #f59e0b;
}

.msg-notif-item--danger {
  border-left: 3px solid #ef4444;
}

.msg-notif-item--ok {
  border-left: 3px solid #4ecf8f;
}

.msg-notif-item__body {
  font-size: 0.86rem;
  color: #e8f4ef;
  line-height: 1.35;
}

.msg-notif-item__time {
  font-size: 0.72rem;
  color: #6d9488;
  margin-top: 0.3rem;
}

.msg-thread {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 1rem;
  overflow-anchor: none;
}

.msg-thread-hint {
  text-align: center;
  font-size: 0.78rem;
  color: #6d9488;
  margin: 0 0 0.65rem;
  padding: 0.35rem 0.5rem;
}

.msg-thread-hint--action {
  color: #8fb3a8;
}

.msg-bubbles {
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
}

.msg-bubble-row {
  display: flex;
  justify-content: flex-start;
}

.msg-bubble-row--mine {
  justify-content: flex-end;
}

.msg-bubble-wrap {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  max-width: min(82%, 540px);
}

.msg-bubble-row--mine .msg-bubble-wrap {
  align-items: flex-end;
}

.msg-bubble__sender {
  font-size: 0.72rem;
  color: #8fb3a8;
  margin: 0 0.35rem 0.2rem;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.msg-bubble-row--mine .msg-bubble__sender {
  display: none;
}

.msg-bubble {
  max-width: 100%;
  background: rgba(28, 38, 48, 0.95);
  border: 1px solid rgba(148, 163, 184, 0.18);
  border-radius: 16px 16px 16px 4px;
  padding: 0.55rem 0.75rem;
}

.msg-bubble-row--mine .msg-bubble {
  background: rgba(35, 110, 72, 0.72);
  border-color: rgba(78, 207, 143, 0.35);
  border-radius: 16px 16px 4px 16px;
}

.msg-main__head-titles {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  min-width: 0;
}

.msg-thread-subtitle {
  margin: 0;
  font-size: 0.8rem;
  color: #8fb3a8;
}

.msg-bubble__body {
  white-space: pre-wrap;
  word-break: break-word;
  line-height: 1.45;
  font-size: 0.92rem;
}

.msg-bubble__meta {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 0.35rem;
  margin-top: 0.25rem;
  font-size: 0.72rem;
  color: #8fb3a8;
}

.msg-bubble__react,
.msg-bubble__menu {
  border: none;
  background: transparent;
  color: #8fb3a8;
  cursor: pointer;
  font-size: 0.82rem;
  line-height: 1;
  padding: 0.1rem 0.25rem;
  border-radius: 6px;
  opacity: 0.55;
}

.msg-bubble__react:hover,
.msg-bubble__menu:hover {
  opacity: 1;
  background: rgba(78, 207, 143, 0.12);
  color: #c8e8dc;
}

.msg-status {
  color: #8fb3a8;
  letter-spacing: -0.12em;
}

.msg-status--read {
  color: #6ec9ff;
}

.msg-reactions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem;
  margin-top: 0.35rem;
  max-width: min(82%, 540px);
}

.msg-bubble-row--mine .msg-reactions {
  justify-content: flex-end;
}

.msg-reaction {
  display: inline-flex;
  align-items: center;
  gap: 0.2rem;
  border: 1px solid rgba(78, 207, 143, 0.2);
  background: rgba(8, 22, 18, 0.75);
  color: #e8f4ef;
  border-radius: 999px;
  padding: 0.15rem 0.45rem;
  font-size: 0.82rem;
  cursor: pointer;
  line-height: 1.2;
}

.msg-reaction--mine {
  border-color: rgba(78, 207, 143, 0.45);
  background: rgba(35, 110, 72, 0.35);
}

.msg-reaction--add {
  opacity: 0.85;
  padding: 0.15rem 0.4rem;
}

.msg-reaction__count {
  font-size: 0.72rem;
  color: #9fd4b8;
}

.msg-reaction-picker {
  position: fixed;
  z-index: 1200;
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 0.25rem;
  padding: 0.5rem;
  border-radius: 12px;
  border: 1px solid rgba(78, 207, 143, 0.22);
  background: rgba(8, 22, 18, 0.98);
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.4);
}

.msg-reaction-picker__btn {
  border: none;
  background: transparent;
  font-size: 1.25rem;
  cursor: pointer;
  border-radius: 8px;
  padding: 0.25rem;
}

.msg-reaction-picker__btn:hover {
  background: rgba(78, 207, 143, 0.12);
}

.msg-bubble__legacy {
  font-style: italic;
  color: #8fb3a8;
  font-size: 0.88rem;
}

.msg-compose {
  display: flex;
  gap: 0.5rem;
  padding: 0.85rem 1rem;
  border-top: 1px solid rgba(78, 207, 143, 0.1);
  align-items: center;
  flex-shrink: 0;
}

.msg-compose-tools {
  display: flex;
  gap: 0.25rem;
  flex-shrink: 0;
}

.msg-compose-btn {
  width: 38px;
  height: 38px;
  border-radius: 10px;
  border: 1px solid rgba(78, 207, 143, 0.18);
  background: rgba(4, 14, 10, 0.7);
  color: #e8f4ef;
  font-size: 1rem;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
}

.msg-compose-btn:hover {
  border-color: rgba(78, 207, 143, 0.35);
  background: rgba(20, 48, 36, 0.85);
}

.msg-compose-btn--recording {
  background: rgba(220, 38, 38, 0.25);
  border-color: rgba(248, 113, 113, 0.55);
  animation: msg-rec-pulse 1s ease-in-out infinite;
}

@keyframes msg-rec-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.65; }
}

.msg-compose input {
  flex: 1;
  min-width: 120px;
  border-radius: 12px;
  border: 1px solid rgba(78, 207, 143, 0.18);
  background: rgba(4, 14, 10, 0.7);
  color: #e8f4ef;
  padding: 0.65rem 0.85rem;
}

.msg-emoji-picker {
  position: absolute;
  left: 0.75rem;
  bottom: calc(100% + 0.35rem);
  z-index: 30;
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  gap: 0.2rem;
  padding: 0.5rem;
  border-radius: 12px;
  border: 1px solid rgba(78, 207, 143, 0.2);
  background: rgba(8, 22, 18, 0.98);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
  max-width: min(320px, calc(100vw - 2rem));
}

.msg-emoji-picker__btn {
  border: none;
  background: transparent;
  font-size: 1.2rem;
  cursor: pointer;
  border-radius: 8px;
  padding: 0.2rem;
}

.msg-emoji-picker__btn:hover {
  background: rgba(78, 207, 143, 0.12);
}

.msg-bubble__deleted {
  font-style: italic;
  color: #9fb3a8;
  font-size: 0.88rem;
}

.msg-bubble__media {
  margin-bottom: 0.25rem;
}

.msg-bubble__img {
  display: block;
  max-width: min(280px, 100%);
  max-height: 280px;
  border-radius: 10px;
  object-fit: cover;
}

.msg-bubble__media--audio {
  min-width: 200px;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.msg-bubble__audio {
  width: 100%;
  max-width: 280px;
  height: 36px;
}

.msg-bubble__audio-dur {
  font-size: 0.72rem;
  color: #8fb3a8;
  padding-left: 0.15rem;
}

.msg-bubble__caption {
  margin-top: 0.35rem;
  white-space: pre-wrap;
  word-break: break-word;
  font-size: 0.92rem;
}

.msg-context-menu {
  position: fixed;
  z-index: 1200;
  min-width: 180px;
  border-radius: 12px;
  border: 1px solid rgba(78, 207, 143, 0.22);
  background: rgba(8, 22, 18, 0.98);
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.4);
  padding: 0.35rem;
}

.msg-context-menu__item {
  display: block;
  width: 100%;
  text-align: left;
  border: none;
  background: transparent;
  color: #e8f4ef;
  padding: 0.55rem 0.7rem;
  border-radius: 8px;
  cursor: pointer;
  font-size: 0.88rem;
}

.msg-context-menu__item:hover {
  background: rgba(78, 207, 143, 0.12);
}

.msg-context-menu__item--danger {
  color: #fca5a5;
}

.msg-empty {
  color: #8fb3a8;
  font-size: 0.9rem;
  padding: 1rem;
  text-align: center;
}

.msg-toolbar {
  display: flex;
  gap: 0.4rem;
  flex-wrap: wrap;
}

.msg-modal .modal-card {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 520px;
  background: rgba(12, 28, 24, 0.97);
  border: 1px solid rgba(78, 207, 143, 0.28);
  border-radius: 16px;
  box-shadow: 0 28px 80px rgba(0, 0, 0, 0.55);
  overflow: hidden;
}

.msg-modal .modal-backdrop {
  position: absolute;
  inset: 0;
}

.msg-modal .modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 1rem 1.1rem;
  border-bottom: 1px solid rgba(78, 207, 143, 0.12);
}

.msg-modal .modal-head h3 {
  margin: 0;
  font-size: 1.05rem;
  color: #e8f4ef;
}

.msg-modal .modal-body {
  padding: 1rem 1.1rem 1.15rem;
}

.msg-modal .modal-close {
  border: none;
  background: transparent;
  color: #9fd4b8;
  font-size: 1.5rem;
  line-height: 1;
  cursor: pointer;
}

.msg-search-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
  margin-bottom: 0.75rem;
}

.msg-search-results {
  max-height: 280px;
  overflow-y: auto;
  margin-top: 0.75rem;
}

.msg-search-item {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  width: 100%;
  text-align: left;
  background: rgba(12, 30, 24, 0.8);
  border: 1px solid rgba(78, 207, 143, 0.14);
  border-radius: 12px;
  padding: 0.7rem 0.85rem;
  color: #d8ebe4;
  cursor: pointer;
  margin-bottom: 0.45rem;
}

.msg-search-item--corp {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 0.35rem;
}

.msg-search-item__company {
  font-weight: 700;
  font-size: 0.98rem;
  color: #f2faf6;
  min-width: 0;
}

.msg-search-item__meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.55rem 1rem;
  font-size: 0.84rem;
  color: #9fd4b8;
}

.msg-search-item__contact,
.msg-search-item__phone,
.msg-search-item__city {
  text-align: left;
  max-width: none;
  flex-shrink: 1;
}

.msg-search-item__meta em {
  font-style: normal;
  color: #7ea894;
  margin-right: 0.2rem;
}

.msg-search-item__avatar {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  object-fit: cover;
  flex-shrink: 0;
  border: 2px solid rgba(78, 207, 143, 0.35);
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.2);
}
}

.msg-search-item--user {
  display: grid;
  grid-template-columns: 44px 1fr auto;
  align-items: center;
  gap: 0.75rem;
}

.msg-search-item__phone {
  font-size: 0.86rem;
  color: #9fd4b8;
  white-space: nowrap;
  flex-shrink: 0;
}

.msg-search-item__fullname {
  font-size: 0.92rem;
  font-weight: 600;
  color: #e8f4ef;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
}

.msg-search-item:hover {
  border-color: rgba(78, 207, 143, 0.35);
  background: rgba(45, 143, 95, 0.1);
}

.msg-search-item__title {
  font-weight: 600;
}

.msg-search-item__sub {
  font-size: 0.82rem;
  color: #8fb3a8;
  margin-top: 0.15rem;
}

body.msg-corp-mode .msg-app {
  padding-top: 0.5rem;
}

body.msg-corp-mode .spa-view[data-view="messages"].spa-view--active {
  height: 100dvh;
  max-height: 100dvh;
}

body.msg-corp-mode #user-header {
  display: none !important;
}

body.msg-corp-mode #guest-header {
  display: none !important;
}

.corp-action-btn--msg {
  border-color: rgba(78, 207, 143, 0.35);
  color: #b8f0d4;
}
