/* ==========================================================================
   SyncFlow — Premium Light / White Theme Design System
   ========================================================================== */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&family=Outfit:wght@500;600;700;800&display=swap');

:root {
  /* Base Palette */
  --bg-page:       #f0f2f8;
  --bg-card:       #ffffff;
  --bg-card-alt:   #f8f9fc;
  --bg-input:      #f4f5f8;

  /* Borders */
  --border:        #e4e7ef;
  --border-focus:  #6366f1;

  /* Brand Gradient */
  --primary:       #6366f1;
  --primary-dark:  #4f46e5;
  --primary-glow:  rgba(99, 102, 241, 0.18);
  --gradient:      linear-gradient(135deg, #6366f1 0%, #8b5cf6 60%, #a78bfa 100%);
  --gradient-text: linear-gradient(135deg, #6366f1, #8b5cf6);

  /* Accent */
  --accent-cyan:   #0ea5e9;
  --accent-green:  #10b981;
  --accent-red:    #ef4444;
  --accent-amber:  #f59e0b;

  /* Typography */
  --text-main:     #1e2130;
  --text-sub:      #4b5563;
  --text-muted:    #9ca3af;
  --text-dim:      #c4cad8;

  /* Fonts */
  --font-body:     'Inter', system-ui, sans-serif;
  --font-heading:  'Outfit', system-ui, sans-serif;

  /* Radii */
  --r-sm:   8px;
  --r-md:   14px;
  --r-lg:   20px;
  --r-xl:   28px;

  /* Shadows */
  --shadow-sm:  0 1px 3px rgba(0,0,0,.06), 0 1px 2px rgba(0,0,0,.04);
  --shadow-md:  0 4px 16px rgba(0,0,0,.08), 0 2px 6px rgba(0,0,0,.05);
  --shadow-lg:  0 12px 40px rgba(0,0,0,.10), 0 4px 12px rgba(0,0,0,.06);
  --shadow-xl:  0 24px 60px rgba(0,0,0,.12);

  --t-fast:   0.18s cubic-bezier(.4,0,.2,1);
  --t-normal: 0.28s cubic-bezier(.4,0,.2,1);
}

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

body {
  background: var(--bg-page);
  color: var(--text-main);
  font-family: var(--font-body);
  min-height: 100vh;
  display: flex;
  justify-content: center;
  align-items: flex-start;
  padding: 32px 16px 48px;
  line-height: 1.5;
  /* Subtle dot grid background */
  background-image: radial-gradient(circle, #c7cde6 1px, transparent 1px);
  background-size: 28px 28px;
}

/* ── App Container ──────────────────────────────────────────────────────── */
.app-container {
  width: 100%;
  max-width: 960px;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

/* Ambient elements (hidden in light mode) */
.ambient-glow { display: none; }

/* ── Header ─────────────────────────────────────────────────────────────── */
.app-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 14px;
  padding: 14px 22px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--r-xl);
  box-shadow: var(--shadow-md);
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.logo-icon {
  width: 42px;
  height: 42px;
  background: var(--gradient);
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  color: #fff;
  box-shadow: 0 4px 14px var(--primary-glow);
  flex-shrink: 0;
}

.brand-text h1 {
  font-family: var(--font-heading);
  font-size: 20px;
  font-weight: 800;
  letter-spacing: -.5px;
  background: var(--gradient-text);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.brand-text .tag {
  display: block;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  letter-spacing: .4px;
  margin-top: 1px;
}

/* ── Room Pill ───────────────────────────────────────────────────────────── */
.room-pill {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--bg-card-alt);
  border: 1.5px solid var(--border);
  padding: 6px 14px;
  border-radius: 40px;
  box-shadow: var(--shadow-sm);
  flex-shrink: 0;
}

.live-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent-green);
  box-shadow: 0 0 8px rgba(16,185,129,.5);
  animation: dot-pulse 2.2s infinite;
  flex-shrink: 0;
}

@keyframes dot-pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50%       { opacity: .4; transform: scale(.8); }
}

.room-pill .label {
  font-size: 12px;
  color: var(--text-muted);
  font-weight: 500;
}

