/**
 * css/chat.css — chat.bitty.cat styles
 *
 * Dark theme, Telegram-style layout.
 */

/* ── Variables ────────────────────────────────────────── */

:root {
  --bg-primary: #0a0a0f;
  --bg-secondary: #12121a;
  --bg-tertiary: #1a1a28;
  --bg-hover: #22223a;
  --bg-active: #2a2a44;
  --text-primary: #e8e8f0;
  --text-secondary: #9090a8;
  --text-muted: #606078;
  --accent: #7c3aed;
  --accent-hover: #6d28d9;
  --accent-dim: rgba(124, 58, 237, 0.15);
  --success: #22c55e;
  --warning: #f59e0b;
  --error: #ef4444;
  --border: #2a2a3e;
  --msg-mine-bg: #2e1065;
  --msg-other-bg: #1e1e30;
  --sidebar-width: 280px;
  --header-height: 56px;
  --input-height: 56px;
  --radius: 8px;
  --radius-lg: 12px;
  --shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

/* ── Reset & Base ─────────────────────────────────────── */

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

html,
body {
  height: 100%;
  overflow: hidden;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto,
    'Helvetica Neue', Arial, sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  font-size: 14px;
  line-height: 1.5;
}

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

.login-screen {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100vh;
  width: 100%;
  background: var(--bg-primary);
  text-align: center;
  padding: 20px;
}

.login-logo {
  font-size: 48px;
  margin-bottom: 8px;
}

.login-title {
  font-size: 28px;
  font-weight: 700;
  margin-bottom: 4px;
  letter-spacing: 1px;
}

.login-subtitle {
  font-size: 14px;
  color: var(--text-secondary);
  margin-bottom: 32px;
}

.login-btn {
  background: var(--accent);
  color: #fff;
  border: none;
  padding: 14px 32px;
  border-radius: var(--radius);
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  letter-spacing: 0.5px;
  transition: background 0.2s, transform 0.1s;
}

.login-btn:hover {
  background: var(--accent-hover);
}

.login-btn:active {
  transform: scale(0.98);
}

.login-btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.login-status {
  margin-top: 16px;
  color: var(--error);
  font-size: 13px;
  min-height: 20px;
}

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

.chat-app {
  display: flex;
  height: 100vh;
  width: 100%;
  overflow: hidden;
}

/* ── Sidebar ──────────────────────────────────────────── */

.sidebar {
  width: var(--sidebar-width);
  min-width: var(--sidebar-width);
  background: var(--bg-secondary);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  height: var(--header-height);
  border-bottom: 1px solid var(--border);
}

.sidebar-header h2 {
  font-size: 16px;
  font-weight: 600;
  letter-spacing: 0.5px;
}

.new-room-btn {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: none;
  background: var(--accent);
  color: #fff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  transition: background 0.2s;
}

.new-room-btn:hover {
  background: var(--accent-hover);
}

.sidebar-search {
  padding: 8px 12px;
  border-bottom: 1px solid var(--border);
}

.sidebar-search input {
  width: 100%;
  padding: 8px 12px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--bg-tertiary);
  color: var(--text-primary);
  font-size: 13px;
  outline: none;
}

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

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

.room-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  cursor: pointer;
  border-bottom: 1px solid rgba(255, 255, 255, 0.03);
  transition: background 0.15s;
}

.room-item:hover {
  background: var(--bg-hover);
}

.room-item.active {
  background: var(--bg-active);
  border-left: 3px solid var(--accent);
}

.room-icon {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--accent-dim);
  color: var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  flex-shrink: 0;
}

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

