/* src/frontend/index.css */
* {
  box-sizing: border-box;
}

:root {
  --bg: #0a0c11;
  --surface: #12151c;
  --surface-2: #191d27;
  --surface-3: #222735;
  --border: #262b38;
  --text: #eceef4;
  --text-dim: #8e93a6;
  --text-faint: #5b6072;
  --accent: #7c6cff;
  --accent-2: #22d3ee;
  --accent-soft: #7c6cff26;
  --danger: #ff5c7a;
  --bubble-me: linear-gradient(135deg, #6e5bff 0%, #8a3ffc 100%);
  --bubble-them: #1b1f2a;
  --radius: 16px;
  --shadow-glow: 0 0 0 1px #ffffff08, 0 8px 24px -8px #6e5bff40;
}

html, body, #root {
  height: 100%;
}

body {
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, Inter, Segoe UI, Roboto, sans-serif;
}

::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

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

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

::-webkit-scrollbar-thumb:hover {
  background: #2c3242;
}

button {
  cursor: pointer;
  font-family: inherit;
}

a {
  color: var(--accent-2);
}

.login-screen {
  display: flex;
  background: radial-gradient(circle at 20% 20%, #6e5bff22, transparent 40%), radial-gradient(circle at 80% 80%, #22d3ee1a, transparent 40%), var(--bg);
  justify-content: center;
  align-items:  center;
  height: 100%;
}

.login-card {
  background: var(--surface);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-glow);
  border-radius: 20px;
  width: 380px;
  padding: 36px 32px;
}

.login-brand {
  display: flex;
  align-items:  center;
  gap: 10px;
  margin-bottom: 28px;
}

.login-brand-mark {
  background: var(--bubble-me);
  display: flex;
  border-radius: 10px;
  justify-content: center;
  align-items:  center;
  width: 36px;
  height: 36px;
  font-size: 15px;
  font-weight: 700;
}

.login-brand-name {
  letter-spacing: -.01em;
  font-size: 17px;
  font-weight: 700;
}

.login-title {
  margin: 0 0 4px;
  font-size: 20px;
  font-weight: 700;
}

.login-subtitle {
  color: var(--text-dim);
  margin: 0 0 24px;
  font-size: 13.5px;
}

.field {
  margin-bottom: 16px;
}

.field label {
  display: block;
  color: var(--text-dim);
  margin-bottom: 6px;
  font-size: 12.5px;
  font-weight: 600;
}

.field input {
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text);
  outline: none;
  border-radius: 10px;
  width: 100%;
  padding: 11px 13px;
  transition: border-color .15s;
  font-size: 14.5px;
}

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

.field input.otp-input {
  letter-spacing: .4em;
  text-align: center;
  font-size: 22px;
  font-weight: 700;
}

.btn-primary {
  background: var(--bubble-me);
  color: #fff;
  border: none;
  border-radius: 10px;
  width: 100%;
  padding: 12px;
  transition: filter .15s, transform .1s;
  font-size: 14.5px;
  font-weight: 700;
}

.btn-primary:hover {
  filter: brightness(1.08);
}

.btn-primary:active {
  transform: scale(.98);
}

.btn-primary:disabled {
  opacity: .5;
  cursor: not-allowed;
}

.btn-link {
  color: var(--text-dim);
  background: none;
  border: none;
  margin-top: 14px;
  padding: 0;
  font-size: 13px;
}

.btn-link:hover {
  color: var(--text);
}

.error-banner {
  color: #ff90a5;
  background: #ff5c7a1a;
  border: 1px solid #ff5c7a40;
  border-radius: 10px;
  margin-bottom: 16px;
  padding: 10px 12px;
  font-size: 13px;
}

.app-shell {
  display: flex;
  height: 100%;
}

.sidebar {
  border-right: 1px solid var(--border);
  display: flex;
  background: var(--surface);
  flex-direction: column;
  flex-shrink: 0;
  width: 340px;
}

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

.sidebar-title {
  display: flex;
  align-items:  center;
  gap: 8px;
  font-size: 16px;
  font-weight: 700;
}

