/* /chat/assets/css/chat.css — layout czatu (desktop + mobile) */

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
}

html,
body {
  touch-action: manipulation;
  overscroll-behavior: none;
}

body.chat-body {
  margin: 0;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: #f3f4f6;
  color: #111827;

  /* pełna wysokość ekranu z obsługą mobile */
  height: 100dvh;
  min-height: 100vh;
}

.chat-app {
  display: flex;
  height: 100%;
}

/* ───────── Sidebar ───────── */

.chat-sidebar {
  width: 260px;
  background: #111827;
  color: #f9fafb;
  display: flex;
  flex-direction: column;
}

.chat-sidebar-header {
  padding: 16px;
  border-bottom: 1px solid rgba(55, 65, 81, 0.9);
}

.chat-sidebar-header h1 {
  margin: 0 0 8px;
  font-size: 18px;
}

.chat-user-label {
  font-size: 12px;
  opacity: 0.8;
}

.chat-user-name {
  font-size: 13px;
  font-weight: 600;
  display: block;
}

.chat-conversations {
  list-style: none;
  margin: 0;
  padding: 8px 0;
  flex: 1;
  overflow-y: auto;
}

/* lista kanałów + badge nieprzeczytanych */
.chat-conversation-item {
  padding: 10px 14px;
  cursor: pointer;
  font-size: 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
}

.chat-conversation-item.active {
  background: #1f2937;
}

.chat-conv-title {
  flex: 1;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.chat-conv-unread {
  flex-shrink: 0;
  min-width: 20px;
  padding: 0 6px;
  border-radius: 999px;
  background: #ef4444;
  color: #f9fafb;
  font-size: 11px;
  font-weight: 600;
  text-align: center;
}

/* ───────── Main ───────── */

.chat-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  background: #e5e7eb;
  height: 100%;
  position: relative; /* kotwica dla dropdownu powiadomień */
}

/* nagłówek przyklejony do góry */
.chat-main-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.chat-main-left {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.chat-main-header h2 {
  margin: 0;
  font-size: 16px;
}

/* wrapper na akcje w headerze (np. dzwonek) */
.chat-header-actions {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: .5rem;
}

/* lista wiadomości przewijana po środku */
.chat-messages {
  flex: 1;
  padding: 12px 10px;
  overflow-y: auto;
  display: flex;
  flex-direction: column; /* Messenger-style */
}

/* info "brak wiadomości / ładowanie" */
.chat-messages-empty {
  margin: 16px auto;
  font-size: 14px;
  color: #6b7280;
}

/* ───────── Bąbelki ───────── */

.chat-message {
  position: relative;
  display: inline-block;
  max-width: 70%;               /* desktop: bąbel max 70% szerokości */
  margin: 4px 0;
  padding: 8px 10px;
  border-radius: 14px 14px 14px 4px;
  background: #ffffff;
  box-shadow: 0 2px 6px rgba(15, 23, 42, 0.15);
  font-size: 14px;
  line-height: 1.4;
  word-wrap: break-word;
  word-break: break-word;
}

/* domyślnie „inni” — po lewej */
.chat-message:not(.me) {
  margin-right: auto;
}

/* moje wiadomości — po prawej, inny kolor i narożnik */
.chat-message.me {
  margin-left: auto;
  margin-right: 0;
  border-radius: 14px 14px 4px 14px;
  background: #d1fae5;
}

/* nagłówek bąbla (nick + czas) */
.chat-message-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 2px;
  font-size: 11px;
  opacity: 0.8;
  color: #6b7280;
}

.chat-message-nick {
  font-weight: 600;
}

.chat-message-time {
  margin-left: 8px;
}

.chat-message-text {
  font-size: 14px;
  white-space: pre-wrap;
  word-wrap: break-word;
}

/* ───────── MOBILE tuning ───────── */
@media (max-width: 640px) {
  .chat-message {
    max-width: 80%;
    padding: 8px 11px;
  }

  .chat-message-text {
    font-size: 15px;
  }
}

/* pasek inputu przyklejony do dołu */

.chat-input-bar {
  padding: 8px 12px;
  border-top: 1px solid #d1d5db;
  background: #ffffff;
  position: sticky;
  bottom: 0;
  z-index: 20;
  padding-bottom: calc(8px + env(safe-area-inset-bottom, 0px));
}

#chatForm {
  display: flex;
  gap: 8px;
}

.chat-input {
  flex: 1;
  padding: 10px 12px;
  border-radius: 999px;
  border: 1px solid #d1d5db;
  font-size: 16px;
  outline: none;
}

.chat-input:focus {
  border-color: #3b82f6;
  box-shadow: 0 0 0 1px rgba(59, 130, 246, 0.4);
}

.chat-send-btn {
  border: none;
  border-radius: 999px;
  padding: 0 18px;
  font-size: 16px;
  font-weight: 600;
  background: #3b82f6;
  color: #ffffff;
  cursor: pointer;
}