.room-pill .room-id {
  font-family: var(--font-heading);
  font-weight: 700;
  font-size: 14px;
  color: var(--primary);
  letter-spacing: 1.2px;
}

.btn-icon {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  border: none;
  background: transparent;
  color: var(--text-muted);
  font-size: 15px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: var(--t-fast);
  flex-shrink: 0;
}

.btn-icon:hover {
  background: var(--bg-page);
  color: var(--primary);
}

.btn-icon.danger:hover {
  background: rgba(239,68,68,.08);
  color: var(--accent-red);
}

/* ── Pinned Rooms Nav ────────────────────────────────────────────────────── */
.pinned-dropdown-wrap { position: relative; }

.btn-pinned-nav {
  display: flex;
  align-items: center;
  gap: 6px;
  background: var(--bg-card-alt);
  border: 1.5px solid var(--border);
  color: var(--text-sub);
  font-family: var(--font-heading);
  font-size: 13px;
  font-weight: 600;
  padding: 7px 14px;
  border-radius: 40px;
  cursor: pointer;
  transition: var(--t-fast);
  box-shadow: var(--shadow-sm);
}

.btn-pinned-nav:hover {
  border-color: var(--accent-amber);
  color: var(--accent-amber);
  background: #fffbeb;
}

#pinned-arrow { transition: transform var(--t-fast); }
#pinned-arrow.open { transform: rotate(180deg); }

.pinned-dropdown {
  display: none;
  position: absolute;
  top: calc(100% + 10px);
  left: 0;
  min-width: 250px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-xl);
  z-index: 100;
  overflow: hidden;
}

.pinned-dropdown.show {
  display: block;
  animation: dropdown-in .2s ease forwards;
}

@keyframes dropdown-in {
  from { opacity: 0; transform: translateY(-8px); }
  to   { opacity: 1; transform: translateY(0); }
}

.pinned-dropdown-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  font-size: 12px;
  color: var(--text-muted);
  font-weight: 600;
}

.btn-create-pinned {
  background: #fef3c7;
  border: 1px solid #fde68a;
  color: #92400e;
  font-size: 12px;
  font-weight: 700;
  padding: 4px 10px;
  border-radius: 20px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 4px;
  transition: var(--t-fast);
}

.btn-create-pinned:hover {
  background: #fde68a;
}

#pinned-rooms-list {
  list-style: none;
  padding: 6px 0;
  margin: 0;
  max-height: 220px;
  overflow-y: auto;
}

#pinned-rooms-list li.pinned-empty {
  padding: 16px;
  font-size: 13px;
  color: var(--text-muted);
  text-align: center;
}

#pinned-rooms-list li.pinned-room-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 14px;
  cursor: pointer;
  font-size: 13px;
  color: var(--text-main);
  transition: background var(--t-fast);
}

#pinned-rooms-list li.pinned-room-item:hover { background: #fffbeb; }
#pinned-rooms-list li.pinned-room-item .item-icon { color: var(--accent-amber); font-size: 15px; }
#pinned-rooms-list li.pinned-room-item .item-id  { font-weight: 600; flex-grow: 1; }
#pinned-rooms-list li.pinned-room-item .item-meta { font-size: 11px; color: var(--text-muted); }

/* ── Info Bar ────────────────────────────────────────────────────────────── */
.info-bar {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 6px 20px;
  padding: 8px 16px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  box-shadow: var(--shadow-sm);
  font-size: 12px;
  color: var(--text-muted);
}

.info-item {
  display: flex;
  align-items: center;
  gap: 5px;
}

.info-item.highlight { color: var(--primary); font-weight: 600; }

/* ── Workspace Card ──────────────────────────────────────────────────────── */
.workspace-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--r-xl);
  padding: 28px;
  box-shadow: var(--shadow-lg);
  display: flex;
  flex-direction: column;
  gap: 22px;
}

/* ── Tab Nav ─────────────────────────────────────────────────────────────── */
.tab-nav {
  display: flex;
  gap: 6px;
  border-bottom: 1.5px solid var(--border);
  padding-bottom: 18px;
}