.status-dot {
  background: var(--accent-2);
  box-shadow: 0 0 8px var(--accent-2);
  border-radius: 50%;
  width: 8px;
  height: 8px;
}

.icon-btn {
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text-dim);
  display: flex;
  border-radius: 9px;
  justify-content: center;
  align-items:  center;
  width: 32px;
  height: 32px;
  font-size: 15px;
}

.icon-btn:hover {
  color: var(--text);
  border-color: var(--accent);
}

.search-box {
  margin: 12px 14px;
}

.search-box input {
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text);
  outline: none;
  border-radius: 10px;
  width: 100%;
  padding: 9px 12px;
  font-size: 13.5px;
}

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

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

.chat-item {
  display: flex;
  cursor: pointer;
  border-radius: 12px;
  align-items:  center;
  gap: 12px;
  padding: 10px;
  transition: background .12s;
}

.chat-item:hover {
  background: var(--surface-2);
}

.chat-item.active {
  background: var(--accent-soft);
}

.chat-item-body {
  flex: 1;
  min-width: 0;
}

.chat-item-top {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 8px;
}

.chat-item-name {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-size: 14px;
  font-weight: 600;
}

.chat-item-time {
  color: var(--text-faint);
  flex-shrink: 0;
  font-size: 11px;
}

.chat-item-bottom {
  display: flex;
  justify-content: space-between;
  align-items:  center;
  gap: 8px;
  margin-top: 2px;
}

.chat-item-preview {
  color: var(--text-dim);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-size: 12.5px;
}

.unread-badge {
  background: var(--accent);
  color: #fff;
  display: flex;
  border-radius: 9px;
  flex-shrink: 0;
  justify-content: center;
  align-items:  center;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  font-size: 11px;
  font-weight: 700;
}

.empty-state {
  display: flex;
  color: var(--text-faint);
  flex-direction: column;
  justify-content: center;
  align-items:  center;
  gap: 8px;
  height: 100%;
  font-size: 13.5px;
}

.thread {
  display: flex;
  background: radial-gradient(circle at 50% 0%, #6e5bff0d, transparent 50%), var(--bg);
  flex-direction: column;
  flex: 1;
  min-width: 0;
}

.thread-header {
  border-bottom: 1px solid var(--border);
  display: flex;
  background: var(--surface);
  align-items:  center;
  gap: 12px;
  padding: 14px 20px;
}

.thread-header-name {
  font-size: 14.5px;
  font-weight: 700;
}

.thread-header-sub {
  color: var(--text-dim);
  font-size: 12px;
}

.thread-scroll {
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  flex: 1;
  gap: 3px;
  padding: 20px;
}

.bubble {
  border-radius: var(--radius);
  position: relative;
  word-wrap: break-word;
  max-width: 62%;
  padding: 9px 13px;
  font-size: 14px;
  line-height: 1.45;
}

.bubble.them {
  background: var(--bubble-them);
  border-bottom-left-radius: 4px;
}

.bubble.me {
  background: var(--bubble-me);
  color: #fff;
  border-bottom-right-radius: 4px;
}

.bubble-time {
  opacity: .65;
  text-align: right;
  margin-top: 4px;
  font-size: 10.5px;
}

.bubble-media img, .bubble-media video {
  display: block;
  cursor: pointer;
  border-radius: 12px;
  max-width: 280px;
  max-height: 340px;
}

.bubble-media audio {
  width: 240px;
}

.doc-card {
  display: flex;
  text-decoration: none;
  color: inherit;
  background: #ffffff14;
  border-radius: 12px;
  align-items:  center;
  gap: 10px;
  min-width: 220px;
  padding: 10px 12px;
}

.doc-icon {
  background: var(--accent);
  display: flex;
  border-radius: 9px;
  flex-shrink: 0;
  justify-content: center;
  align-items:  center;
  width: 36px;
  height: 36px;
  font-size: 16px;
}

.doc-info {
  min-width: 0;
}

.doc-name {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-size: 13px;
  font-weight: 600;
}

.doc-sub {
  opacity: .7;
  font-size: 11px;
}

.bubble-row {
  position: relative;
  display: flex;
  align-items:  flex-start;
  gap: 6px;
  margin-bottom: 6px;
}

.bubble-row.me {
  justify-content: flex-end;
}

.bubble-actions {
  display: flex;
  opacity: 0;
  align-self:  center;
  gap: 2px;
  transition: opacity .12s;
}

.bubble-row:hover .bubble-actions {
  opacity: 1;
}

.bubble-action-btn {
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text-dim);
  display: flex;
  border-radius: 8px;
  justify-content: center;
  align-items:  center;
  width: 26px;
  height: 26px;
  font-size: 12px;
}

