/* CollabSpace – Modern dark UI, mobile-first */
:root {
  --bg: #0f1117;
  --surface: #1a1d27;
  --surface2: #242836;
  --border: #2e3345;
  --text: #e8eaed;
  --text-muted: #9aa0b4;
  --primary: #6c5ce7;
  --primary-hover: #5a4bd1;
  --accent: #00cec9;
  --danger: #ff6b6b;
  --success: #55efc4;
  --warning: #fdcb6e;
  --radius: 12px;
  --shadow: 0 4px 20px rgba(0,0,0,0.35);
  --font: "Segoe UI", system-ui, -apple-system, sans-serif;
}

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

html, body {
  height: 100%;
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  overflow: hidden;
}

/* Screens */
.screen {
  display: none;
  height: 100%;
  width: 100%;
}
.screen.active { display: flex; flex-direction: column; }

/* ========== JOIN SCREEN ========== */
#join-screen {
  align-items: center;
  justify-content: center;
  background: linear-gradient(145deg, #0f1117 0%, #1a1d27 50%, #0f1117 100%);
  padding: 1rem;
}

.join-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 2rem 1.75rem;
  width: 100%;
  max-width: 400px;
  box-shadow: var(--shadow);
}

.logo { text-align: center; margin-bottom: 1.5rem; }
.logo-icon { font-size: 3rem; display: block; margin-bottom: 0.5rem; }
.logo h1 { font-size: 1.75rem; font-weight: 700; letter-spacing: -0.5px; }
.tagline { color: var(--text-muted); font-size: 0.85rem; margin-top: 0.35rem; }

.tabs {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 1.25rem;
  background: var(--surface2);
  border-radius: 10px;
  padding: 4px;
}
.tab {
  flex: 1;
  padding: 0.6rem;
  border: none;
  background: transparent;
  color: var(--text-muted);
  border-radius: 8px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}
.tab.active {
  background: var(--primary);
  color: white;
}

.form-panel { display: none; }
.form-panel.active { display: block; }

label {
  display: block;
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-bottom: 0.35rem;
  margin-top: 0.9rem;
}
input[type="text"], select {
  width: 100%;
  padding: 0.75rem 1rem;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--bg);
  color: var(--text);
  font-size: 1rem;
  outline: none;
  transition: border 0.2s;
}
input:focus, select:focus { border-color: var(--primary); }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.75rem 1.25rem;
  border: none;
  border-radius: 10px;
  font-weight: 600;
  font-size: 0.95rem;
  cursor: pointer;
  transition: background 0.2s, transform 0.1s;
}
.btn:active { transform: scale(0.97); }
.btn.primary {
  background: var(--primary);
  color: white;
  width: 100%;
  margin-top: 1.25rem;
}
.btn.primary:hover { background: var(--primary-hover); }

.hint {
  text-align: center;
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 1.25rem;
  line-height: 1.4;
}

/* ========== APP HEADER ========== */
.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.6rem 0.85rem;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.header-left, .header-right {
  display: flex;
  align-items: center;
  gap: 0.6rem;
}
.room-info { display: flex; flex-direction: column; }
.room-info strong { font-size: 0.95rem; }
.code {
  font-size: 0.7rem;
  color: var(--accent);
  font-family: monospace;
  letter-spacing: 1px;
}
.badge {
  background: var(--primary);
  color: white;
  padding: 0.25rem 0.6rem;
  border-radius: 20px;
  font-size: 0.75rem;
  font-weight: 600;
}
.icon-btn {
  background: var(--surface2);
  border: none;
  color: var(--text);
  width: 36px;
  height: 36px;
  border-radius: 10px;
  font-size: 1.1rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}
.icon-btn:hover { background: var(--border); }
.icon-btn.danger:hover { background: var(--danger); color: white; }

/* Tab bar */
.tab-bar {
  display: flex;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  overflow-x: auto;
  flex-shrink: 0;
}
.nav-tab {
  flex: 1;
  min-width: 70px;
  padding: 0.7rem 0.4rem;
  border: none;
  background: transparent;
  color: var(--text-muted);
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  transition: all 0.2s;
  white-space: nowrap;
}
.nav-tab.active {
  color: var(--primary);
  border-bottom-color: var(--primary);
}

/* Panels */
.panels {
  flex: 1;
  overflow: hidden;
  position: relative;
}
.panel {
  display: none;
  height: 100%;
  flex-direction: column;
  overflow: hidden;
}
.panel.active { display: flex; }

