/* ── Reset ───────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; font-family: 'Segoe UI', system-ui, -apple-system, sans-serif; background: #111b21; color: #e9edef; font-size: 14px; overflow: hidden; }

:root {
  --green:      #25D366;
  --dark-green: #075E54;
  --mid-green:  #128C7E;
  --panel-bg:   #111b21;
  --sidebar-bg: #202c33;
  --header-bg:  #202c33;
  --input-bg:   #2a3942;
  --msg-right:  #005c4b;
  --msg-left:   #202c33;
  --msg-text:   #e9edef;
  --time-color: #8696a0;
  --divider-bg: #182229;
  --border:     #2a3942;
  --hover:      #2a3942;
  --sb-w:       300px;
  --hdr-h:      60px;
}

/* ── Upload Screen ───────────────────────────────────── */
#upload-screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: linear-gradient(145deg, #0a1628 0%, #075E54 60%, #128C7E 100%);
  overflow: auto;
}

.upload-card {
  background: #1f2c34;
  border-radius: 20px;
  padding: 40px 36px;
  max-width: 520px;
  width: 100%;
  text-align: center;
  box-shadow: 0 24px 80px rgba(0,0,0,0.5);
  border: 1px solid #2a3942;
}

.logo-wrap { margin-bottom: 18px; }

.upload-card h1 {
  font-size: 24px;
  font-weight: 700;
  color: #e9edef;
  margin-bottom: 10px;
}

.subtitle {
  font-size: 13px;
  color: #8696a0;
  line-height: 1.7;
  margin-bottom: 28px;
}

/* Drop zone */
.drop-zone {
  border: 2px dashed #2a3942;
  border-radius: 16px;
  padding: 36px 20px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  transition: all 0.2s;
  margin-bottom: 28px;
  background: #111b21;
}

.drop-zone:hover,
.drop-zone.drag-over {
  border-color: var(--green);
  background: #0d2318;
}

