/* Wiky Chat — Wecko Servis Design System */
:root {
  --green: #6db33f;
  --green-dark: #3d7a1f;
  --green-light: #8cc63f;
  --bg-dark: #0d1b0e;
  --bg-sidebar: #111a12;
  --bg-chat: #f5f5f5;
  --bg-message-user: #dcf8c6;
  --bg-message-ai: #ffffff;
  --text-primary: #1a1a1a;
  --text-secondary: #666;
  --text-light: rgba(255,255,255,0.9);
  --text-muted: rgba(255,255,255,0.5);
  --border: #e0e0e0;
  --border-dark: rgba(255,255,255,0.08);
  --shadow: 0 1px 3px rgba(0,0,0,0.1);
  --radius: 12px;
  --radius-sm: 8px;
  --sidebar-width: 300px;
  --header-height: 60px;
  --input-height: 60px;
}

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

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
  background: var(--bg-chat);
  color: var(--text-primary);
}

#app {
  display: flex;
  height: 100%;
}

/* Sidebar */
#sidebar {
  width: var(--sidebar-width);
  min-width: var(--sidebar-width);
  background: var(--bg-sidebar);
  display: flex;
  flex-direction: column;
  border-right: 1px solid var(--border-dark);
  z-index: 100;
}

.sidebar-header {
  padding: 20px 16px 12px;
  border-bottom: 1px solid var(--border-dark);
}

.logo-row {
  display: flex;
  align-items: center;
  gap: 12px;
}

.logo-icon {
  width: 42px;
  height: 42px;
  background: linear-gradient(135deg, var(--green), var(--green-dark));
  border-radius: var(--radius);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 20px;
  color: white;
  flex-shrink: 0;
}

.logo-name {
  font-size: 18px;
  font-weight: 800;
  color: var(--text-light);
  display: block;
}

.logo-sub {
  font-size: 11px;
  color: var(--text-muted);
  font-weight: 500;
  letter-spacing: 0.5px;
}

.sidebar-search {
  padding: 12px 16px;
}

.sidebar-search input {
  width: 100%;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-dark);
  background: rgba(255,255,255,0.05);
  color: var(--text-light);
  font-size: 13px;
  font-family: inherit;
  outline: none;
  transition: border-color 0.2s;
}

.sidebar-search input::placeholder { color: var(--text-muted); }
.sidebar-search input:focus { border-color: var(--green); }

.channel-list {
  flex: 1;
  overflow-y: auto;
  padding: 4px 8px;
}

.channel-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background 0.15s;
  margin-bottom: 2px;
}

.channel-item:hover { background: rgba(255,255,255,0.05); }
.channel-item.active { background: rgba(109,179,63,0.15); }

.channel-icon {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: rgba(255,255,255,0.08);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  flex-shrink: 0;
}

.channel-item.active .channel-icon {
  background: rgba(109,179,63,0.25);
}

.channel-info { flex: 1; min-width: 0; }

.channel-name {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-light);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.channel-desc {
  font-size: 12px;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-top: 2px;
}

.channel-badge {
  background: var(--green);
  color: white;
  font-size: 11px;
  font-weight: 700;
  min-width: 20px;
  height: 20px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 6px;
}

.sidebar-footer {
  padding: 12px 16px;
  border-top: 1px solid var(--border-dark);
}

.user-info {
  display: flex;
  align-items: center;
  gap: 10px;
}

.user-avatar {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--green), var(--green-dark));
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 14px;
  color: white;
}

.user-name {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-light);
}

/* Chat area */
#chatArea {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.chat-header {
  height: var(--header-height);
  padding: 0 20px;
  display: flex;
  align-items: center;
  gap: 12px;
  background: white;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.menu-btn {
  display: none;
  background: none;
  border: none;
  font-size: 22px;
  cursor: pointer;
  color: var(--text-primary);
  padding: 4px;
}

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

.chat-header-icon { font-size: 24px; }

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

.chat-header-desc {
  font-size: 12px;
  color: var(--text-secondary);
}

/* Messages */
.messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px 20px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  background: var(--bg-chat);
  scroll-behavior: smooth;
}

.messages-empty {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  gap: 8px;
}

.empty-icon { font-size: 48px; opacity: 0.6; }
.empty-title { font-size: 18px; font-weight: 700; color: var(--text-primary); }
.empty-text { font-size: 14px; color: var(--text-secondary); }

.msg {
  max-width: 75%;
  padding: 10px 14px;
  border-radius: 12px;
  font-size: 14px;
  line-height: 1.5;
  word-wrap: break-word;
  position: relative;
  animation: msgIn 0.2s ease-out;
}

@keyframes msgIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

