/* ═══════════════════════════════════════════════════════════════
   Markuply — Design System
   Aesthetic: Dark chrome shell · Light content canvas · Emerald accent
   Fonts: Syne (headings) · Manrope (body)
═══════════════════════════════════════════════════════════════ */

/* ── Variables ── */
:root {
  --bg:          #0d1117;
  --surface:     #161b22;
  --surface-2:   #1f2937;
  --border:      #30363d;
  --border-soft: #21262d;

  --text:        #e6edf3;
  --text-muted:  #7d8590;
  --text-faint:  #484f58;

  --accent:      #3ecf8e;
  --accent-dim:  rgba(62,207,142,.15);
  --accent-dark: #2ea872;

  --danger:      #f85149;
  --warn:        #d29922;

  --pin-bg:      #ff5757;
  --pin-resolve: #3ecf8e;

  --canvas:      #ffffff;
  --canvas-bg:   #f6f8fa;

  --radius:      10px;
  --radius-lg:   16px;
  --radius-sm:   6px;
  --shadow:      0 4px 24px rgba(0,0,0,.4);
  --shadow-sm:   0 1px 8px rgba(0,0,0,.3);

  --sidebar-w:   340px;
  --topbar-h:    56px;

  font-family: 'Manrope', system-ui, sans-serif;
  font-size: 14px;
  line-height: 1.5;
  color: var(--text);
}

/* ── Reset ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
img { display: block; max-width: 100%; }
input, textarea, button { font-family: inherit; font-size: inherit; }
a { text-decoration: none; color: inherit; }
svg { display: block; width: 16px; height: 16px; fill: none;
      stroke: currentColor; stroke-width: 2;
      stroke-linecap: round; stroke-linejoin: round; }

/* ═══ AUTH PAGES ════════════════════════════════════════════════ */
.auth-page {
  background: var(--bg);
  display: flex; align-items: center; justify-content: center;
  min-height: 100vh; padding: 24px;
}

.auth-container {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 40px;
  width: 100%; max-width: 420px;
  box-shadow: var(--shadow);
}

.auth-brand {
  display: flex; align-items: center; gap: 10px;
  margin-bottom: 32px;
}

.brand-logo {
  width: 32px; height: 32px;
  background: var(--accent);
  border-radius: 8px;
  position: relative;
}
.brand-logo::after {
  content: '';
  position: absolute; inset: 7px;
  border: 2px solid #0d1117;
  border-radius: 2px;
}
.brand-logo.small { width: 24px; height: 24px; border-radius: 6px; }
.brand-logo.small::after { inset: 5px; }

.brand-name {
  font-family: 'Syne', sans-serif;
  font-weight: 800; font-size: 20px;
  color: var(--text); letter-spacing: -0.5px;
}

.auth-title {
  font-family: 'Syne', sans-serif;
  font-size: 26px; font-weight: 700;
  color: var(--text); margin-bottom: 6px;
}
.auth-sub { color: var(--text-muted); margin-bottom: 28px; }

.auth-form { display: flex; flex-direction: column; gap: 16px; }

.auth-switch {
  text-align: center; color: var(--text-muted);
  margin-top: 20px;
}
.auth-switch a { color: var(--accent); font-weight: 600; }
.auth-switch a:hover { text-decoration: underline; }

/* ═══ FORM FIELDS ═══════════════════════════════════════════════ */
.field { display: flex; flex-direction: column; gap: 6px; }
.field label { font-weight: 600; color: var(--text-muted); font-size: 12px;
               text-transform: uppercase; letter-spacing: .5px; }

input[type="text"], input[type="email"], input[type="url"],
input[type="password"], textarea {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  color: var(--text);
  outline: none;
  transition: border-color .15s;
  width: 100%;
}
input:focus, textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-dim);
}
input::placeholder, textarea::placeholder { color: var(--text-faint); }
textarea { resize: vertical; min-height: 80px; }

/* ═══ BUTTONS ══════════════════════════════════════════════════ */
.btn {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 9px 18px; border-radius: var(--radius-sm);
  font-weight: 600; cursor: pointer;
  border: none; outline: none;
  transition: all .15s; white-space: nowrap;
}
.btn svg { width: 15px; height: 15px; }
.btn-primary {
  background: var(--accent); color: #0d1117;
}
.btn-primary:hover { background: var(--accent-dark); }

