/* =============================================
   CoLab — Collaborative Workspace
   Theme: Dark editorial / terminal-inspired
   Fonts: IBM Plex Mono + IBM Plex Sans
   ============================================= */

/* ── CSS Variables ── */
:root {
  --bg:          #0e0f11;
  --bg-2:        #161719;
  --bg-3:        #1d1e21;
  --bg-hover:    #232529;
  --border:      #2a2c30;
  --border-2:    #353840;
  --text:        #e2e4e9;
  --text-2:      #8b8f9a;
  --text-3:      #555a66;
  --accent:      #4fd1c5;
  --accent-dim:  #2a6b66;
  --accent-glow: rgba(79,209,197,0.15);
  --warn:        #f6ad55;
  --warn-dim:    rgba(246,173,85,0.15);
  --danger:      #fc8181;
  --danger-dim:  rgba(252,129,129,0.1);
  --success:     #68d391;
  --radius:      6px;
  --radius-lg:   10px;
  --mono:        'IBM Plex Mono', monospace;
  --sans:        'IBM Plex Sans', sans-serif;
  --topbar-h:    52px;
  --typing-h:    32px;
  --shadow:      0 4px 24px rgba(0,0,0,0.4);
}

[data-theme="light"] {
  --bg:          #f5f6f8;
  --bg-2:        #ffffff;
  --bg-3:        #eef0f3;
  --bg-hover:    #e8eaee;
  --border:      #d8dbe2;
  --border-2:    #c4c8d1;
  --text:        #1a1c20;
  --text-2:      #5a5f70;
  --text-3:      #9ea3b0;
  --accent:      #0e8c85;
  --accent-dim:  rgba(14,140,133,0.1);
  --accent-glow: rgba(14,140,133,0.12);
  --warn:        #c77c1a;
  --warn-dim:    rgba(199,124,26,0.1);
  --danger:      #c53030;
  --danger-dim:  rgba(197,48,48,0.08);
  --success:     #276749;
  --shadow:      0 4px 24px rgba(0,0,0,0.1);
}

/* ── Reset & Base ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { font-size: 14px; }

body {
  font-family: var(--sans);
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  line-height: 1.6;
  transition: background 0.25s, color 0.25s;
}

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

/* ── TOP BAR ── */
#topbar {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: var(--topbar-h);
  background: var(--bg-2);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  z-index: 100;
  gap: 16px;
}

.topbar-left, .topbar-center, .topbar-right {
  display: flex;
  align-items: center;
  gap: 14px;
}

.topbar-left { flex: 1; }
.topbar-center { flex: 1; justify-content: center; }
.topbar-right { flex: 1; justify-content: flex-end; }

.logo {
  font-family: var(--mono);
  font-size: 15px;
  font-weight: 600;
  color: var(--accent);
  letter-spacing: 0.02em;
  white-space: nowrap;
}

.user-badge {
  display: flex;
  align-items: center;
  gap: 6px;
  background: var(--bg-3);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 3px 10px 3px 8px;
  font-family: var(--mono);
  font-size: 11px;
  color: var(--text-2);
}
.user-dot {
  width: 7px; height: 7px;
  border-radius: 50%;
  background: var(--success);
  box-shadow: 0 0 6px var(--success);
  flex-shrink: 0;
}

.presence-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 12px;
  color: var(--text-2);
  font-family: var(--mono);
}

.avatar-row {
  display: flex;
  gap: -4px;
}
.avatar-chip {
  width: 24px; height: 24px;
  border-radius: 50%;
  border: 2px solid var(--bg-2);
  font-size: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--mono);
  font-weight: 600;
  margin-left: -6px;
  flex-shrink: 0;
}
.avatar-chip:first-child { margin-left: 0; }

.sync-badge {
  display: flex;
  align-items: center;
  gap: 6px;
  font-family: var(--mono);
  font-size: 11px;
  color: var(--text-2);
  transition: color 0.2s;
}
.sync-dot {
  width: 7px; height: 7px;
  border-radius: 50%;
  flex-shrink: 0;
  transition: background 0.2s;
}
.sync-dot.synced { background: var(--success); }
.sync-dot.updating {
  background: var(--warn);
  animation: pulse-dot 0.8s ease-in-out infinite;
}

@keyframes pulse-dot {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.3; }
}