.room-name {
  font-size: 14px;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.room-type {
  font-size: 11px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

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

.chat-panel {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--bg-primary);
}

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

.sidebar-toggle {
  display: none;
  width: 36px;
  height: 36px;
  border: none;
  background: none;
  color: var(--text-primary);
  cursor: pointer;
  font-size: 18px;
  border-radius: var(--radius);
}

.sidebar-toggle:hover {
  background: var(--bg-hover);
}

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

.chat-header-info h3 {
  font-size: 15px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.chat-header-info .room-type-badge {
  font-size: 11px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.wallet-badge {
  font-size: 12px;
  color: var(--text-secondary);
  background: var(--bg-tertiary);
  padding: 4px 10px;
  border-radius: var(--radius);
}

.logout-btn {
  border: none;
  background: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 14px;
  padding: 6px;
  border-radius: var(--radius);
  transition: color 0.15s;
}

.logout-btn:hover {
  color: var(--error);
}

/* ── Messages Area ────────────────────────────────────── */

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

.msg {
  max-width: 70%;
  padding: 8px 14px;
  border-radius: var(--radius-lg);
  word-wrap: break-word;
  position: relative;
}

.msg-mine {
  background: var(--msg-mine-bg);
  align-self: flex-end;
  border-bottom-right-radius: 4px;
}

.msg-other {
  background: var(--msg-other-bg);
  align-self: flex-start;
  border-bottom-left-radius: 4px;
}

.msg-sender {
  font-size: 11px;
  font-weight: 600;
  color: var(--accent);
  margin-bottom: 2px;
}

.msg-mine .msg-sender {
  color: #a78bfa;
}

.msg-text {
  font-size: 14px;
  line-height: 1.45;
  white-space: pre-wrap;
}

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

/* ── Typing Indicator ─────────────────────────────────── */

.typing-indicator {
  padding: 0 16px;
  height: 20px;
  font-size: 12px;
  color: var(--text-muted);
  font-style: italic;
}

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

.chat-input {
  display: flex;
  align-items: flex-end;
  padding: 8px 12px;
  border-top: 1px solid var(--border);
  background: var(--bg-secondary);
  gap: 8px;
}

.chat-input textarea {
  flex: 1;
  resize: none;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-tertiary);
  color: var(--text-primary);
  padding: 10px 14px;
  font-size: 14px;
  font-family: inherit;
  line-height: 1.4;
  outline: none;
  min-height: 40px;
  max-height: 120px;
  overflow-y: auto;
}

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

.chat-input textarea::placeholder {
  color: var(--text-muted);
}

.send-btn {
  width: 40px;
  height: 40px;
  border: none;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  flex-shrink: 0;
  transition: background 0.2s, transform 0.1s;
}

.send-btn:hover {
  background: var(--accent-hover);
}

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

/* ── Empty State ──────────────────────────────────────── */

.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  color: var(--text-muted);
  text-align: center;
  padding: 40px;
}

.empty-state i {
  font-size: 48px;
  margin-bottom: 16px;
  opacity: 0.3;
}

.empty-state p {
  font-size: 14px;
}

/* ── Connection Status ────────────────────────────────── */

.connection-status {
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 10px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  font-weight: 600;
}

.status-connected {
  color: var(--success);
  background: rgba(34, 197, 94, 0.1);
}

.status-disconnected {
  color: var(--error);
  background: rgba(239, 68, 68, 0.1);
}

.status-connecting {
  color: var(--warning);
  background: rgba(245, 158, 11, 0.1);
}

/* ── Toast Notifications ──────────────────────────────── */

.toast-container {
  position: fixed;
  top: 16px;
  right: 16px;
  z-index: 10000;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}

.toast {
  padding: 10px 18px;
  border-radius: var(--radius);
  font-size: 13px;
  font-weight: 500;
  color: #fff;
  opacity: 0;
  transform: translateX(100%);
  transition: opacity 0.3s, transform 0.3s;
  pointer-events: auto;
  box-shadow: var(--shadow);
  max-width: 320px;
}

.toast.show {
  opacity: 1;
  transform: translateX(0);
}

.toast-info {
  background: var(--bg-tertiary);
  border-left: 3px solid var(--accent);
}

.toast-success {
  background: #064e3b;
  border-left: 3px solid var(--success);
}

.toast-warning {
  background: #78350f;
  border-left: 3px solid var(--warning);
}

.toast-error {
  background: #7f1d1d;
  border-left: 3px solid var(--error);
}

/* ── Modal ────────────────────────────────────────────── */

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(4px);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 9000;
}

.modal-overlay.active {
  display: flex;
}

.modal {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  width: 90%;
  max-width: 420px;
  box-shadow: var(--shadow);
  overflow: hidden;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
}

.modal-header h3 {
  font-size: 14px;
  font-weight: 600;
  letter-spacing: 0.5px;
}

.modal-close {
  border: none;
  background: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 22px;
  line-height: 1;
  padding: 0 4px;
}

.modal-close:hover {
  color: var(--text-primary);
}

.modal-body {
  padding: 20px;
}

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

.form-group label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.input {
  width: 100%;
  padding: 10px 14px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--bg-tertiary);
  color: var(--text-primary);
  font-size: 14px;
  font-family: inherit;
  outline: none;
}

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

select.input {
  cursor: pointer;
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%239090a8' fill='none' stroke-width='1.5'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 32px;
}

.btn-full {
  width: 100%;
  padding: 12px;
  border: none;
  border-radius: var(--radius);
  background: var(--accent);
  color: #fff;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  letter-spacing: 0.5px;
  transition: background 0.2s;
}

.btn-full:hover {
  background: var(--accent-hover);
}

/* ── Scrollbar ────────────────────────────────────────── */

::-webkit-scrollbar {
  width: 6px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--text-muted);
}

/* ── Responsive ───────────────────────────────────────── */

@media (max-width: 768px) {
  .sidebar {
    position: fixed;
    left: -100%;
    top: 0;
    bottom: 0;
    z-index: 5000;
    width: 85%;
    max-width: 320px;
    transition: left 0.3s ease;
    box-shadow: var(--shadow);
  }

  .sidebar.open {
    left: 0;
  }

  .sidebar-toggle {
    display: flex;
    align-items: center;
    justify-content: center;
  }

  .chat-panel {
    width: 100%;
  }

  .msg {
    max-width: 85%;
  }

  .wallet-badge {
    display: none;
  }
}
