:root {
  --bg-sidebar: #0f111a;
  --bg-chat: #090a0f;
  --bg-message-out: #3b82f6;
  --bg-message-in: #1e293b;
  --bg-input: #1e293b;
  --accent: #ec4899;
  --text-primary: #f8fafc;
  --text-secondary: #94a3b8;
  --border: #2a2a3c;
  --fab-bg: linear-gradient(135deg, #ec4899, #8b5cf6);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: 'Segoe UI', 'Helvetica Neue', Helvetica, Arial, sans-serif;
  background: #000;
  color: var(--text-primary);
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
  display: flex;
}

.app-container {
  display: flex;
  width: 100vw;
  width: 100dvw;
  height: 100vh;
  height: 100dvh;
  background: var(--bg-chat);
  position: relative;
}


.sidebar {
  width: 30%;
  min-width: 300px;
  max-width: 420px;
  background: var(--bg-sidebar);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: relative;
  z-index: 5;
}

.sidebar-header {
  height: 60px;
  background: var(--bg-input);
  display: flex;
  align-items: center;
  padding: 0 16px;
  border-bottom: 1px solid var(--border);
  font-weight: 600;
  font-size: 16px;
  gap: 12px;
  color: var(--text-primary);
}

.sidebar-header svg {
  fill: var(--text-secondary);
}

.room-list-container {
  flex: 1;
  overflow-y: auto;
}

.room-list-empty {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 100%;
  color: var(--text-secondary);
  text-align: center;
  font-size: 14px;
  padding: 0 20px;
  line-height: 1.5;
  box-sizing: border-box;
  pointer-events: none;
}

.room-item {
  display: flex;
  align-items: center;
  padding: 12px 16px;
  cursor: pointer;
  transition: background 0.1s;
  border-bottom: 1px solid var(--border);
}

.room-item:hover {
  background: #202c33;
}

.room-item.active {
  background: #2a3942;
}

.room-avatar {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  font-weight: bold;
  color: white;
  margin-right: 12px;
  flex-shrink: 0;
}

.room-info {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.room-top {
  display: flex;
  justify-content: space-between;
  margin-bottom: 4px;
}

.room-name {
  font-weight: 600;
  font-size: 16px;
  text-overflow: ellipsis;
  white-space: nowrap;
  overflow: hidden;
  color: var(--text-primary);
}

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

.room-top-right {
  display: flex;
  align-items: center;
  gap: 8px;
}

.room-menu-container {
  position: relative;
  display: inline-block;
}

.room-menu-btn {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text-secondary);
  padding: 4px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transform: scale(0.8);
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  width: 24px;
  height: 24px;
}

.room-menu-btn:hover {
  background: rgba(255, 255, 255, 0.08);
  color: var(--text-primary);
}

.room-item:hover .room-menu-btn,
.room-menu-container.active .room-menu-btn {
  opacity: 1;
  pointer-events: auto;
  transform: scale(1);
}

.room-menu-btn svg {
  width: 16px;
  height: 16px;
  fill: currentColor;
}

.room-dropdown {
  position: absolute;
  top: 100%;
  right: 0;
  background: #1f2c34;
  border-radius: 8px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4), 0 2px 4px rgba(0, 0, 0, 0.3);
  padding: 4px 0;
  min-width: 130px;
  z-index: 50;
  opacity: 0;
  transform: translateY(-8px) scale(0.95);
  pointer-events: none;
  transition: opacity 0.15s ease, transform 0.15s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.room-dropdown.active {
  opacity: 1;
  transform: translateY(4px) scale(1);
  pointer-events: auto;
}

.dropdown-item {
  width: 100%;
  background: none;
  border: none;
  padding: 10px 16px;
  text-align: left;
  font-size: 14px;
  color: var(--text-primary);
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 10px;
  font-family: inherit;
  transition: background 0.15s ease;
}

.dropdown-item:hover {
  background: rgba(255, 255, 255, 0.05);
}

.dropdown-item.delete {
  color: #ef4444;
}

.dropdown-item.delete:hover {
  background: rgba(239, 68, 68, 0.1);
}

.dropdown-item svg {
  width: 16px;
  height: 16px;
  fill: currentColor;
  flex-shrink: 0;
}

.room-bottom {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.room-preview {
  font-size: 14px;
  color: var(--text-secondary);
  text-overflow: ellipsis;
  white-space: nowrap;
  overflow: hidden;
  margin-right: 8px;
}

.unread-badge {
  background: var(--accent);
  color: #111b21;
  font-size: 12px;
  font-weight: bold;
  padding: 2px 6px;
  border-radius: 10px;
  min-width: 20px;
  text-align: center;
}


.fab {
  position: absolute;
  bottom: 24px;
  right: 24px;
  width: 56px;
  height: 56px;
  background: var(--fab-bg);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
  border: none;
  color: white;
  transition: transform 0.2s cubic-bezier(0.34, 1.56, 0.64, 1), box-shadow 0.2s;
  z-index: 10;
}

.fab:hover {
  transform: scale(1.05);
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.4);
}

.fab svg {
  width: 24px;
  height: 24px;
  stroke: currentColor;
  stroke-width: 2;
  fill: none;
  stroke-linecap: round;
  stroke-linejoin: round;
}


.main-area {
  flex: 1;
  display: flex;
  flex-direction: column;
  background: var(--bg-chat);
  position: relative;
}

.main-empty {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: var(--bg-sidebar);
  border-bottom: 6px solid var(--accent);
  text-align: center;
  padding: 20px;
}

.main-empty svg {
  fill: #41525d;
  margin-bottom: 24px;
}

.main-empty h1 {
  font-weight: 300;
  font-size: 32px;
  color: var(--text-primary);
  margin-bottom: 16px;
}

.main-empty p {
  color: var(--text-secondary);
  font-size: 14px;
  line-height: 1.5;
}


.chat-area {
  display: flex;
  flex-direction: column;
  height: 100%;
  display: none;
}

.chat-header {
  height: 60px;
  background: var(--bg-input);
  display: flex;
  align-items: center;
  padding: 0 16px;
  border-bottom: 1px solid var(--border);
  gap: 12px;
}

.back-btn {
  display: none;
  background: none;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  padding: 8px;
  border-radius: 50%;
}

.back-btn:hover {
  background: rgba(255, 255, 255, 0.05);
}

.back-btn svg {
  width: 24px;
  height: 24px;
  fill: currentColor;
}

.chat-header-info {
  display: flex;
  flex-direction: column;
}

.chat-header-name {
  font-weight: 600;
  font-size: 16px;
  color: var(--text-primary);
}

.chat-header-online {
  font-size: 13px;
  color: var(--text-secondary);
  margin-top: 2px;
}


.chat-body {
  flex: 1;
  overflow-y: auto;
  padding: 20px 5%;
  display: flex;
  flex-direction: column;
  background-image: radial-gradient(circle at center, rgba(255, 255, 255, 0.02) 1px, transparent 1px);
  background-size: 20px 20px;
}

.chat-body::-webkit-scrollbar {
  width: 6px;
}

.chat-body::-webkit-scrollbar-thumb {
  background-color: rgba(255, 255, 255, 0.15);
  border-radius: 3px;
}


.message-wrapper {
  display: flex;
  margin-bottom: 8px;
  flex-direction: column;
}

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

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

.message-bubble {
  max-width: 75%;
  min-width: 0;
  word-break: break-word;
  overflow-wrap: break-word;
  padding: 6px 8px;
  font-size: 14px;
  position: relative;
  box-shadow: 0 1px 0.5px rgba(11, 20, 26, .13);
  line-height: 1.4;
  animation: slideUp 0.2s cubic-bezier(0.1, 0.8, 0.2, 1);
}

@keyframes slideUp {
  0% {
    opacity: 0;
    transform: translateY(10px);
  }

  100% {
    opacity: 1;
    transform: translateY(0);
  }
}

.message-bubble.out {
  background: linear-gradient(135deg, #3b82f6, #6366f1);
  border-radius: 8px 0 8px 8px;
  color: #ffffff;
}

.message-bubble.in {
  background: var(--bg-message-in);
  border-radius: 0 8px 8px 8px;
  border: 1px solid rgba(255, 255, 255, 0.05);
}

.message-bubble.ai {
  background: linear-gradient(135deg, #1a1a2e, #16213e);
  border-left: 3px solid var(--accent);
  border-radius: 0 8px 8px 8px;
}

.sender-name {
  font-size: 13px;
  font-weight: bold;
  margin-bottom: 3px;
  cursor: pointer;
}

.ai-sender {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 13px;
  font-weight: bold;
  color: #a180ff;
  margin-bottom: 3px;
}

.message-content {
  word-wrap: break-word;
  word-break: break-word;
  overflow-wrap: break-word;
  white-space: pre-wrap;
  margin-bottom: 12px;
}

.message-content.ai-text {
  font-style: italic;
  color: #e9edef;
}

.message-footer {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  color: rgba(255, 255, 255, 0.7);
  margin-top: -12px;
  float: right;
  margin-left: 12px;
  position: relative;
  bottom: -2px;
}

.read-receipt svg {
  width: 16px;
  height: 16px;
  fill: #60a5fa;
}

.read-receipt.sent svg {
  fill: rgba(255, 255, 255, 0.7);
}

.system-msg {
  text-align: center;
  margin: 12px 0;
}

.system-msg span {
  background: rgba(255, 255, 255, 0.08);
  padding: 5px 12px;
  border-radius: 12px;
  font-size: 12px;
  color: rgba(255, 255, 255, 0.8);
}


.file-preview {
  display: block;
  max-width: 100%;
  border-radius: 6px;
  margin-bottom: 6px;
}

.file-link {
  display: flex;
  align-items: center;
  gap: 8px;
  background: rgba(0, 0, 0, 0.2);
  padding: 10px;
  border-radius: 6px;
  text-decoration: none;
  color: inherit;
  margin-bottom: 6px;
}

.file-link svg {
  width: 24px;
  height: 24px;
  fill: var(--text-secondary);
}

.file-link span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 200px;
}


.typing-container {
  padding: 8px 14px;
  background: var(--bg-message-in);
  border-radius: 16px;
  width: fit-content;
  display: none;
  margin-bottom: 8px;
  align-self: flex-start;
  align-items: center;
  border: 1px solid rgba(255, 255, 255, 0.05);
}

.typing-text {
  font-size: 13px;
  color: var(--accent);
  margin-right: 8px;
  font-weight: 600;
}

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

.typing-dot {
  width: 5px;
  height: 5px;
  background: var(--text-secondary);
  border-radius: 50%;
  animation: typing-bounce 1s infinite;
}

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

.typing-dot:nth-child(2) {
  animation-delay: 150ms;
}

.typing-dot:nth-child(3) {
  animation-delay: 300ms;
}

@keyframes typing-bounce {

  0%,
  60%,
  100% {
    transform: translateY(0);
  }

  30% {
    transform: translateY(-4px);
  }
}


.input-bar-container {
  background: var(--bg-input);
  padding: 10px 16px;
  display: flex;
  flex-direction: column;
  position: relative;
}

.attached-file-preview {
  background: var(--bg-sidebar);
  border-radius: 8px;
  padding: 12px;
  display: none;
  align-items: center;
  gap: 12px;
  margin-bottom: 8px;
}

.attached-file-preview.active {
  display: flex;
}

.attached-filename {
  flex: 1;
  font-size: 14px;
  color: var(--text-primary);
  text-overflow: ellipsis;
  overflow: hidden;
  white-space: nowrap;
}

.remove-file-btn {
  background: none;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  padding: 4px;
}

.remove-file-btn:hover {
  color: #f15c6d;
}

.input-bar {
  display: flex;
  align-items: flex-end;
  gap: 12px;
}

.icon-btn {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text-secondary);
  padding: 8px;
  border-radius: 50%;
  transition: background 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
  height: 42px;
  width: 42px;
  flex-shrink: 0;
}

.icon-btn:hover {
  background: rgba(255, 255, 255, 0.05);
}

.icon-btn svg {
  width: 24px;
  height: 24px;
  fill: currentColor;
}

.input-container {
  flex: 1;
  background: var(--bg-sidebar);
  border-radius: 8px;
  display: flex;
  align-items: center;
  padding: 0 16px;
  min-height: 42px;
}

.message-input {
  width: 100%;
  border: none;
  background: transparent;
  color: var(--text-primary);
  font-size: 15px;
  font-family: inherit;
  padding: 10px 0;
  outline: none;
  resize: none;
  max-height: 120px;
  overflow-y: auto;
  line-height: 1.4;
}

.message-input::placeholder {
  color: var(--text-secondary);
}

.send-btn {
  background: var(--accent);
  border: none;
  width: 42px;
  height: 42px;
  border-radius: 50%;
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: transform 0.1s;
  flex-shrink: 0;
}

.send-btn:active {
  transform: scale(0.95);
}

.send-btn svg {
  width: 20px;
  height: 20px;
  fill: currentColor;
  transform: translateX(2px);
}


.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(11, 20, 26, 0.85);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s;
}