.theme-toggle {
  background: var(--bg-3);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text-2);
  cursor: pointer;
  font-size: 14px;
  padding: 5px 9px;
  line-height: 1;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}
.theme-toggle:hover {
  background: var(--bg-hover);
  color: var(--accent);
  border-color: var(--accent-dim);
}

/* ── TYPING BAR ── */
.typing-bar {
  position: fixed;
  top: var(--topbar-h);
  left: 0; right: 0;
  height: var(--typing-h);
  background: var(--bg-3);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 20px;
  z-index: 99;
  font-size: 11px;
  font-family: var(--mono);
  color: var(--accent);
  opacity: 0;
  transform: translateY(-4px);
  transition: opacity 0.2s, transform 0.2s;
  pointer-events: none;
}
.typing-bar.visible {
  opacity: 1;
  transform: translateY(0);
}
.typing-bar::before {
  content: "● ";
  animation: blink 1s step-end infinite;
}
@keyframes blink { 0%,100%{opacity:1} 50%{opacity:0} }

/* ── APP LAYOUT ── */
.app-layout {
  display: flex;
  margin-top: calc(var(--topbar-h) + var(--typing-h));
  flex: 1;
  min-height: calc(100vh - var(--topbar-h) - var(--typing-h));
  overflow: hidden;
}

/* ── CONTENT AREA ── */
.content-area {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  overflow: hidden;
}

/* ── SECTION TABS ── */
.section-tabs {
  display: flex;
  gap: 2px;
  padding: 12px 20px 0;
  background: var(--bg-2);
  border-bottom: 1px solid var(--border);
}
.tab-btn {
  background: transparent;
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--text-3);
  cursor: pointer;
  font-family: var(--mono);
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.03em;
  padding: 8px 16px 10px;
  display: flex;
  align-items: center;
  gap: 6px;
  transition: color 0.15s, border-color 0.15s;
}
.tab-btn .tab-icon { font-size: 14px; }
.tab-btn:hover { color: var(--text); }
.tab-btn.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
}

/* ── TAB PANELS ── */
.tab-panel {
  display: none;
  flex-direction: column;
  flex: 1;
  padding: 24px 24px 16px;
  overflow-y: auto;
  animation: fadeIn 0.18s ease;
}
.tab-panel.active { display: flex; }

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(4px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ── PANEL HEADER ── */
.panel-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 16px;
}
.panel-header h2 {
  font-family: var(--sans);
  font-size: 18px;
  font-weight: 600;
  color: var(--text);
}
.panel-meta {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--text-3);
}

/* ── SHARED EDITOR ── */
.editor-wrap {
  position: relative;
  flex: 1;
  display: flex;
  flex-direction: column;
}
#sharedEditor {
  flex: 1;
  min-height: 340px;
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  color: var(--text);
  font-family: var(--mono);
  font-size: 13px;
  line-height: 1.75;
  padding: 16px 20px;
  resize: vertical;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}
#sharedEditor:focus {
  border-color: var(--accent-dim);
  box-shadow: 0 0 0 3px var(--accent-glow);
}
#sharedEditor::placeholder { color: var(--text-3); }

/* ── CONFLICT BANNER ── */
.conflict-banner {
  margin-top: 10px;
  background: var(--warn-dim);
  border: 1px solid var(--warn);
  border-radius: var(--radius);
  padding: 10px 14px;
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 12px;
  font-family: var(--mono);
  color: var(--warn);
  animation: slideIn 0.2s ease;
}
.conflict-icon { font-size: 16px; flex-shrink: 0; }
.conflict-banner span:last-of-type { flex: 1; }
.conflict-actions { display: flex; gap: 8px; flex-shrink: 0; }
.btn-overwrite, .btn-merge {
  background: transparent;
  border: 1px solid currentColor;
  border-radius: var(--radius);
  cursor: pointer;
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 500;
  padding: 4px 10px;
  transition: background 0.15s;
}
.btn-overwrite { color: var(--danger); }
.btn-overwrite:hover { background: var(--danger-dim); }
.btn-merge { color: var(--accent); }
.btn-merge:hover { background: var(--accent-glow); }
.hidden { display: none !important; }