.tab-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  font-family: var(--font-heading);
  font-size: 14px;
  font-weight: 600;
  color: var(--text-muted);
  background: transparent;
  border: 1.5px solid transparent;
  padding: 9px 18px;
  border-radius: var(--r-md);
  cursor: pointer;
  transition: var(--t-normal);
  position: relative;
}

.tab-btn:hover {
  color: var(--text-main);
  background: var(--bg-page);
}

.tab-btn.active {
  color: var(--primary);
  background: var(--primary-glow);
  border-color: rgba(99,102,241,.25);
}

.count-badge {
  background: var(--bg-page);
  color: var(--text-muted);
  font-size: 11px;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 12px;
  border: 1px solid var(--border);
}

.tab-btn.active .count-badge {
  background: rgba(99,102,241,.12);
  color: var(--primary);
  border-color: rgba(99,102,241,.25);
}

.pulse-badge {
  width: 7px;
  height: 7px;
  background: var(--accent-cyan);
  border-radius: 50%;
  box-shadow: 0 0 6px var(--accent-cyan);
}

/* ── Tab Content ─────────────────────────────────────────────────────────── */
.tab-content { display: none; flex-direction: column; gap: 14px; }
.tab-content.active { display: flex; }

/* ── Editor Section ──────────────────────────────────────────────────────── */
.editor-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 12px;
  color: var(--text-muted);
  min-height: 22px;
}

.typing-indicator {
  display: flex;
  align-items: center;
  gap: 7px;
  color: var(--accent-cyan);
  font-weight: 600;
  opacity: 0;
  transition: var(--t-fast);
}

.typing-indicator.show { opacity: 1; }

.typing-dots span {
  display: inline-block;
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--accent-cyan);
  animation: typing-wave 1.4s infinite ease-in-out both;
}

.typing-dots span:nth-child(1) { animation-delay: 0s; }
.typing-dots span:nth-child(2) { animation-delay: .2s; }
.typing-dots span:nth-child(3) { animation-delay: .4s; }

@keyframes typing-wave {
  0%, 80%, 100% { transform: scale(0); }
  40%           { transform: scale(1); }
}

.editor-wrapper { position: relative; }

textarea#sync-textarea {
  width: 100%;
  height: 280px;
  background: var(--bg-input);
  border: 1.5px solid var(--border);
  border-radius: var(--r-md);
  padding: 16px;
  color: var(--text-main);
  font-family: var(--font-body);
  font-size: 14px;
  line-height: 1.7;
  resize: vertical;
  outline: none;
  transition: var(--t-normal);
}

textarea#sync-textarea::placeholder { color: var(--text-dim); }

textarea#sync-textarea:focus {
  border-color: var(--border-focus);
  background: #fff;
  box-shadow: 0 0 0 4px var(--primary-glow);
}

/* ── Action Buttons ──────────────────────────────────────────────────────── */
.editor-actions {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
}

.left-actions, .right-actions { display: flex; gap: 8px; }

.btn {
  padding: 9px 16px;
  border-radius: var(--r-sm);
  font-family: var(--font-heading);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  border: 1.5px solid transparent;
  transition: var(--t-normal);
}

.btn-primary {
  background: var(--gradient);
  color: #fff;
  box-shadow: 0 3px 12px var(--primary-glow);
}

.btn-primary:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 18px var(--primary-glow);
}

.btn-secondary {
  background: var(--bg-card-alt);
  color: var(--text-sub);
  border-color: var(--border);
}

.btn-secondary:hover {
  background: var(--bg-page);
  border-color: var(--primary);
  color: var(--primary);
}

.btn-ghost {
  background: transparent;
  color: var(--text-muted);
  border-color: transparent;
}

.btn-ghost.danger:hover {
  color: var(--accent-red);
  background: rgba(239,68,68,.07);
  border-color: rgba(239,68,68,.2);
}

/* ── Dropzone ────────────────────────────────────────────────────────────── */
.dropzone {
  border: 2px dashed var(--border);
  border-radius: var(--r-lg);
  padding: 40px 20px;
  text-align: center;
  background: var(--bg-card-alt);
  cursor: pointer;
  transition: var(--t-normal);
}

.dropzone:hover,
.dropzone.dragover {
  border-color: var(--primary);
  background: var(--primary-glow);
}

