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

:root {
  --primary: #0078d4;
  --primary-dark: #005a9e;
  --bg: #f5f5f5;
  --card-bg: #fff;
  --text: #1a1a1a;
  --text-muted: #666;
  --border: #e0e0e0;
  --msg-customer: #e3f2fd;
  --msg-support: #fff;
  --sidebar-bg: #1e1e2e;
  --sidebar-text: #cdd6f4;
  --sidebar-active: #313244;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  height: 100vh;
  overflow: hidden;
}

.hidden { display: none !important; }

/* ─── Login ─────────────────────────────── */

.login-container {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 20px;
}

.login-card {
  background: var(--card-bg);
  border-radius: 12px;
  padding: 48px 40px;
  box-shadow: 0 2px 12px rgba(0,0,0,0.08);
  width: 100%;
  max-width: 420px;
  text-align: center;
}

.login-card h1 {
  font-size: 28px;
  margin-bottom: 8px;
}

.login-card .subtitle {
  color: var(--text-muted);
  margin-bottom: 32px;
}

.login-card input[type="email"] {
  width: 100%;
  padding: 14px 16px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 16px;
  margin-bottom: 16px;
  outline: none;
  transition: border-color 0.2s;
}

.login-card input[type="email"]:focus {
  border-color: var(--primary);
}

.login-card button {
  width: 100%;
  padding: 14px;
  background: var(--primary);
  color: #fff;
  border: none;
  border-radius: 8px;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s;
}

.login-card button:hover { background: var(--primary-dark); }
.login-card button:disabled { opacity: 0.6; cursor: not-allowed; }

.success-msg {
  margin-top: 24px;
  padding: 16px;
  background: #e8f5e9;
  border-radius: 8px;
  color: #2e7d32;
}

.error-msg {
  margin-top: 16px;
  padding: 12px;
  background: #ffebee;
  border-radius: 8px;
  color: #c62828;
}

/* ─── Chat Layout ───────────────────────── */

.chat-app {
  display: flex;
  height: 100vh;
}

.sidebar {
  width: 260px;
  background: var(--sidebar-bg);
  color: var(--sidebar-text);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
}

.sidebar-header {
  padding: 20px;
  border-bottom: 1px solid rgba(255,255,255,0.08);
}

.sidebar-header h2 {
  font-size: 16px;
  color: #fff;
  margin-bottom: 4px;
}

.sidebar-header .org-name {
  font-size: 13px;
  opacity: 0.6;
}

.channel-list {
  flex: 1;
  overflow-y: auto;
  padding: 12px 0;
}

.channel-item {
  padding: 10px 20px;
  cursor: pointer;
  font-size: 14px;
  display: flex;
  align-items: center;
  gap: 8px;
  transition: background 0.15s;
}

.channel-item:hover { background: rgba(255,255,255,0.05); }
.channel-item.active { background: var(--sidebar-active); color: #fff; }

.channel-item .channel-icon {
  font-size: 16px;
  opacity: 0.5;
}

.channel-item .unread-badge {
  margin-left: auto;
  background: var(--primary);
  color: #fff;
  font-size: 11px;
  padding: 2px 7px;
  border-radius: 10px;
  font-weight: 600;
}

.sidebar-footer {
  padding: 16px 20px;
  border-top: 1px solid rgba(255,255,255,0.08);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.sidebar-footer .user-name {
  font-size: 13px;
}

.sidebar-footer button {
  background: none;
  border: none;
  color: var(--sidebar-text);
  cursor: pointer;
  font-size: 13px;
  opacity: 0.6;
}

.sidebar-footer button:hover { opacity: 1; }

/* ─── Chat Panel ────────────────────────── */

.chat-panel {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.chat-header {
  padding: 16px 24px;
  border-bottom: 1px solid var(--border);
  background: var(--card-bg);
  font-weight: 600;
  font-size: 16px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.chat-header .typing-indicator {
  font-weight: 400;
  font-size: 13px;
  color: var(--text-muted);
  font-style: italic;
}

.messages-container {
  flex: 1;
  overflow-y: auto;
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.message {
  max-width: 70%;
  padding: 10px 16px;
  border-radius: 12px;
  font-size: 14px;
  line-height: 1.5;
  word-break: break-word;
}

.message.customer {
  align-self: flex-end;
  background: var(--primary);
  color: #fff;
  border-bottom-right-radius: 4px;
}

.message.support {
  align-self: flex-start;
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-bottom-left-radius: 4px;
}

.message .msg-sender {
  font-size: 12px;
  font-weight: 600;
  margin-bottom: 2px;
  opacity: 0.8;
}

.message .msg-time {
  font-size: 11px;
  opacity: 0.6;
  margin-top: 4px;
}

.message.support .msg-sender { color: var(--primary); }

/* ─── Input ─────────────────────────────── */

.chat-input-area {
  padding: 16px 24px;
  border-top: 1px solid var(--border);
  background: var(--card-bg);
}

.chat-input-area form {
  display: flex;
  gap: 12px;
}

.chat-input-area textarea {
  flex: 1;
  padding: 12px 16px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 14px;
  font-family: inherit;
  resize: none;
  outline: none;
  max-height: 120px;
  min-height: 44px;
}

.chat-input-area textarea:focus {
  border-color: var(--primary);
}

.chat-input-area button {
  padding: 0 20px;
  background: var(--primary);
  color: #fff;
  border: none;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s;
  white-space: nowrap;
}

.chat-input-area button:hover { background: var(--primary-dark); }

.no-channel-selected {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  font-size: 16px;
}

/* ─── Mobile ────────────────────────────── */

@media (max-width: 640px) {
  .sidebar { width: 100%; position: absolute; z-index: 10; }
  .sidebar.collapsed { display: none; }
  .message { max-width: 85%; }
}