.bubble-action-btn:hover {
  color: var(--text);
  border-color: var(--accent);
}

.quoted-block {
  border-left: 3px solid var(--accent-2);
  opacity: .85;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  background: #ffffff12;
  border-radius: 8px;
  max-width: 260px;
  margin-bottom: 6px;
  padding: 5px 9px;
  font-size: 12px;
}

.reply-banner {
  display: flex;
  background: var(--surface-2);
  border-top: 1px solid var(--border);
  justify-content: space-between;
  align-items:  center;
  gap: 10px;
  padding: 8px 20px;
  font-size: 12.5px;
}

.reply-banner-text {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--text-dim);
}

.reply-banner-label {
  color: var(--accent-2);
  margin-right: 6px;
  font-weight: 700;
}

.reply-banner-close {
  color: var(--text-dim);
  background: none;
  border: none;
  flex-shrink: 0;
  font-size: 13px;
}

.reply-banner-close:hover {
  color: var(--text);
}

.modal-backdrop {
  position: fixed;
  display: flex;
  z-index: 100;
  background: #000000a0;
  justify-content: center;
  align-items:  center;
  inset: 0;
}

.modal-card {
  background: var(--surface);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-glow);
  display: flex;
  border-radius: 16px;
  flex-direction: column;
  width: 340px;
  max-height: 70vh;
  padding: 16px;
}

.modal-title {
  margin-bottom: 12px;
  font-size: 15px;
  font-weight: 700;
}

.modal-list {
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.modal-list-item {
  display: flex;
  border-radius: 10px;
  align-items:  center;
  gap: 10px;
  padding: 8px;
}

.modal-list-item:hover {
  background: var(--surface-2);
}

.modal-list-item-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 13.5px;
}

.modal-close {
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 10px;
  margin-top: 12px;
  padding: 8px;
  font-size: 13px;
}

.composer {
  border-top: 1px solid var(--border);
  display: flex;
  background: var(--surface);
  align-items:  flex-end;
  gap: 10px;
  padding: 14px 20px;
}

.composer textarea {
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text);
  resize: none;
  outline: none;
  border-radius: 14px;
  flex: 1;
  max-height: 120px;
  padding: 11px 14px;
  font-family: inherit;
  font-size: 14px;
}

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

.composer-send {
  background: var(--bubble-me);
  color: #fff;
  display: flex;
  border: none;
  border-radius: 12px;
  flex-shrink: 0;
  justify-content: center;
  align-items:  center;
  width: 42px;
  height: 42px;
  font-size: 17px;
}

.composer-send:disabled {
  opacity: .4;
}

.avatar {
  display: flex;
  color: #fff;
  background: var(--surface-3);
  overflow: hidden;
  border-radius: 50%;
  flex-shrink: 0;
  justify-content: center;
  align-items:  center;
  width: 44px;
  height: 44px;
  font-size: 15px;
  font-weight: 700;
}

.avatar img {
  object-fit: cover;
  width: 100%;
  height: 100%;
}

.avatar.sm {
  width: 34px;
  height: 34px;
  font-size: 12.5px;
}

.lightbox {
  position: fixed;
  display: flex;
  z-index: 100;
  background: #000000d8;
  justify-content: center;
  align-items:  center;
  padding: 30px;
  inset: 0;
}

.lightbox img, .lightbox video {
  border-radius: 8px;
  max-width: 100%;
  max-height: 100%;
}

.lightbox-close {
  position: absolute;
  color: #fff;
  background: #ffffff1a;
  border: none;
  border-radius: 50%;
  width: 38px;
  height: 38px;
  font-size: 18px;
  top: 20px;
  right: 24px;
}