.chat-send-btn:disabled {
  opacity: 0.5;
  cursor: default;
}

/* Mobile: sidebar off, select kanału on */

@media (max-width: 768px) {
  .chat-sidebar {
    display: none;
  }

  .chat-main {
    width: 100%;
  }

  .chat-main-header h2 {
    font-size: 15px;
  }

  .chat-channel-select-wrapper {
    display: block;
  }
}

/* Selector kanału (mobile) */
.chat-channel-select-wrapper {
  display: none;
  margin-left: auto;
}

.chat-channel-select {
  padding: 4px 8px;
  font-size: 14px;
  border-radius: 999px;
  border: 1px solid #d1d5db;
  background: #f9fafb;
}

.chat-install-btn {
  margin-top: 8px;
  width: 100%;
  padding: 8px 10px;
  border-radius: 6px;
  border: none;
  font-size: 14px;
  cursor: pointer;
}

/* ───────────────── Ribbon (stary slot na produkt / LIVE) ─────────────── */

.chat-ribbon {
  padding: 8px 16px;
  border-bottom: 1px solid #e5e7eb;
  background: #f9fafb;
  box-shadow: 0 1px 0 rgba(15, 23, 42, 0.04);
}

.chat-ribbon--hidden {
  display: none;
}

.chat-ribbon-inner {
  display: flex;
  align-items: center;
  gap: 10px;
}

.chat-ribbon-thumb {
  width: 48px;
  height: 48px;
  border-radius: 12px;
  background: linear-gradient(135deg, #f97316, #facc15);
  flex-shrink: 0;
  box-shadow: 0 4px 8px rgba(15, 23, 42, 0.15);
}

.chat-ribbon-content {
  flex: 1;
  min-width: 0;
}

.chat-ribbon-title {
  font-size: 14px;
  font-weight: 600;
  color: #111827;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.chat-ribbon-sub {
  font-size: 12px;
  color: #6b7280;
}

.chat-ribbon-cta {
  border: none;
  border-radius: 999px;
  padding: 6px 12px;
  font-size: 13px;
  font-weight: 600;
  background: #10b981;
  color: #ffffff;
  cursor: pointer;
  white-space: nowrap;
}

.chat-ribbon-cta:disabled {
  opacity: .5;
  cursor: default;
}

/* ───────── Powiadomienia w headerze czatu (dzwonek) ───────── */

.chat-notif-btn {
  border: 0;
  background: transparent;
  padding: .25rem .5rem;
  cursor: pointer;
  border-radius: 9999px;
  display: inline-flex;
  align-items: center;
  gap: .25rem;
  font-size: 1rem;
}

.chat-notif-btn:hover {
  background: rgba(148, 163, 184, .16);
}

.chat-notif-icon {
  line-height: 1;
}

.chat-notif-badge {
  min-width: 18px;
  height: 18px;
  padding: 0 4px;
  border-radius: 9999px;
  background: #ef4444;
  color: #fff;
  font-size: .7rem;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

/* Dropdown powiadomień przy dzwonku */
.chat-notif-panel {
  position: absolute;
  right: .75rem;
  top: 3.2rem; /* pod nagłówkiem */
  width: min(260px, 92vw);
  max-height: 60vh;
  background: #ffffff;
  border-radius: 12px;
  border: 1px solid #e5e7eb;
  box-shadow: 0 10px 25px rgba(15, 23, 42, .12);
  overflow: hidden;
  z-index: 40;
}

.chat-notif-panel--hidden {
  display: none;
}

.chat-notif-head {
  padding: .5rem .75rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid #e5e7eb;
  font-size: .9rem;
  font-weight: 600;
  color: #111827;
}

.chat-notif-close {
  border: 0;
  background: transparent;
  cursor: pointer;
  font-size: 1rem;
  line-height: 1;
  padding: .1rem .3rem;
}

.chat-notif-list {
  max-height: 50vh;
  overflow-y: auto;
  padding: .4rem .75rem .6rem;
}

.chat-notif-empty {
  font-size: .85rem;
  color: #6b7280;
}

/* Selector kanału (desktop domyślnie schowany, mobile pokażemy) */
.chat-channel-select-wrapper {
  margin-left: auto;
  display: none;
}

.chat-channel-select {
  padding: 4px 8px;
  font-size: 14px;
  border-radius: 999px;
  border: 1px solid #d1d5db;
  background: #f9fafb;
}

/* Mobile: sidebar znika, selector się pojawia */
@media (max-width: 768px) {
  .chat-sidebar {
    display: none;
  }

  .chat-main {
    width: 100%;
  }

  .chat-main-header h2 {
    font-size: 15px;
  }

  .chat-channel-select-wrapper {
    display: block;
  }
}

.chat-push-btn {
  margin-top: 6px;
  background: #16a34a;
  color: #f9fafb;
}