.modal-overlay.active {
  opacity: 1;
  pointer-events: auto;
}

.modal-content {
  background: var(--bg-sidebar);
  width: 90%;
  max-width: 380px;
  padding: 24px;
  border-radius: 12px;
  box-shadow: 0 17px 50px 0 rgba(0, 0, 0, .19), 0 12px 15px 0 rgba(0, 0, 0, .24);
  transform: scale(0.95);
  transition: transform 0.2s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.modal-overlay.active .modal-content {
  transform: scale(1);
}

.modal-title {
  font-size: 20px;
  font-weight: 500;
  margin-bottom: 24px;
  color: var(--text-primary);
  text-align: center;
}

.form-group {
  margin-bottom: 16px;
}

.form-input {
  width: 100%;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 14px;
  color: var(--text-primary);
  font-size: 15px;
  outline: none;
  transition: border-color 0.2s;
  font-family: inherit;
}

.form-input:focus {
  border-color: var(--accent);
}

.form-input::placeholder {
  color: var(--text-secondary);
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 12px;
  margin-top: 28px;
}

.btn-cancel {
  background: transparent;
  color: var(--accent);
  border: none;
  padding: 10px 16px;
  border-radius: 8px;
  cursor: pointer;
  font-weight: 600;
  font-size: 14px;
  transition: background 0.2s;
}

.btn-cancel:hover {
  background: rgba(0, 168, 132, 0.1);
}

.btn-primary {
  background: var(--accent);
  color: #111b21;
  border: none;
  padding: 10px 24px;
  border-radius: 8px;
  cursor: pointer;
  font-weight: 600;
  font-size: 14px;
  transition: background 0.2s;
}

.btn-primary:hover {
  background: #008f6f;
}


@media (max-width: 768px) {
  .sidebar {
    width: 100%;
    min-width: 100%;
  }

  .main-area {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 20;
    transform: translateX(100%);
    transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
    display: flex !important;
  }

  .main-area.active {
    transform: translateX(0);
  }

  .back-btn {
    display: block;
  }
}


@media (max-width: 400px) {
  .sidebar-header {
    height: 52px;
    padding: 0 12px;
    font-size: 15px;
  }

  .room-item {
    padding: 10px 12px;
  }

  .room-avatar {
    width: 40px;
    height: 40px;
    font-size: 16px;
    margin-right: 10px;
  }

  .room-name {
    font-size: 14px;
  }

  .room-preview {
    font-size: 12px;
  }

  .chat-header {
    height: 52px;
    padding: 0 10px;
    gap: 8px;
  }

  .chat-header-name {
    font-size: 14px;
  }

  .chat-header-online {
    font-size: 11px;
  }

  .back-btn {
    padding: 6px;
  }

  .chat-body {
    padding: 12px 3%;
  }

  .message-bubble {
    max-width: 85%;
    padding: 6px 10px;
    font-size: 13.5px;
  }

  .sender-name,
  .ai-sender {
    font-size: 12px;
  }

  .message-footer {
    font-size: 10px;
  }

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

  .input-bar {
    gap: 8px;
  }

  .icon-btn {
    width: 36px;
    height: 36px;
    padding: 6px;
  }

  .input-container {
    padding: 0 10px;
    min-height: 36px;
  }

  .message-input {
    font-size: 14px;
    padding: 8px 0;
  }

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

  .send-btn svg {
    width: 16px;
    height: 16px;
  }

  .modal-content {
    padding: 16px;
  }

  .modal-title {
    font-size: 18px;
    margin-bottom: 16px;
  }

  .form-input {
    padding: 10px;
    font-size: 14px;
  }

  .fab {
    bottom: 16px;
    right: 16px;
    width: 48px;
    height: 48px;
  }

  .fab svg {
    width: 20px;
    height: 20px;
  }
}


@media (max-width: 360px) {
  .chat-body {
    padding: 10px 8px;
    gap: 6px;
  }
  .message-bubble {
    max-width: 88%;
    padding: 6px 8px;
    font-size: 13px;
    border-radius: 8px;
  }
  .sidebar-header {
    height: 48px;
    font-size: 14px;
    padding: 0 10px;
  }
  .chat-header {
    height: 48px;
    padding: 0 8px;
  }
  .chat-header-name {
    font-size: 13px;
  }
  .chat-header-online {
    font-size: 10px;
  }
  .input-bar-container {
    padding: 6px 8px;
  }
  .input-container {
    padding: 0 8px;
    min-height: 34px;
  }
  .message-input {
    font-size: 13px;
    padding: 6px 0;
  }
  .icon-btn {
    width: 32px;
    height: 32px;
    padding: 4px;
  }
  .send-btn {
    width: 34px;
    height: 34px;
  }
  .send-btn svg {
    width: 14px;
    height: 14px;
  }
}
