/* ============================================================================
   SyncDoc Collaborative Editor - Modern Google Docs / Notion Inspired Styles
   ============================================================================ */

:root {
  --primary: #2563eb;
  --primary-hover: #1d4ed8;
  --bg-app: #f8fafc;
  --bg-surface: #ffffff;
  --bg-hover: #f1f5f9;
  --border: #e2e8f0;
  --border-focus: #3b82f6;
  --text-main: #0f172a;
  --text-muted: #64748b;
  --text-dim: #94a3b8;
  --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
  --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
  --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;
  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
}

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

body {
  font-family: var(--font-sans);
  background-color: var(--bg-app);
  color: var(--text-main);
  height: 100vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

/* App Header */
.app-header {
  height: 64px;
  background-color: var(--bg-surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  z-index: 100;
}

.header-left {
  display: flex;
  align-items: center;
  gap: 16px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 700;
  font-size: 1.15rem;
  color: var(--primary);
  text-decoration: none;
}

.brand svg {
  width: 28px;
  height: 28px;
}

.doc-info {
  display: flex;
  flex-direction: column;
}

.doc-title-input {
  font-size: 1rem;
  font-weight: 600;
  border: 1px solid transparent;
  padding: 2px 6px;
  border-radius: var(--radius-sm);
  outline: none;
  color: var(--text-main);
  background: transparent;
  transition: all 0.15s;
}

.doc-title-input:hover, .doc-title-input:focus {
  background: var(--bg-hover);
  border-color: var(--border);
}

.doc-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.75rem;
  color: var(--text-muted);
}

.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 2px 8px;
  border-radius: 9999px;
  font-size: 0.75rem;
  font-weight: 600;
}

.status-badge.connected {
  background: #ecfdf5;
  color: #059669;
}

.status-badge.connecting {
  background: #fefce8;
  color: #ca8a04;
}

.status-badge.partitioned {
  background: #fef2f2;
  color: #dc2626;
}

.status-badge.disconnected {
  background: #f1f5f9;
  color: var(--text-muted);
}