.upload-icon-circle {
  width: 56px;
  height: 56px;
  background: rgba(99,102,241,.1);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 14px;
  font-size: 26px;
  color: var(--primary);
}

.dropzone h3 {
  font-family: var(--font-heading);
  font-size: 15px;
  font-weight: 700;
  color: var(--text-main);
  margin-bottom: 6px;
}

.dropzone .browse-link {
  color: var(--primary);
  text-decoration: underline;
  text-underline-offset: 2px;
}

.dropzone-tip {
  font-size: 12px;
  color: var(--text-muted);
}

/* ── Progress Bar ────────────────────────────────────────────────────────── */
.progress-bar-container {
  background: var(--bg-card-alt);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  padding: 12px 16px;
}

.progress-info {
  display: flex;
  justify-content: space-between;
  font-size: 12px;
  margin-bottom: 7px;
  color: var(--text-muted);
}

.progress-track {
  height: 6px;
  background: var(--bg-page);
  border-radius: 3px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  width: 0%;
  background: var(--gradient);
  border-radius: 3px;
  transition: width .1s linear;
}

/* ── Files List ──────────────────────────────────────────────────────────── */
.files-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-top: 4px;
}

.files-header h4 {
  font-family: var(--font-heading);
  font-size: 14px;
  font-weight: 700;
  color: var(--text-main);
  display: flex;
  align-items: center;
  gap: 6px;
}

.files-header .sub-tip {
  font-size: 12px;
  color: var(--text-muted);
}

.files-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 12px;
}

.empty-files {
  grid-column: 1 / -1;
  text-align: center;
  padding: 48px 0;
  color: var(--text-dim);
}

.empty-files i {
  font-size: 40px;
  display: block;
  margin-bottom: 10px;
  color: var(--border);
}

.empty-files p { font-size: 13px; color: var(--text-muted); }

/* File Card */
.file-card {
  background: var(--bg-card-alt);
  border: 1.5px solid var(--border);
  border-radius: var(--r-md);
  padding: 14px;
  display: flex;
  align-items: center;
  gap: 12px;
  transition: var(--t-fast);
}

.file-card:hover {
  border-color: var(--primary);
  box-shadow: 0 4px 14px var(--primary-glow);
  background: #fff;
}

.file-icon {
  width: 40px;
  height: 40px;
  background: rgba(99,102,241,.08);
  border-radius: var(--r-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  color: var(--primary);
  flex-shrink: 0;
}

.file-details { flex-grow: 1; overflow: hidden; }

.file-name {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-main);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.file-size {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 2px;
}

.file-actions { display: flex; gap: 2px; }

/* ── Footer ──────────────────────────────────────────────────────────────── */
.app-footer {
  text-align: center;
  font-size: 12px;
  color: var(--text-muted);
  padding: 8px 0;
}

/* ── Modal ───────────────────────────────────────────────────────────────── */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15,20,40,.3);
  backdrop-filter: blur(6px);
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  animation: fade-in .2s ease;
}

@keyframes fade-in {
  from { opacity: 0; }
  to   { opacity: 1; }
}

.modal-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--r-xl);
  width: 100%;
  max-width: 400px;
  padding: 26px;
  box-shadow: var(--shadow-xl);
  animation: modal-up .25s cubic-bezier(.175,.885,.32,1.275);
}

@keyframes modal-up {
  from { opacity: 0; transform: translateY(20px) scale(.97); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
}

.modal-header h3 {
  font-family: var(--font-heading);
  font-size: 17px;
  font-weight: 700;
  color: var(--text-main);
}

.btn-close {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--bg-card-alt);
  color: var(--text-muted);
  font-size: 18px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--t-fast);
}

.btn-close:hover {
  background: var(--bg-page);
  color: var(--accent-red);
  border-color: rgba(239,68,68,.3);
}

/* QR Code Modal */
.qrcode-wrapper {
  background: linear-gradient(135deg, #f0f2ff, #e8f4ff);
  border: 1px solid var(--border);
  padding: 16px;
  border-radius: var(--r-md);
  display: flex;
  justify-content: center;
  margin-bottom: 14px;
}

#qrcode-box img, #qrcode-box canvas {
  display: block;
  width: 180px !important;
  height: 180px !important;
  border-radius: 8px;
}

