/* ==========================================================================
   NeoChat — Frontend CSS
   Nutzt NeoUser CSS Custom Properties:
   --neo-primaer, --neo-primaer-dunkel, --neo-dunkel, --neo-hg, --neo-erfolg
   ========================================================================== */

/* --------------------------------------------------------------------------
   Basis
   -------------------------------------------------------------------------- */
.nc-wrap *,
.nc-wrap *::before,
.nc-wrap *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

/* --------------------------------------------------------------------------
   App-Layout (2 Spalten)
   -------------------------------------------------------------------------- */
.nc-wrap {
  display: grid;
  grid-template-columns: 300px 1fr;
  height: 600px;
  border: 1.5px solid rgba(var(--neo-primaer-dunkel-rgb), 0.25);
  border-radius: 16px;
  overflow: hidden;
  background: rgba(var(--neo-hg-rgb), 0.4);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  box-shadow: 0 4px 24px rgba(var(--neo-dunkel-rgb), 0.10);
  margin: 32px auto;
  max-width: 900px;
}

@media (max-width: 680px) {
  .nc-wrap {
    grid-template-columns: 1fr;
    grid-template-rows: auto 1fr;
  }
  .nc-wrap.nc-chat-active .nc-panel--list  { display: none; }
  .nc-wrap:not(.nc-chat-active) .nc-panel--chat { display: none; }
}

/* --------------------------------------------------------------------------
   Panel — gemeinsam
   -------------------------------------------------------------------------- */
.nc-panel {
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.nc-panel--list {
  border-right: 1.5px solid rgba(var(--neo-primaer-dunkel-rgb), 0.2);
  background: rgba(255, 255, 255, 0.3);
}

/* --------------------------------------------------------------------------
   Panel-Header (Liste)
   -------------------------------------------------------------------------- */
.nc-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  border-bottom: 1.5px solid rgba(var(--neo-primaer-dunkel-rgb), 0.2);
  flex-shrink: 0;
}