.msg-user {
  align-self: flex-end;
  background: var(--bg-message-user);
  border-bottom-right-radius: 4px;
  color: var(--text-primary);
}

.msg-ai {
  align-self: flex-start;
  background: var(--bg-message-ai);
  border-bottom-left-radius: 4px;
  box-shadow: var(--shadow);
  color: var(--text-primary);
}

.msg-sender {
  font-size: 12px;
  font-weight: 700;
  color: var(--green-dark);
  margin-bottom: 2px;
}

.msg-ai .msg-sender { color: var(--green); }

.msg-time {
  font-size: 10px;
  color: var(--text-secondary);
  text-align: right;
  margin-top: 4px;
  opacity: 0.7;
}

.msg-content p { margin: 0 0 8px; }
.msg-content p:last-child { margin-bottom: 0; }
.msg-content code {
  background: rgba(0,0,0,0.06);
  padding: 2px 5px;
  border-radius: 4px;
  font-size: 13px;
}
.msg-content pre {
  background: #1e1e1e;
  color: #d4d4d4;
  padding: 12px;
  border-radius: 8px;
  overflow-x: auto;
  font-size: 13px;
  margin: 8px 0;
}
.msg-content pre code {
  background: none;
  padding: 0;
  color: inherit;
}
.msg-content ul, .msg-content ol {
  padding-left: 20px;
  margin: 4px 0;
}
.msg-content strong { font-weight: 700; }
.msg-content table {
  border-collapse: collapse;
  width: 100%;
  margin: 8px 0;
  font-size: 13px;
}
.msg-content th, .msg-content td {
  border: 1px solid var(--border);
  padding: 6px 10px;
  text-align: left;
}
.msg-content th { background: #f0f0f0; font-weight: 600; }

.msg-typing {
  align-self: flex-start;
  background: var(--bg-message-ai);
  box-shadow: var(--shadow);
  padding: 14px 18px;
  border-radius: 12px;
  border-bottom-left-radius: 4px;
}

.typing-dots {
  display: flex;
  gap: 4px;
}

.typing-dots span {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--green);
  animation: typing 1.4s infinite;
}

.typing-dots span:nth-child(2) { animation-delay: 0.2s; }
.typing-dots span:nth-child(3) { animation-delay: 0.4s; }

@keyframes typing {
  0%, 60%, 100% { opacity: 0.3; transform: scale(0.8); }
  30% { opacity: 1; transform: scale(1); }
}

/* Input area */
.chat-input-area {
  padding: 12px 20px 16px;
  background: white;
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}

.chat-input-wrapper {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  background: #f0f0f0;
  border-radius: 24px;
  padding: 6px 6px 6px 18px;
  transition: background 0.2s;
}

.chat-input-wrapper:focus-within {
  background: #e8e8e8;
}

#messageInput {
  flex: 1;
  border: none;
  background: none;
  font-size: 14px;
  font-family: inherit;
  line-height: 1.4;
  padding: 8px 0;
  resize: none;
  outline: none;
  max-height: 120px;
  color: var(--text-primary);
}

#messageInput::placeholder { color: var(--text-secondary); }

.send-btn {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: none;
  background: var(--green);
  color: white;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background 0.2s, opacity 0.2s;
}

.send-btn:hover { background: var(--green-dark); }
.send-btn:disabled { opacity: 0.4; cursor: default; }
.send-btn:disabled:hover { background: var(--green); }

/* Sidebar overlay for mobile */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 99;
}

/* Date separator */
.date-separator {
  text-align: center;
  padding: 12px 0;
}

.date-separator span {
  background: rgba(0,0,0,0.06);
  padding: 4px 12px;
  border-radius: 8px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
}

/* Scrollbar */
.messages::-webkit-scrollbar,
.channel-list::-webkit-scrollbar {
  width: 6px;
}
.messages::-webkit-scrollbar-thumb,
.channel-list::-webkit-scrollbar-thumb {
  background: rgba(0,0,0,0.15);
  border-radius: 3px;
}
.channel-list::-webkit-scrollbar-thumb {
  background: rgba(255,255,255,0.1);
}

/* Mobile */
@media (max-width: 768px) {
  :root {
    --sidebar-width: 280px;
  }

  #sidebar {
    position: fixed;
    left: 0;
    top: 0;
    bottom: 0;
    transform: translateX(-100%);
    transition: transform 0.25s ease;
    z-index: 100;
  }

  #sidebar.open {
    transform: translateX(0);
  }

  .sidebar-overlay.active {
    display: block;
  }

  .menu-btn {
    display: block;
  }

  .msg {
    max-width: 88%;
  }

  .chat-input-area {
    padding: 8px 12px 12px;
  }

  .messages {
    padding: 12px;
  }
}