.btn-outline {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text);
}
.btn-outline:hover { border-color: var(--accent); color: var(--accent); }

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

.btn-danger {
  background: transparent; color: var(--danger);
  border: 1px solid transparent;
}
.btn-danger:hover { background: rgba(248,81,73,.1); border-color: var(--danger); }

.btn-sm { padding: 6px 12px; font-size: 13px; }
.btn-sm svg { width: 13px; height: 13px; }
.btn-full { width: 100%; justify-content: center; }

.btn-logout {
  display: block; text-align: center;
  padding: 8px; border-radius: var(--radius-sm);
  color: var(--text-muted); font-size: 13px; font-weight: 500;
  transition: all .15s;
}
.btn-logout:hover { background: var(--surface-2); color: var(--danger); }

/* ═══ ALERT ═════════════════════════════════════════════════════ */
.alert {
  padding: 10px 14px; border-radius: var(--radius-sm);
  margin-bottom: 16px; font-weight: 500; font-size: 13px;
}
.alert-error { background: rgba(248,81,73,.1); color: var(--danger);
               border: 1px solid rgba(248,81,73,.3); }

/* ═══ DASHBOARD ═════════════════════════════════════════════════ */
.dashboard-page {
  background: var(--bg);
  display: flex; height: 100vh; overflow: hidden;
}

/* Sidebar */
.sidebar {
  width: 240px; flex-shrink: 0;
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex; flex-direction: column;
  padding: 20px 0;
}
.sidebar-top { flex: 1; padding: 0 16px; }
.sidebar-brand {
  display: flex; align-items: center; gap: 10px;
  padding: 4px 8px; margin-bottom: 24px;
}

.sidebar-nav { display: flex; flex-direction: column; gap: 2px; }
.nav-link {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 12px; border-radius: var(--radius-sm);
  color: var(--text-muted); font-weight: 500;
  transition: all .15s;
}
.nav-link svg { width: 16px; height: 16px; }
.nav-link:hover, .nav-link.active {
  background: var(--surface-2); color: var(--text);
}
.nav-link.active { color: var(--accent); }

.sidebar-bottom { padding: 16px; border-top: 1px solid var(--border-soft); }
.user-chip {
  display: flex; align-items: center; gap: 10px;
  margin-bottom: 10px;
}
.user-avatar {
  width: 32px; height: 32px; border-radius: 50%;
  background: var(--accent); color: #0d1117;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 13px; flex-shrink: 0;
}
.user-name  { font-weight: 600; font-size: 13px; }
.user-email { color: var(--text-muted); font-size: 11px;
              white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 140px; }

/* Main */
.main-content {
  flex: 1; overflow-y: auto;
  padding: 32px 36px;
}

.page-header {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 32px;
}
.page-title {
  font-family: 'Syne', sans-serif;
  font-size: 24px; font-weight: 700;
}
.page-sub { color: var(--text-muted); margin-top: 2px; }

/* Projects Grid */
.projects-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 20px;
}

.project-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  transition: border-color .2s, box-shadow .2s;
}
.project-card:hover {
  border-color: var(--accent);
  box-shadow: 0 0 0 1px var(--accent), var(--shadow);
}