.nc-panel-title {
  font-size: 16px;
  font-weight: 700;
  color: var(--neo-dunkel, #333d40);
}

.nc-btn-new {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: none;
  background: linear-gradient(135deg, var(--neo-primaer, #ffa500), var(--neo-primaer-dunkel, #e09900));
  color: #fff;
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
  box-shadow: 0 2px 8px rgba(var(--neo-primaer-rgb), 0.3);
}
.nc-btn-new:hover { transform: scale(1.1); box-shadow: 0 4px 12px rgba(var(--neo-primaer-rgb), 0.4); }

/* --------------------------------------------------------------------------
   Konversationsliste
   -------------------------------------------------------------------------- */
#nc-conversations-list {
  flex: 1;
  overflow-y: auto;
}

.nc-conv-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  cursor: pointer;
  border-bottom: 1px solid rgba(var(--neo-primaer-dunkel-rgb), 0.1);
  transition: background 0.15s ease;
  position: relative;
}

.nc-conv-item:hover,
.nc-conv-item.is-active {
  background: rgba(var(--neo-primaer-rgb), 0.08);
}

.nc-conv-item.is-active {
  border-left: 3px solid var(--neo-primaer, #ffa500);
  padding-left: 11px;
}

.nc-conv-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  object-fit: cover;
  flex-shrink: 0;
  background: var(--neo-hg, #fff7ea);
}

.nc-conv-avatar--group {
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, var(--neo-primaer, #ffa500), var(--neo-primaer-dunkel, #e09900));
  color: #fff;
  font-size: 18px;
}

.nc-conv-body {
  flex: 1;
  min-width: 0;
}

.nc-conv-name {
  font-size: 14px;
  font-weight: 600;
  color: var(--neo-dunkel, #333d40);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.nc-conv-preview {
  font-size: 12px;
  color: #888;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-top: 2px;
}

.nc-conv-meta {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 4px;
  flex-shrink: 0;
}

.nc-conv-time {
  font-size: 11px;
  color: #aaa;
  white-space: nowrap;
}

.nc-badge {
  background: var(--neo-primaer, #ffa500);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  min-width: 18px;
  height: 18px;
  border-radius: 9px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 4px;
}

/* --------------------------------------------------------------------------
   Chat-Header
   -------------------------------------------------------------------------- */
.nc-chat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  border-bottom: 1.5px solid rgba(var(--neo-primaer-dunkel-rgb), 0.2);
  flex-shrink: 0;
  background: rgba(255, 255, 255, 0.4);
}

.nc-chat-header-info {
  display: flex;
  align-items: center;
  gap: 10px;
}

.nc-chat-header-info .nc-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  object-fit: cover;
}

.nc-chat-header-info span {
  font-size: 15px;
  font-weight: 600;
  color: var(--neo-dunkel, #333d40);
}

.nc-chat-actions {
  display: flex;
  gap: 8px;
}

.nc-btn-ghost {
  background: transparent;
  border: 1.5px solid rgba(var(--neo-primaer-dunkel-rgb), 0.4);
  border-radius: 8px;
  padding: 5px 12px;
  font-size: 13px;
  color: var(--neo-dunkel, #333d40);
  cursor: pointer;
  transition: background 0.15s ease;
}
.nc-btn-ghost:hover { background: rgba(var(--neo-primaer-rgb), 0.1); }

/* --------------------------------------------------------------------------
   Nachrichten
   -------------------------------------------------------------------------- */
.nc-messages-wrap {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  scroll-behavior: smooth;
}

.nc-message {
  display: flex;
  gap: 8px;
  align-items: flex-end;
  max-width: 75%;
  animation: nc-fade-in 0.2s ease;
}

.nc-message--mine {
  align-self: flex-end;
  flex-direction: row-reverse;
}

.nc-message--theirs {
  align-self: flex-start;
}

.nc-message img.nc-msg-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  object-fit: cover;
  flex-shrink: 0;
}

.nc-bubble {
  padding: 9px 13px;
  border-radius: 14px;
  font-size: 14px;
  line-height: 1.5;
  word-break: break-word;
  position: relative;
}

.nc-message--mine .nc-bubble {
  background: linear-gradient(135deg, var(--neo-primaer, #ffa500), var(--neo-primaer-dunkel, #e09900));
  color: #fff;
  border-bottom-right-radius: 4px;
}

.nc-message--theirs .nc-bubble {
  background: rgba(255, 255, 255, 0.7);
  color: var(--neo-dunkel, #333d40);
  border: 1px solid rgba(var(--neo-primaer-dunkel-rgb), 0.15);
  border-bottom-left-radius: 4px;
}

.nc-msg-time {
  font-size: 10px;
  opacity: 0.65;
  margin-top: 3px;
  white-space: nowrap;
}

.nc-message--mine .nc-msg-time { text-align: right; }

.nc-bubble .nc-delete-btn {
  display: none;
  position: absolute;
  top: -8px;
  right: -8px;
  background: #dc3232;
  color: #fff;
  border: none;
  border-radius: 50%;
  width: 18px;
  height: 18px;
  font-size: 11px;
  line-height: 1;
  cursor: pointer;
  align-items: center;
  justify-content: center;
}
.nc-bubble:hover .nc-delete-btn { display: flex; }

.nc-bubble .nc-report-btn {
  display: none;
  position: absolute;
  top: -8px;
  left: -8px;
  background: #fff;
  color: #a00;
  border: 1px solid rgba(170, 0, 0, 0.4);
  border-radius: 50%;
  width: 18px;
  height: 18px;
  font-size: 10px;
  line-height: 1;
  cursor: pointer;
  align-items: center;
  justify-content: center;
  padding: 0;
}
.nc-message--theirs .nc-bubble:hover .nc-report-btn { display: flex; }
.nc-bubble .nc-report-btn:disabled { color: #2a8a2a; border-color: rgba(42, 138, 42, 0.4); cursor: default; }

/* --------------------------------------------------------------------------
   Laden-Button
   -------------------------------------------------------------------------- */
#nc-load-more {
  text-align: center;
  padding-bottom: 8px;
}

/* --------------------------------------------------------------------------
   Eingabe
   -------------------------------------------------------------------------- */
.nc-input-wrap {
  display: flex;
  gap: 8px;
  padding: 12px 16px;
  border-top: 1.5px solid rgba(var(--neo-primaer-dunkel-rgb), 0.2);
  flex-shrink: 0;
  background: rgba(255, 255, 255, 0.4);
  align-items: flex-end;
}

.nc-input {
  flex: 1;
  padding: 10px 14px;
  border: 1.5px solid rgba(var(--neo-primaer-dunkel-rgb), 0.3);
  border-radius: 12px;
  font-size: 14px;
  color: var(--neo-dunkel, #333d40);
  background: rgba(255, 255, 255, 0.6);
  resize: none;
  outline: none;
  transition: border-color 0.2s ease;
  max-height: 120px;
}
.nc-input:focus { border-color: var(--neo-primaer, #ffa500); }

.nc-send-btn {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: none;
  background: linear-gradient(135deg, var(--neo-primaer, #ffa500), var(--neo-primaer-dunkel, #e09900));
  color: #fff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: transform 0.15s ease;
  box-shadow: 0 2px 8px rgba(var(--neo-primaer-rgb), 0.3);
}
.nc-send-btn:hover { transform: scale(1.08); }

/* --------------------------------------------------------------------------
   Empty State
   -------------------------------------------------------------------------- */
.nc-empty-state {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #aaa;
  font-size: 14px;
  text-align: center;
  padding: 32px;
}

/* --------------------------------------------------------------------------
   Ladeindikator
   -------------------------------------------------------------------------- */
.nc-loading {
  width: 28px;
  height: 28px;
  border: 3px solid rgba(var(--neo-primaer-rgb), 0.2);
  border-top-color: var(--neo-primaer, #ffa500);
  border-radius: 50%;
  animation: nc-spin 0.7s linear infinite;
  margin: 32px auto;
}

/* --------------------------------------------------------------------------
   Modal
   -------------------------------------------------------------------------- */
.nc-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(var(--neo-dunkel-rgb), 0.5);
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  animation: nc-fade-in 0.15s ease;
}

.nc-modal {
  background: #fff;
  border-radius: 16px;
  width: 100%;
  max-width: 420px;
  box-shadow: 0 8px 40px rgba(var(--neo-dunkel-rgb), 0.2);
  overflow: hidden;
  animation: nc-slide-up 0.2s ease;
}

.nc-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid rgba(var(--neo-primaer-dunkel-rgb), 0.2);
}

.nc-modal-header h3 {
  font-size: 16px;
  font-weight: 700;
  color: var(--neo-dunkel, #333d40);
}

.nc-modal-close {
  background: none;
  border: none;
  font-size: 22px;
  cursor: pointer;
  color: #aaa;
  line-height: 1;
}
.nc-modal-close:hover { color: var(--neo-dunkel, #333d40); }

.nc-modal-body {
  padding: 20px;
}

.nc-modal-footer {
  margin-top: 16px;
}

.nc-search-input {
  width: 100%;
  padding: 10px 14px;
  border: 1.5px solid rgba(var(--neo-primaer-dunkel-rgb), 0.3);
  border-radius: 10px;
  font-size: 14px;
  color: var(--neo-dunkel, #333d40);
  outline: none;
  transition: border-color 0.2s ease;
}
.nc-search-input:focus { border-color: var(--neo-primaer, #ffa500); }

#nc-user-results {
  margin-top: 10px;
  max-height: 200px;
  overflow-y: auto;
}

.nc-user-result {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.15s ease;
}
.nc-user-result:hover { background: rgba(var(--neo-primaer-rgb), 0.08); }

.nc-user-result img {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  object-fit: cover;
}

.nc-user-result span { font-size: 14px; color: var(--neo-dunkel, #333d40); }

#nc-selected-users {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 10px;
}

.nc-user-tag {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: rgba(var(--neo-primaer-rgb), 0.12);
  border: 1px solid rgba(var(--neo-primaer-rgb), 0.3);
  border-radius: 20px;
  padding: 3px 10px;
  font-size: 13px;
  color: var(--neo-dunkel, #333d40);
}

.nc-user-tag button {
  background: none;
  border: none;
  cursor: pointer;
  color: #aaa;
  font-size: 14px;
  line-height: 1;
  padding: 0;
}
.nc-user-tag button:hover { color: #c00; }

/* --------------------------------------------------------------------------
   Nav-Badge (in Theme-Navigation)
   -------------------------------------------------------------------------- */
.neo-chat-nav-item {
  position: relative;
}

.neo-chat-nav-badge {
  position: absolute;
  top: -4px;
  right: -10px;
  background: #dc3232;
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  min-width: 16px;
  height: 16px;
  border-radius: 8px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 3px;
  pointer-events: none;
}

/* --------------------------------------------------------------------------
   Keyframes
   -------------------------------------------------------------------------- */
@keyframes nc-spin {
  to { transform: rotate(360deg); }
}

@keyframes nc-fade-in {
  from { opacity: 0; }
  to   { opacity: 1; }
}

@keyframes nc-slide-up {
  from { transform: translateY(20px); opacity: 0; }
  to   { transform: translateY(0);    opacity: 1; }
}

/* --------------------------------------------------------------------------
   Reduced Motion
   -------------------------------------------------------------------------- */
@media (prefers-reduced-motion: reduce) {
  .nc-message, .nc-modal, .nc-modal-overlay { animation: none; }
  .nc-send-btn:hover, .nc-btn-new:hover     { transform: none; }
}