/* ── ADD ROW ── */
.add-row {
  display: flex;
  gap: 8px;
  margin-bottom: 16px;
}
.add-row input {
  flex: 1;
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-family: var(--sans);
  font-size: 13px;
  padding: 9px 14px;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.add-row input:focus {
  border-color: var(--accent-dim);
  box-shadow: 0 0 0 3px var(--accent-glow);
}
.add-row input::placeholder { color: var(--text-3); }

.btn-primary {
  background: var(--accent);
  border: none;
  border-radius: var(--radius);
  color: var(--bg);
  cursor: pointer;
  font-family: var(--mono);
  font-size: 12px;
  font-weight: 600;
  padding: 9px 16px;
  transition: opacity 0.15s, transform 0.1s;
  white-space: nowrap;
}
.btn-primary:hover { opacity: 0.85; }
.btn-primary:active { transform: scale(0.97); }

/* ── TODO LIST ── */
.todo-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.todo-item {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px 14px;
  animation: slideIn 0.2s ease;
  transition: border-color 0.15s, background 0.15s;
}
.todo-item:hover { border-color: var(--border-2); }
.todo-item.completed .todo-text {
  text-decoration: line-through;
  color: var(--text-3);
}
.todo-item input[type="checkbox"] {
  appearance: none;
  width: 16px; height: 16px;
  border: 2px solid var(--border-2);
  border-radius: 3px;
  cursor: pointer;
  flex-shrink: 0;
  position: relative;
  transition: background 0.15s, border-color 0.15s;
}
.todo-item input[type="checkbox"]:checked {
  background: var(--accent);
  border-color: var(--accent);
}
.todo-item input[type="checkbox"]:checked::after {
  content: "✓";
  color: var(--bg);
  font-size: 10px;
  font-weight: 700;
  position: absolute;
  top: 50%; left: 50%;
  transform: translate(-50%, -52%);
}
.todo-text {
  flex: 1;
  font-size: 13px;
  color: var(--text);
  line-height: 1.4;
}
.todo-delete {
  background: transparent;
  border: none;
  color: var(--text-3);
  cursor: pointer;
  font-size: 14px;
  line-height: 1;
  padding: 2px 4px;
  border-radius: 3px;
  transition: color 0.15s, background 0.15s;
  flex-shrink: 0;
}
.todo-delete:hover { color: var(--danger); background: var(--danger-dim); }

/* ── NOTES GRID ── */
.notes-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 14px;
}
.note-card {
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  animation: slideIn 0.2s ease;
  transition: border-color 0.15s, box-shadow 0.15s;
  position: relative;
}
.note-card:hover {
  border-color: var(--border-2);
  box-shadow: var(--shadow);
}
.note-title {
  background: transparent;
  border: none;
  border-bottom: 1px solid var(--border);
  color: var(--text);
  font-family: var(--sans);
  font-size: 13px;
  font-weight: 600;
  outline: none;
  padding-bottom: 8px;
  width: 100%;
  transition: border-color 0.15s;
}
.note-title:focus { border-bottom-color: var(--accent); }
.note-title::placeholder { color: var(--text-3); font-weight: 400; }
.note-content {
  background: transparent;
  border: none;
  color: var(--text-2);
  font-family: var(--sans);
  font-size: 12px;
  line-height: 1.6;
  min-height: 80px;
  outline: none;
  resize: none;
  width: 100%;
  transition: color 0.15s;
}
.note-content:focus { color: var(--text); }
.note-content::placeholder { color: var(--text-3); }
.note-footer {
  display: flex;
  justify-content: flex-end;
  gap: 6px;
  margin-top: 4px;
}
.note-save {
  background: var(--accent-glow);
  border: 1px solid var(--accent-dim);
  border-radius: var(--radius);
  color: var(--accent);
  cursor: pointer;
  font-family: var(--mono);
  font-size: 10px;
  font-weight: 600;
  padding: 3px 10px;
  transition: background 0.15s;
}
.note-save:hover { background: var(--accent); color: var(--bg); }
.note-delete {
  background: transparent;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text-3);
  cursor: pointer;
  font-family: var(--mono);
  font-size: 10px;
  padding: 3px 10px;
  transition: all 0.15s;
}
.note-delete:hover { border-color: var(--danger); color: var(--danger); background: var(--danger-dim); }