/* ========== CHAT ========== */
.messages {
  flex: 1;
  overflow-y: auto;
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}
.message {
  max-width: 85%;
  padding: 0.6rem 0.9rem;
  border-radius: 14px;
  background: var(--surface2);
  animation: fadeIn 0.2s ease;
}
.message.mine {
  align-self: flex-end;
  background: var(--primary);
  color: white;
}
.message .meta {
  font-size: 0.7rem;
  opacity: 0.75;
  margin-bottom: 0.2rem;
}
.message .text { word-break: break-word; line-height: 1.4; }
.typing {
  height: 20px;
  padding: 0 1rem;
  font-size: 0.75rem;
  color: var(--text-muted);
  font-style: italic;
}
.composer {
  display: flex;
  gap: 0.5rem;
  padding: 0.75rem;
  background: var(--surface);
  border-top: 1px solid var(--border);
}
.composer input {
  flex: 1;
  border-radius: 20px;
  padding: 0.7rem 1rem;
}
.composer .btn { width: auto; margin: 0; border-radius: 20px; padding: 0.7rem 1.2rem; }

/* ========== FILES ========== */
.panel-toolbar {
  padding: 0.75rem;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.drop-zone {
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
  text-align: center;
  color: var(--text-muted);
  cursor: pointer;
  transition: border-color 0.2s, background 0.2s;
  margin-bottom: 0.6rem;
}
.drop-zone:hover, .drop-zone.dragover {
  border-color: var(--primary);
  background: rgba(108, 92, 231, 0.08);
}
.drop-zone p { font-size: 0.9rem; line-height: 1.4; }
.perm-select {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.85rem;
}
.perm-select select { width: auto; padding: 0.4rem 0.6rem; }

.file-list {
  flex: 1;
  overflow-y: auto;
  padding: 0.75rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}
.file-card {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  background: var(--surface2);
  border-radius: 10px;
  padding: 0.75rem;
  cursor: pointer;
  transition: background 0.15s;
}
.file-card:hover { background: var(--border); }
.file-icon {
  width: 42px;
  height: 42px;
  border-radius: 8px;
  background: var(--bg);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.3rem;
  flex-shrink: 0;
}
.file-info { flex: 1; min-width: 0; }
.file-info .name {
  font-weight: 600;
  font-size: 0.9rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.file-info .meta {
  font-size: 0.7rem;
  color: var(--text-muted);
  margin-top: 0.15rem;
}
.perm-badge {
  font-size: 0.65rem;
  padding: 0.15rem 0.4rem;
  border-radius: 6px;
  background: var(--bg);
  color: var(--text-muted);
}
.perm-badge.write { color: var(--success); }

/* ========== TASKS / KANBAN ========== */
.kanban {
  flex: 1;
  display: flex;
  gap: 0.6rem;
  padding: 0.75rem;
  overflow-x: auto;
}
.column {
  flex: 1;
  min-width: 160px;
  background: var(--surface);
  border-radius: var(--radius);
  display: flex;
  flex-direction: column;
  max-height: 100%;
}
.column h3 {
  padding: 0.7rem;
  font-size: 0.85rem;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
  text-align: center;
}
.task-list {
  flex: 1;
  overflow-y: auto;
  padding: 0.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}
.task-card {
  background: var(--surface2);
  border-radius: 8px;
  padding: 0.65rem;
  font-size: 0.85rem;
  cursor: grab;
  border-left: 3px solid var(--primary);
}
.task-card .task-meta {
  font-size: 0.7rem;
  color: var(--text-muted);
  margin-top: 0.3rem;
}
.task-actions {
  display: flex;
  gap: 0.3rem;
  margin-top: 0.4rem;
}
.task-actions button {
  font-size: 0.7rem;
  padding: 0.2rem 0.4rem;
  border: none;
  border-radius: 4px;
  background: var(--bg);
  color: var(--text);
  cursor: pointer;
}

/* ========== REVIEW BOARD ========== */
.review-gallery {
  flex: 1;
  overflow-y: auto;
  padding: 0.75rem;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 0.75rem;
  align-content: start;
}
.review-card {
  background: var(--surface2);
  border-radius: 10px;
  overflow: hidden;
  cursor: pointer;
  transition: transform 0.15s;
}
.review-card:hover { transform: scale(1.02); }
.review-card .thumb {
  width: 100%;
  aspect-ratio: 1;
  object-fit: cover;
  background: var(--bg);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2rem;
}
.review-card .thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.review-card .info {
  padding: 0.5rem;
  font-size: 0.75rem;
}
.review-card .info .name {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-weight: 600;
}

.review-detail {
  position: absolute;
  inset: 0;
  background: var(--bg);
  z-index: 10;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.review-detail.hidden { display: none; }
#btn-close-review {
  position: absolute;
  top: 0.5rem;
  right: 0.5rem;
  z-index: 20;
}
#review-preview {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #000;
  overflow: auto;
  min-height: 40%;
}
#review-preview img, #review-preview iframe, #review-preview embed {
  max-width: 100%;
  max-height: 100%;
}
#review-preview .fallback {
  color: var(--text-muted);
  text-align: center;
  padding: 2rem;
}
.comments-section {
  background: var(--surface);
  border-top: 1px solid var(--border);
  max-height: 45%;
  display: flex;
  flex-direction: column;
}
.comments-section h3 {
  padding: 0.6rem 0.9rem;
  font-size: 0.9rem;
  border-bottom: 1px solid var(--border);
}
#review-comments {
  flex: 1;
  overflow-y: auto;
  padding: 0.6rem 0.9rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}