.drop-icon { margin-bottom: 4px; }
.drop-title { font-size: 15px; color: #e9edef; font-weight: 500; }
.drop-sub { font-size: 12px; color: #8696a0; }
.drop-or { font-size: 12px; color: #8696a0; margin: 2px 0; }

.btn-browse {
  display: inline-block;
  background: var(--green);
  color: #111;
  padding: 11px 30px;
  border-radius: 50px;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.2s, transform 0.1s;
  margin-top: 4px;
}
.btn-browse:hover { background: var(--mid-green); color: white; }
.btn-browse:active { transform: scale(0.97); }
#folder-input { display: none; }

/* Steps */
.info-steps {
  text-align: left;
  background: #111b21;
  border-radius: 14px;
  padding: 18px 20px;
  border: 1px solid #2a3942;
}
.steps-title {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: #8696a0;
  margin-bottom: 14px;
}
.steps { display: flex; flex-direction: column; gap: 10px; }
.step { display: flex; align-items: flex-start; gap: 12px; font-size: 13px; color: #aebac1; line-height: 1.5; }
.step strong { color: #e9edef; }
.step-num {
  background: var(--green);
  color: #111;
  width: 22px; height: 22px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 11px; font-weight: 700;
  flex-shrink: 0;
}

/* ── Chat Screen ─────────────────────────────────────── */
#chat-screen {
  display: flex;
  height: 100vh;
  overflow: hidden;
}
#chat-screen.hidden,
#upload-screen.hidden { display: none !important; }
.hidden { display: none !important; }

/* ── Sidebar ─────────────────────────────────────────── */
#sidebar {
  width: var(--sb-w);
  min-width: var(--sb-w);
  background: var(--sidebar-bg);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  z-index: 20;
  transition: transform 0.25s ease;
}

.sb-header {
  background: var(--dark-green);
  padding: 16px;
  display: flex;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
}
.sb-avatar {
  width: 42px; height: 42px; border-radius: 50%;
  background: var(--mid-green);
  display: flex; align-items: center; justify-content: center;
  font-size: 18px; font-weight: 700; color: white;
  flex-shrink: 0;
}
.sb-name { font-size: 14px; font-weight: 600; color: #e9edef; }
.sb-count { font-size: 11px; color: #8696a0; margin-top: 2px; }

.sb-section {
  padding: 14px 14px 10px;
  border-bottom: 1px solid var(--border);
}
.sb-label {
  font-size: 10px; font-weight: 700; text-transform: uppercase;
  letter-spacing: 0.6px; color: #8696a0; margin-bottom: 7px;
}
.sb-section input,
.sb-section select {
  width: 100%; padding: 8px 10px;
  background: var(--input-bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: #e9edef;
  font-size: 13px;
  font-family: inherit;
  outline: none;
}
.sb-section input:focus,
.sb-section select:focus { border-color: var(--green); }
.sb-section select option { background: #1f2c34; }

.sb-stats {
  padding: 14px;
  flex: 1;
  font-size: 12px;
  color: #8696a0;
}
.stat-row { display: flex; justify-content: space-between; margin-bottom: 4px; }
.stat-val { font-weight: 600; color: #e9edef; }
.stat-hr { border: none; border-top: 1px solid var(--border); margin: 8px 0; }
.stat-sender {
  display: flex; align-items: center; gap: 7px;
  margin: 5px 0; font-size: 12px;
}
.stat-dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
.stat-sender-name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: #aebac1; }
.stat-sender-count { font-weight: 600; color: #e9edef; }
.stat-pct { color: #8696a0; margin-left: 4px; }

#back-btn {
  margin: 14px;
  padding: 10px;
  background: none;
  border: 1px solid var(--border);
  border-radius: 8px;
  color: #8696a0;
  font-size: 13px;
  font-family: inherit;
  cursor: pointer;
  transition: all 0.2s;
  text-align: center;
}
#back-btn:hover { border-color: var(--green); color: var(--green); }

/* ── Chat Main ───────────────────────────────────────── */
#chat-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: #0b141a;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='80' height='80'%3E%3Ctext y='60' font-size='60' opacity='0.02' fill='white'%3E💬%3C/text%3E%3C/svg%3E");
}

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

#menu-toggle {
  display: none;
  background: none;
  border: none;
  color: #aebac1;
  font-size: 20px;
  cursor: pointer;
  padding: 4px 8px;
}

.h-avatar {
  width: 40px; height: 40px; border-radius: 50%;
  background: var(--mid-green);
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 16px; color: white;
  flex-shrink: 0;
}
.h-name { font-size: 15px; font-weight: 600; color: #e9edef; }
.h-sub { font-size: 12px; color: #8696a0; }

/* ── Messages ────────────────────────────────────────── */
#messages {
  flex: 1;
  overflow-y: auto;
  padding: 12px 16px 20px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  scroll-behavior: smooth;
}

#filter-bar {
  padding: 7px 16px;
  background: #1f2c34;
  border-top: 1px solid var(--border);
  font-size: 12px;
  color: #8696a0;
  text-align: center;
  flex-shrink: 0;
}

/* Date divider */
.date-div {
  text-align: center;
  margin: 14px 0 8px;
}
.date-div span {
  background: #182229;
  color: #8696a0;
  font-size: 11.5px;
  padding: 4px 14px;
  border-radius: 8px;
  border: 1px solid #2a3942;
}

/* System message */
.sys-msg { text-align: center; margin: 6px 0; }
.sys-msg span {
  display: inline-block;
  background: #182229;
  color: #8696a0;
  font-size: 11.5px;
  padding: 4px 14px;
  border-radius: 8px;
  max-width: 80%;
  border: 1px solid #2a3942;
}

/* Message row */
.msg-row {
  display: flex;
  align-items: flex-end;
  gap: 6px;
  max-width: 70%;
  margin-bottom: 2px;
}
.msg-row.right { align-self: flex-end; flex-direction: row-reverse; }
.msg-row.left  { align-self: flex-start; }

.msg-av {
  width: 28px; height: 28px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 11px; font-weight: 700; color: white;
  flex-shrink: 0;
  margin-bottom: 2px;
}
.msg-row.right .msg-av { display: none; }

/* Bubble */
.bubble {
  padding: 6px 10px 4px;
  border-radius: 8px;
  max-width: 100%;
  position: relative;
  word-break: break-word;
  box-shadow: 0 1px 2px rgba(0,0,0,0.3);
}
.msg-row.right .bubble {
  background: var(--msg-right);
  border-radius: 8px 2px 8px 8px;
}
.msg-row.left .bubble {
  background: var(--msg-left);
  border-radius: 2px 8px 8px 8px;
}

.bub-sender {
  font-size: 12px; font-weight: 700;
  margin-bottom: 3px; display: block;
}

.bub-text {
  font-size: 13.5px;
  color: var(--msg-text);
  white-space: pre-wrap;
  line-height: 1.5;
}

.bub-time {
  font-size: 10px;
  color: var(--time-color);
  text-align: right;
  margin-top: 3px;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 3px;
}

/* Highlight search */
mark.hl {
  background: #f3c40060;
  color: #ffe57a;
  border-radius: 2px;
  padding: 0 1px;
}

/* Links */
.bub-text a { color: #53bdeb; word-break: break-all; }

/* ── Media Attachments ───────────────────────────────── */

/* Image */
.media-img {
  max-width: 280px;
  max-height: 220px;
  border-radius: 8px;
  display: block;
  cursor: zoom-in;
  object-fit: cover;
  transition: opacity 0.2s;
  margin-bottom: 2px;
}
.media-img:hover { opacity: 0.88; }

/* Video */
.media-video {
  max-width: 280px;
  max-height: 200px;
  border-radius: 8px;
  display: block;
  margin-bottom: 2px;
  cursor: pointer;
}

/* Audio */
.media-audio-wrap {
  display: flex;
  align-items: center;
  gap: 10px;
  background: #2a3942;
  border-radius: 24px;
  padding: 8px 14px;
  min-width: 220px;
  margin-bottom: 2px;
}
.audio-icon {
  width: 36px; height: 36px;
  background: var(--green);
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0; cursor: pointer;
  font-size: 14px;
}
.audio-player { flex: 1; height: 28px; accent-color: var(--green); min-width: 120px; }

/* Document */
.media-doc {
  display: flex;
  align-items: center;
  gap: 12px;
  background: #2a3942;
  border-radius: 10px;
  padding: 10px 14px;
  min-width: 200px;
  cursor: pointer;
  text-decoration: none;
  color: inherit;
  margin-bottom: 2px;
  transition: background 0.15s;
}
.media-doc:hover { background: #3a4a54; }
.doc-icon {
  width: 40px; height: 40px;
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  font-size: 20px;
  flex-shrink: 0;
}
.doc-info { flex: 1; overflow: hidden; }
.doc-name {
  font-size: 13px; font-weight: 600; color: #e9edef;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.doc-size { font-size: 11px; color: #8696a0; margin-top: 2px; }

/* Not-found placeholder */
.media-missing {
  display: flex; align-items: center; gap: 8px;
  background: #2a3942;
  border-radius: 8px;
  padding: 8px 12px;
  font-size: 12px;
  color: #8696a0;
  font-style: italic;
  margin-bottom: 2px;
}

/* ── Lightbox ────────────────────────────────────────── */
#lightbox {
  position: fixed; inset: 0; z-index: 1000;
  display: flex; align-items: center; justify-content: center;
}
#lb-backdrop {
  position: absolute; inset: 0;
  background: rgba(0,0,0,0.92);
  backdrop-filter: blur(6px);
}
#lb-box {
  position: relative; z-index: 1001;
  max-width: 92vw; max-height: 92vh;
  display: flex; flex-direction: column; align-items: center; gap: 10px;
}
#lb-close {
  align-self: flex-end;
  background: rgba(255,255,255,0.12);
  border: none; border-radius: 50%;
  width: 36px; height: 36px;
  color: white; font-size: 16px; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: background 0.2s;
}
#lb-close:hover { background: rgba(255,255,255,0.25); }
#lb-content img, #lb-content video {
  max-width: 88vw; max-height: 80vh;
  border-radius: 10px;
  display: block;
  object-fit: contain;
}
#lb-caption { font-size: 12px; color: #8696a0; }

/* ── Scrollbar ───────────────────────────────────────── */
#messages::-webkit-scrollbar { width: 5px; }
#messages::-webkit-scrollbar-thumb { background: #2a3942; border-radius: 10px; }
#messages::-webkit-scrollbar-track { background: transparent; }
#sidebar::-webkit-scrollbar { width: 4px; }
#sidebar::-webkit-scrollbar-thumb { background: #2a3942; border-radius: 10px; }

/* ── Responsive ──────────────────────────────────────── */
@media (max-width: 660px) {
  #sidebar {
    position: fixed; top: 0; left: 0; height: 100%;
    transform: translateX(-110%);
    box-shadow: 6px 0 20px rgba(0,0,0,0.5);
  }
  #sidebar.open { transform: translateX(0); }
  #menu-toggle { display: flex; }
  .msg-row { max-width: 88%; }
}