.project-thumb {
  height: 160px; background: var(--surface-2);
  display: flex; align-items: center; justify-content: center;
  overflow: hidden; position: relative;
}
.project-thumb img { width: 100%; height: 100%; object-fit: cover; }
.project-thumb svg { width: 48px; height: 48px; color: var(--text-faint); }
.pdf-thumb   { background: #1a0f00; }
.website-thumb { background: #0a0f1a; }

.project-info { padding: 16px; }
.type-badge {
  display: inline-block;
  padding: 2px 8px; border-radius: 20px;
  font-size: 11px; font-weight: 700; letter-spacing: .5px;
  text-transform: uppercase; margin-bottom: 8px;
}
.type-image   { background: rgba(62,207,142,.15); color: var(--accent); }
.type-pdf     { background: rgba(210,153,34,.15);  color: var(--warn);   }
.type-website { background: rgba(88,166,255,.15);  color: #58a6ff;       }

.project-title {
  font-family: 'Syne', sans-serif;
  font-size: 15px; font-weight: 600;
  margin-bottom: 10px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

.project-meta { display: flex; gap: 14px; margin-bottom: 14px; }
.meta-item {
  display: flex; align-items: center; gap: 5px;
  color: var(--text-muted); font-size: 12px;
}
.meta-item svg { width: 12px; height: 12px; }

.project-actions { display: flex; align-items: center; gap: 6px; }
.project-actions .btn-danger { margin-left: auto; }

/* Empty state */
.empty-state {
  display: flex; flex-direction: column; align-items: center;
  justify-content: center; text-align: center;
  height: calc(100vh - 180px);
  color: var(--text-muted);
}
.empty-icon {
  width: 72px; height: 72px; border-radius: 20px;
  background: var(--surface); border: 1px solid var(--border);
  display: flex; align-items: center; justify-content: center;
  margin-bottom: 20px;
}
.empty-icon svg { width: 32px; height: 32px; color: var(--text-faint); }
.empty-state h2 {
  font-family: 'Syne', sans-serif; font-size: 20px; font-weight: 700;
  color: var(--text); margin-bottom: 8px;
}
.empty-state p { max-width: 320px; margin-bottom: 24px; line-height: 1.6; }

/* ═══ MODAL ═════════════════════════════════════════════════════ */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.7); backdrop-filter: blur(4px);
  display: flex; align-items: center; justify-content: center;
  z-index: 1000; padding: 20px;
}
.modal-overlay[hidden] { display: none !important; }

.modal {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  width: 100%; max-width: 500px;
  box-shadow: var(--shadow);
  animation: slideUp .2s ease;
}
.modal-sm { max-width: 380px; }

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

.modal-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 20px 24px; border-bottom: 1px solid var(--border);
}
.modal-header h2 {
  font-family: 'Syne', sans-serif; font-size: 18px; font-weight: 700;
}
.modal-close {
  width: 30px; height: 30px; border: none; background: none;
  color: var(--text-muted); cursor: pointer; border-radius: var(--radius-sm);
  display: flex; align-items: center; justify-content: center;
  transition: background .15s; padding: 0;
}
.modal-close:hover { background: var(--surface-2); color: var(--text); }
.modal-close svg { width: 16px; height: 16px; }

.modal-body   { padding: 24px; display: flex; flex-direction: column; gap: 18px; }
.modal-footer {
  display: flex; justify-content: flex-end; gap: 10px;
  padding: 16px 24px; border-top: 1px solid var(--border);
}

/* Type selector */
.type-selector { display: flex; gap: 8px; }
.type-btn {
  flex: 1; padding: 12px 8px;
  background: var(--bg); border: 2px solid var(--border);
  border-radius: var(--radius); cursor: pointer; color: var(--text-muted);
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  font-size: 12px; font-weight: 600; transition: all .15s;
}
.type-btn svg { width: 20px; height: 20px; }
.type-btn:hover { border-color: var(--accent); color: var(--text); }
.type-btn.active { border-color: var(--accent); color: var(--accent); background: var(--accent-dim); }

/* Drop zone */
.drop-zone {
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  padding: 32px 20px; text-align: center;
  cursor: pointer; transition: all .15s;
  display: flex; flex-direction: column; align-items: center; gap: 8px;
}
.drop-zone svg { width: 32px; height: 32px; color: var(--text-faint); margin-bottom: 4px; }
.drop-zone p { color: var(--text-muted); }
.drop-zone span { color: var(--accent); font-weight: 600; }
.drop-zone small { color: var(--text-faint); }
.drop-zone:hover, .drop-zone.dragover {
  border-color: var(--accent); background: var(--accent-dim);
}

.file-selected {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 14px; font-size: 13px;
  color: var(--accent); font-weight: 500;
}

/* Progress */
.progress-bar {
  height: 4px; background: var(--surface-2);
  border-radius: 2px; overflow: hidden; margin-bottom: 8px;
}
.progress-fill {
  height: 100%; background: var(--accent);
  width: 0%; transition: width .2s;
  border-radius: 2px;
}
#progressText { color: var(--text-muted); font-size: 13px; text-align: center; }

/* ═══ VIEWER ════════════════════════════════════════════════════ */
.viewer-page {
  background: var(--bg);
  height: 100vh; overflow: hidden;
  display: flex; flex-direction: column;
}

.viewer-layout { display: flex; flex-direction: column; height: 100%; }

/* Topbar */
.viewer-topbar {
  height: var(--topbar-h); flex-shrink: 0;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 16px; gap: 12px;
}
.topbar-left  { display: flex; align-items: center; gap: 12px; flex: 1; min-width: 0; }
.topbar-right { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }

.back-btn {
  width: 34px; height: 34px; border-radius: var(--radius-sm);
  display: flex; align-items: center; justify-content: center;
  color: var(--text-muted); transition: all .15s;
  flex-shrink: 0;
}
.back-btn:hover { background: var(--surface-2); color: var(--text); }
.back-btn svg { width: 18px; height: 18px; }

.viewer-title {
  font-family: 'Syne', sans-serif;
  font-size: 15px; font-weight: 700;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

/* Viewer body */
.viewer-body {
  flex: 1; display: flex; overflow: hidden;
}

/* Content area */
.content-area {
  flex: 1; overflow: auto;
  background: var(--canvas-bg);
  display: flex; justify-content: center;
  padding: 32px;
}

/* Image viewer */
.content-wrapper {
  position: relative; display: inline-block;
  align-self: flex-start;
  box-shadow: 0 8px 48px rgba(0,0,0,.25);
  border-radius: 4px; overflow: visible;
}
.content-wrapper img {
  display: block; max-width: 100%;
  border-radius: 4px;
}

/* PDF viewer */
.pdf-wrapper {
  position: relative; align-self: flex-start;
  display: flex; flex-direction: column; gap: 20px;
}
.pdf-page-container {
  position: relative;
  box-shadow: 0 4px 24px rgba(0,0,0,.2);
}
.pdf-page-container canvas { display: block; border-radius: 2px; }
.pdf-page-overlay {
  position: absolute; inset: 0;
  cursor: crosshair; z-index: 5;
}

/* Website viewer */
.website-wrapper {
  position: relative;
  width: 1200px;
  align-self: flex-start;
}
#siteFrame {
  width: 100%; height: 6000px;
  border: none; display: block;
  background: var(--canvas);
}
.browse-hint {
  position: sticky; top: 8px;
  background: rgba(13,17,23,.85); backdrop-filter: blur(8px);
  color: var(--text-muted); font-size: 12px; font-weight: 600;
  padding: 6px 14px; border-radius: 20px;
  border: 1px solid var(--border);
  display: inline-block; margin: 12px auto; left: 50%; transform: translateX(-50%);
  pointer-events: none; z-index: 20;
  white-space: nowrap;
}

/* Overlay (image & website) */
.click-overlay {
  position: absolute; inset: 0;
  cursor: crosshair; z-index: 10;
}
.click-overlay:not(.active) {
  pointer-events: none;
}

/* Pins layer */
.pins-layer {
  position: absolute; inset: 0;
  pointer-events: none; z-index: 15;
}

/* Comment pin */
.comment-pin {
  position: absolute;
  width: 28px; height: 28px;
  border-radius: 50% 50% 50% 4px;
  background: var(--pin-bg);
  color: white;
  display: flex; align-items: center; justify-content: center;
  font-size: 11px; font-weight: 700;
  transform: translate(-14px, -28px);
  pointer-events: all; cursor: pointer;
  box-shadow: 0 2px 10px rgba(0,0,0,.4);
  transition: transform .15s, box-shadow .15s;
  border: 2px solid rgba(255,255,255,.2);
  user-select: none;
  z-index: 20;
}
.comment-pin:hover {
  transform: translate(-14px, -32px) scale(1.15);
  box-shadow: 0 4px 20px rgba(0,0,0,.5);
}
.comment-pin.resolved { background: var(--pin-resolve); }
.comment-pin.active   { box-shadow: 0 0 0 3px white, 0 4px 20px rgba(0,0,0,.5); }

/* ═══ COMMENT SIDEBAR ═══════════════════════════════════════════ */
.comment-sidebar {
  width: var(--sidebar-w); flex-shrink: 0;
  background: var(--surface);
  border-left: 1px solid var(--border);
  display: flex; flex-direction: column;
  transition: width .2s;
}
.comment-sidebar.collapsed { width: 48px; overflow: hidden; }

.sidebar-header {
  display: flex; align-items: center; gap: 8px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.sidebar-header h2 {
  font-family: 'Syne', sans-serif;
  font-size: 14px; font-weight: 700; flex: 1;
}
.comment-count {
  background: var(--surface-2);
  color: var(--text-muted);
  font-size: 11px; font-weight: 700;
  padding: 2px 7px; border-radius: 20px;
}
.sidebar-toggle {
  width: 28px; height: 28px; border: none; background: none;
  color: var(--text-muted); cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  border-radius: var(--radius-sm); transition: all .15s; padding: 0;
}
.sidebar-toggle:hover { background: var(--surface-2); color: var(--text); }
.sidebar-toggle svg { width: 14px; height: 14px; transition: transform .2s; }
.collapsed .sidebar-toggle svg { transform: rotate(180deg); }

.comment-list { flex: 1; overflow-y: auto; padding: 12px; }
.comments-empty {
  display: flex; flex-direction: column; align-items: center;
  justify-content: center; text-align: center;
  height: 200px; color: var(--text-faint); gap: 12px; padding: 20px;
}
.comments-empty svg { width: 32px; height: 32px; }
.comments-empty p { font-size: 13px; line-height: 1.5; }

/* Comment item */
.comment-item {
  background: var(--bg);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius);
  padding: 12px 14px;
  margin-bottom: 8px;
  transition: border-color .15s;
  cursor: pointer;
  animation: fadeIn .2s ease;
}
.comment-item:hover { border-color: var(--border); }
.comment-item.active { border-color: var(--accent); }
.comment-item.resolved { opacity: .55; }

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

.ci-header {
  display: flex; align-items: center; gap: 8px; margin-bottom: 8px;
}
.ci-num {
  width: 20px; height: 20px; border-radius: 50%;
  background: var(--pin-bg); color: white;
  font-size: 10px; font-weight: 700;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.ci-num.resolved { background: var(--pin-resolve); }
.ci-author { font-weight: 600; font-size: 13px; flex: 1; }
.ci-time   { color: var(--text-faint); font-size: 11px; }

.ci-content { font-size: 13px; line-height: 1.55; color: var(--text-muted); margin-bottom: 10px; }

.ci-actions { display: flex; gap: 6px; }
.ci-action {
  font-size: 11px; font-weight: 600; padding: 3px 10px;
  border-radius: 20px; border: 1px solid var(--border);
  background: none; cursor: pointer; color: var(--text-muted);
  transition: all .15s;
}
.ci-action:hover { background: var(--surface-2); color: var(--text); }
.ci-action.resolve-btn:hover { border-color: var(--accent); color: var(--accent); }
.ci-action.delete-btn:hover  { border-color: var(--danger); color: var(--danger); }

/* ═══ COMMENT POPUP ═════════════════════════════════════════════ */
.comment-popup {
  position: fixed; z-index: 200;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
  width: 280px;
  box-shadow: var(--shadow);
  animation: slideUp .15s ease;
}
.comment-popup[hidden] { display: none !important; }

.popup-input, .popup-textarea {
  background: var(--bg) !important;
  border: 1px solid var(--border) !important;
  border-radius: var(--radius-sm) !important;
  padding: 8px 12px !important;
  color: var(--text) !important; width: 100%;
}
.popup-textarea { resize: none; min-height: 72px; }

.popup-actions {
  display: flex; justify-content: flex-end; gap: 8px; margin-top: 10px;
}

/* ═══ TOAST ═════════════════════════════════════════════════════ */
.toast {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius); padding: 12px 20px;
  font-size: 13px; font-weight: 500;
  box-shadow: var(--shadow); z-index: 9999;
  opacity: 0; pointer-events: none;
  transition: opacity .25s;
  white-space: nowrap;
}
.toast.show { opacity: 1; pointer-events: all; }
.toast.success { border-color: var(--accent); color: var(--accent); }
.toast.error   { border-color: var(--danger); color: var(--danger); }

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