.status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
}
.status-dot.green { background: #10b981; }
.status-dot.yellow { background: #f59e0b; }
.status-dot.red { background: #ef4444; }
.status-dot.gray { background: #94a3b8; }

.header-right {
  display: flex;
  align-items: center;
  gap: 16px;
}

.collaborators-group {
  display: flex;
  align-items: center;
  gap: 8px;
}

.avatar-stack {
  display: flex;
  align-items: center;
}

.avatar-bubble {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  color: #ffffff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
  font-weight: 700;
  border: 2px solid #ffffff;
  margin-left: -8px;
  box-shadow: var(--shadow-sm);
  transition: transform 0.2s;
  cursor: pointer;
}

.avatar-bubble:first-child {
  margin-left: 0;
}

.avatar-bubble:hover {
  transform: translateY(-2px) scale(1.05);
  z-index: 10;
}

.btn-pill {
  padding: 6px 14px;
  background: var(--bg-hover);
  border: 1px solid var(--border);
  border-radius: 9999px;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-main);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: all 0.15s;
}

.btn-pill:hover {
  background: #e2e8f0;
}

.btn-pill.primary {
  background: var(--primary);
  border-color: var(--primary);
  color: #ffffff;
}

.btn-pill.primary:hover {
  background: var(--primary-hover);
}

/* Toolbar */
.toolbar-container {
  background-color: var(--bg-surface);
  border-bottom: 1px solid var(--border);
  padding: 8px 24px;
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  z-index: 90;
}

.tool-group {
  display: flex;
  align-items: center;
  gap: 2px;
  padding: 0 6px;
  border-right: 1px solid var(--border);
}

.tool-group:last-child {
  border-right: none;
}

.tool-btn {
  background: transparent;
  border: 1px solid transparent;
  width: 32px;
  height: 32px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: var(--text-main);
  font-size: 0.9rem;
  font-weight: 600;
  transition: background 0.15s;
}

.tool-btn:hover {
  background: var(--bg-hover);
}

.tool-btn.active {
  background: #dbeafe;
  color: var(--primary);
  border-color: #bfdbfe;
}

.tool-btn svg {
  width: 18px;
  height: 18px;
}

/* Main Workspace & Split Layout */
.workspace-container {
  display: flex;
  flex: 1;
  overflow: hidden;
  position: relative;
}

.main-workspace {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.main-workspace.half-width {
  flex: 0 0 50%;
  border-right: 2px solid var(--border);
}

.editor-scroll-area {
  flex: 1;
  overflow-y: auto;
  padding: 32px 16px;
  display: flex;
  justify-content: center;
}

/* Google Docs Document Canvas Paper */
.document-paper {
  position: relative;
  background: #ffffff;
  width: 100%;
  max-width: 850px;
  min-height: 900px;
  padding: 64px 72px;
  box-shadow: var(--shadow-md);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  outline: none;
}

.editor-content {
  min-height: 800px;
  outline: none;
  font-size: 1.05rem;
  line-height: 1.7;
  color: #1e293b;
  position: relative;
  word-break: break-word;
}

.editor-content p {
  margin-bottom: 0.75rem;
}

.editor-content h1 {
  font-size: 2rem;
  font-weight: 800;
  margin-top: 1rem;
  margin-bottom: 0.75rem;
  color: #0f172a;
}

.editor-content h2 {
  font-size: 1.5rem;
  font-weight: 700;
  margin-top: 0.75rem;
  margin-bottom: 0.5rem;
  color: #1e293b;
}

.editor-content .inline-code {
  font-family: var(--font-mono);
  background: #f1f5f9;
  padding: 2px 5px;
  border-radius: 4px;
  font-size: 0.9em;
  color: #e11d48;
}

/* Floating Remote Cursors */
.remote-cursors-layer {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

.remote-cursor {
  position: absolute;
  width: 2px;
  pointer-events: none;
  transition: top 0.08s ease-out, left 0.08s ease-out;
  animation: cursorBlink 1.2s infinite;
  z-index: 50;
}

@keyframes cursorBlink {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}

.remote-cursor-tag {
  position: absolute;
  top: -20px;
  left: -2px;
  font-size: 10px;
  font-weight: 700;
  color: #ffffff;
  padding: 1px 6px;
  border-radius: 3px 3px 3px 0;
  white-space: nowrap;
  pointer-events: none;
  box-shadow: var(--shadow-sm);
}

/* Split Sandbox Container (Side-by-side Alice & Bob Hackathon Demo) */
.split-sandbox-container {
  display: none;
  flex: 0 0 50%;
  background: var(--bg-app);
  flex-direction: column;
}

.split-sandbox-container.active {
  display: flex;
}

.split-sandbox-header {
  height: 40px;
  background: #1e293b;
  color: #f8fafc;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  font-size: 0.85rem;
  font-weight: 600;
}

.split-sandbox-frame {
  flex: 1;
  border: none;
  width: 100%;
  height: 100%;
}

/* Bottom Status & Metrics Bar */
.app-footer {
  height: 32px;
  background-color: var(--bg-surface);
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  font-size: 0.75rem;
  color: var(--text-muted);
  z-index: 100;
}

.footer-stats {
  display: flex;
  align-items: center;
  gap: 16px;
}

/* Mentor Diagnostic & Chaos Simulator Panel */
.mentor-panel {
  width: 380px;
  background: #ffffff;
  border-left: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  box-shadow: -2px 0 8px rgba(0, 0, 0, 0.03);
}

.mentor-header {
  padding: 16px;
  border-bottom: 1px solid var(--border);
  background: #f8fafc;
}

.mentor-title {
  font-size: 0.95rem;
  font-weight: 700;
  color: #1e293b;
  display: flex;
  align-items: center;
  gap: 8px;
}

.mentor-tag {
  font-size: 0.65rem;
  font-weight: 700;
  background: #4f46e5;
  color: #ffffff;
  padding: 2px 6px;
  border-radius: 4px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.mentor-section {
  padding: 16px;
  border-bottom: 1px solid var(--border);
}

.section-label {
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 12px;
  display: block;
}

.metrics-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.metric-card {
  background: #f8fafc;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 8px 10px;
}

.metric-name {
  font-size: 0.7rem;
  color: var(--text-muted);
}

.metric-value {
  font-size: 0.95rem;
  font-weight: 700;
  color: #0f172a;
  font-family: var(--font-mono);
  margin-top: 2px;
}

.chaos-controls {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.btn-chaos-offline {
  width: 100%;
  padding: 8px 12px;
  background: #ef4444;
  color: #ffffff;
  border: none;
  border-radius: var(--radius-sm);
  font-weight: 600;
  font-size: 0.85rem;
  cursor: pointer;
  transition: background 0.15s;
}

.btn-chaos-offline:hover {
  background: #dc2626;
}

.btn-chaos-online {
  width: 100%;
  padding: 8px 12px;
  background: #10b981;
  color: #ffffff;
  border: none;
  border-radius: var(--radius-sm);
  font-weight: 600;
  font-size: 0.85rem;
  cursor: pointer;
}

.control-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.8rem;
}

.control-select {
  padding: 4px 8px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  font-size: 0.8rem;
  background: #ffffff;
}

.btn-benchmark {
  width: 100%;
  padding: 9px 14px;
  background: #4f46e5;
  color: #ffffff;
  border: none;
  border-radius: var(--radius-sm);
  font-weight: 600;
  font-size: 0.85rem;
  cursor: pointer;
  transition: background 0.15s;
}

.btn-benchmark:hover {
  background: #4338ca;
}

.benchmark-badge {
  margin-top: 10px;
  padding: 10px;
  border-radius: var(--radius-sm);
  font-size: 0.75rem;
  line-height: 1.4;
}

.benchmark-badge.success {
  background: #ecfdf5;
  border: 1px solid #a7f3d0;
  color: #065f46;
}

.benchmark-badge.failed {
  background: #fef2f2;
  border: 1px solid #fecaca;
  color: #991b1b;
}

.code-box {
  background: #0f172a;
  color: #38bdf8;
  font-family: var(--font-mono);
  font-size: 0.7rem;
  padding: 8px;
  border-radius: var(--radius-sm);
  overflow-x: auto;
  white-space: pre-wrap;
  word-break: break-all;
}

.btn-icon {
  background: none;
  border: none;
  color: inherit;
  font-size: 1.2rem;
  cursor: pointer;
}

/* Print Styles */
@media print {
  .app-header, .toolbar-container, .app-footer, .mentor-panel, .split-sandbox-container {
    display: none !important;
  }
  .document-paper {
    box-shadow: none !important;
    border: none !important;
    padding: 0 !important;
    max-width: 100% !important;
  }
}