.share-hint {
  font-size: 12px;
  color: var(--text-muted);
  text-align: center;
  margin-bottom: 14px;
  line-height: 1.6;
}

.share-input-group { display: flex; gap: 8px; }

.share-input-group input {
  flex-grow: 1;
  background: var(--bg-input);
  border: 1.5px solid var(--border);
  border-radius: var(--r-sm);
  padding: 8px 12px;
  color: var(--text-main);
  font-size: 12px;
  outline: none;
}

/* ── Toast ───────────────────────────────────────────────────────────────── */
.toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 1000;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.toast {
  background: var(--bg-card);
  border: 1.5px solid var(--border);
  color: var(--text-main);
  padding: 12px 18px;
  border-radius: var(--r-md);
  font-size: 13px;
  display: flex;
  align-items: center;
  gap: 10px;
  box-shadow: var(--shadow-lg);
  animation: toast-in .3s cubic-bezier(.175,.885,.32,1.275) forwards;
  transition: opacity .3s ease, transform .3s ease;
  max-width: 340px;
}

@keyframes toast-in {
  from { opacity: 0; transform: translateY(16px) scale(.93); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

/* ── Pinned Room (Light Theme) ───────────────────────────────────────────── */

.pinned-badge {
  color: var(--accent-amber);
  font-size: 14px;
  display: inline-flex;
  align-items: center;
  animation: pin-glow 2.5s infinite;
}

@keyframes pin-glow {
  0%, 100% { opacity: 1; }
  50%       { opacity: .4; }
}

.room-pill.is-pinned {
  border-color: rgba(245,158,11,.5);
  box-shadow: 0 0 0 3px rgba(245,158,11,.1);
}

.btn-icon.pin-active { color: var(--accent-amber); }
.btn-icon.pin-active:hover {
  background: #fef3c7;
  color: #92400e;
}

/* Create Pinned Room Form */
.pinned-create-form {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.pinned-input-wrap {
  display: flex;
  align-items: center;
  background: var(--bg-input);
  border: 1.5px solid rgba(245,158,11,.4);
  border-radius: var(--r-sm);
  overflow: hidden;
  transition: var(--t-fast);
}

.pinned-input-wrap:focus-within {
  border-color: var(--accent-amber);
  box-shadow: 0 0 0 3px rgba(245,158,11,.12);
}

.pinned-prefix {
  padding: 10px 12px;
  font-size: 13px;
  color: var(--accent-amber);
  font-weight: 700;
  background: #fef9ed;
  border-right: 1.5px solid rgba(245,158,11,.2);
  white-space: nowrap;
}

.pinned-input-wrap input {
  flex-grow: 1;
  background: transparent;
  border: none;
  outline: none;
  padding: 10px 12px;
  color: var(--text-main);
  font-size: 14px;
  font-weight: 600;
  font-family: var(--font-heading);
}

.pinned-hint { font-size: 11px; color: var(--text-muted); }
.pinned-hint.error { color: var(--accent-red); }
.pinned-hint.ok    { color: var(--accent-green); }

.pinned-form-actions {
  display: flex;
  justify-content: flex-end;
  margin-top: 4px;
}

code {
  background: rgba(99,102,241,.08);
  padding: 1px 5px;
  border-radius: 4px;
  font-size: 12px;
  color: var(--primary);
}

/* ── Responsive ──────────────────────────────────────────────────────────── */
@media (max-width: 640px) {
  body { padding: 16px 12px 32px; }

  .app-header {
    flex-direction: column;
    align-items: flex-start;
    border-radius: var(--r-lg);
    padding: 14px 16px;
  }

  .room-pill { width: 100%; justify-content: space-between; }

  .workspace-card {
    padding: 18px;
    border-radius: var(--r-lg);
  }

  .editor-actions { flex-direction: column; align-items: stretch; }
  .left-actions, .right-actions { flex-direction: column; }

  .tab-btn span:last-child { display: none; }

  .pinned-dropdown {
    left: auto;
    right: 0;
  }
}