/* ── SIDE PANEL ── */
.side-panel {
  width: 280px;
  flex-shrink: 0;
  background: var(--bg-2);
  border-left: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.side-section {
  display: flex;
  flex-direction: column;
  border-bottom: 1px solid var(--border);
  max-height: 50%;
  min-height: 120px;
}
.side-section:last-child { border-bottom: none; flex: 1; }
.side-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 600;
  color: var(--text-2);
  letter-spacing: 0.05em;
  text-transform: uppercase;
  border-bottom: 1px solid var(--border);
  background: var(--bg-3);
  flex-shrink: 0;
}
.clear-log-btn {
  background: transparent;
  border: none;
  color: var(--text-3);
  cursor: pointer;
  font-size: 11px;
  padding: 2px 5px;
  border-radius: 3px;
  transition: color 0.15s;
}
.clear-log-btn:hover { color: var(--danger); }

.activity-log {
  list-style: none;
  overflow-y: auto;
  flex: 1;
  padding: 8px 0;
}
.log-item {
  padding: 6px 14px;
  display: flex;
  flex-direction: column;
  gap: 1px;
  animation: slideIn 0.15s ease;
  border-bottom: 1px solid var(--border);
}
.log-item:last-child { border-bottom: none; }
.log-who {
  font-family: var(--mono);
  font-size: 10px;
  font-weight: 600;
  color: var(--accent);
}
.log-what {
  font-size: 11px;
  color: var(--text-2);
}
.log-when {
  font-family: var(--mono);
  font-size: 10px;
  color: var(--text-3);
}
.log-empty {
  padding: 14px;
  font-size: 11px;
  color: var(--text-3);
  font-family: var(--mono);
  text-align: center;
}

.notifications-area {
  overflow-y: auto;
  flex: 1;
  padding: 8px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.notif-item {
  background: var(--bg-3);
  border: 1px solid var(--border);
  border-left: 3px solid var(--accent);
  border-radius: var(--radius);
  padding: 7px 10px;
  font-size: 11px;
  color: var(--text-2);
  animation: slideIn 0.2s ease;
  line-height: 1.4;
}
.notif-item .notif-user { color: var(--accent); font-family: var(--mono); font-weight: 600; }

/* ── TOAST ── */
.toast-container {
  position: fixed;
  bottom: 20px;
  right: 20px;
  display: flex;
  flex-direction: column-reverse;
  gap: 8px;
  z-index: 200;
}
.toast {
  background: var(--bg-2);
  border: 1px solid var(--border-2);
  border-left: 3px solid var(--accent);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  color: var(--text);
  font-size: 12px;
  max-width: 300px;
  padding: 10px 14px;
  animation: toastIn 0.25s ease, toastOut 0.3s ease 2.7s forwards;
  display: flex;
  align-items: flex-start;
  gap: 8px;
}
.toast-icon { font-size: 14px; flex-shrink: 0; margin-top: 1px; }
.toast-msg { line-height: 1.4; }

@keyframes toastIn {
  from { opacity: 0; transform: translateX(20px); }
  to   { opacity: 1; transform: translateX(0); }
}
@keyframes toastOut {
  from { opacity: 1; transform: translateX(0); }
  to   { opacity: 0; transform: translateX(20px); }
}

/* ── HIGHLIGHT ANIMATION ── */
.highlight-change {
  animation: highlightFade 2s ease forwards;
}
@keyframes highlightFade {
  0%   { box-shadow: 0 0 0 2px var(--accent), inset 0 0 0 9999px var(--accent-glow); }
  70%  { box-shadow: 0 0 0 2px var(--accent-dim), inset 0 0 0 9999px var(--accent-glow); }
  100% { box-shadow: none; }
}

/* ── SLIDE IN ── */
@keyframes slideIn {
  from { opacity: 0; transform: translateY(-6px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ── AVATAR COLORS ── */
.av-0 { background: #4fd1c5; color: #0e0f11; }
.av-1 { background: #f6ad55; color: #0e0f11; }
.av-2 { background: #fc8181; color: #0e0f11; }
.av-3 { background: #68d391; color: #0e0f11; }
.av-4 { background: #76e4f7; color: #0e0f11; }
.av-5 { background: #b794f4; color: #0e0f11; }
.av-6 { background: #f687b3; color: #0e0f11; }
.av-7 { background: #faf089; color: #0e0f11; }

/* ── RESPONSIVE ── */
@media (max-width: 820px) {
  .side-panel { display: none; }
  .topbar-center { display: none; }
}