.comment {
  background: var(--surface2);
  border-radius: 8px;
  padding: 0.5rem 0.7rem;
  font-size: 0.85rem;
}
.comment .meta { font-size: 0.7rem; color: var(--text-muted); margin-bottom: 0.2rem; }

/* ========== USERS ========== */
#panel-users {
  padding: 1rem;
  overflow-y: auto;
}
.user-list {
  list-style: none;
  margin: 1rem 0;
}
.user-list li {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.6rem 0.8rem;
  background: var(--surface2);
  border-radius: 10px;
  margin-bottom: 0.4rem;
}
.user-list .avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--primary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.9rem;
}
.user-list .role {
  margin-left: auto;
  font-size: 0.7rem;
  color: var(--text-muted);
}

/* Toast */
.toast {
  position: fixed;
  bottom: 1.5rem;
  left: 50%;
  transform: translateX(-50%);
  background: var(--surface2);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 0.7rem 1.3rem;
  border-radius: 30px;
  font-size: 0.9rem;
  z-index: 100;
  box-shadow: var(--shadow);
  transition: opacity 0.3s;
}
.toast.hidden { opacity: 0; pointer-events: none; }

/* Animations */
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Scrollbar */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }

/* Mobile tweaks */
@media (max-width: 600px) {
  .kanban { flex-direction: column; }
  .column { min-width: 100%; max-height: 220px; }
  .message { max-width: 92%; }
  .review-gallery { grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); }
}

/* ========== COLLABSPACE COMMUNITY / SESSION ADDITIONS ========== */
.subtag {
  color: var(--accent);
  font-size: 0.76rem;
  margin-top: 0.35rem;
}
.team-wrap {
  overflow-y: auto;
  padding: 1rem;
  display: grid;
  gap: 1rem;
  max-width: 760px;
  width: 100%;
  margin: 0 auto;
}
.team-block, .session-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem;
}
.team-block h3, .session-card h3 { margin-bottom: 0.7rem; }
.btn.secondary {
  background: var(--surface2);
  color: var(--text);
  border: 1px solid var(--border);
  margin-top: 0.7rem;
}
.btn.secondary:hover { background: var(--border); }
.btn.slim { width: auto; margin-top: 0; }
.btn.small { width: auto; margin: 0; padding: 0.55rem 0.8rem; font-size: 0.8rem; }
.danger-btn { background: var(--danger); color: white; }
.session-head, .session-summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
}
.session-status { color: var(--text-muted); font-size: 0.78rem; }
.session-pill {
  background: rgba(85, 239, 196, 0.12);
  color: var(--success);
  border: 1px solid rgba(85, 239, 196, 0.35);
  border-radius: 999px;
  padding: 0.25rem 0.55rem;
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.08em;
}
.session-actions { margin: 0.8rem 0; }
.check-row {
  display: flex;
  align-items: flex-start;
  gap: 0.6rem;
  color: var(--text);
  margin-top: 0.9rem;
  cursor: pointer;
}
.check-row input { margin-top: 0.2rem; }
.privacy-note {
  color: var(--text-muted);
  font-size: 0.72rem;
  line-height: 1.45;
  margin-top: 0.55rem;
}
.hint.compact { margin-top: 0.6rem; text-align: left; }
.meeting-place {
  margin-top: 0.8rem;
  padding: 0.7rem;
  border-radius: 9px;
  background: rgba(0, 206, 201, 0.08);
  border: 1px solid rgba(0, 206, 201, 0.25);
  font-size: 0.82rem;
}
.meeting-place a { color: var(--accent); }
.meetup-options { display: grid; gap: 0.55rem; margin-top: 0.75rem; }
.meetup-choice {
  text-align: left;
  border: 1px solid var(--border);
  background: var(--surface2);
  color: var(--text);
  padding: 0.75rem;
  border-radius: 10px;
  cursor: pointer;
}
.meetup-choice:hover { border-color: var(--accent); }
.meetup-choice strong { display: block; margin-bottom: 0.2rem; }
.meetup-choice span { display: block; color: var(--text-muted); font-size: 0.72rem; }
.hidden { display: none !important; }
