/* CRP Client Portal — styles.css */

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

:root {
  --navy:      #0f1c2e;
  --navy-mid:  #1a2e47;
  --navy-soft: #243853;
  --accent:    #2f80ed;
  --accent-hov:#1a6fd8;
  --green:     #27ae60;
  --red:       #e74c3c;
  --amber:     #f39c12;
  --border:    rgba(255,255,255,0.10);
  --border-md: rgba(255,255,255,0.16);
  --text:      #e8edf3;
  --text-muted:#8fa3bc;
  --surface:   #192539;
  --card:      #1e2f45;
  --radius:    10px;
  --radius-lg: 16px;
  --font:      system-ui, -apple-system, 'Segoe UI', sans-serif;
  --mono:      'SF Mono', 'Fira Code', 'Consolas', monospace;
}

html, body {
  height: 100%;
  font-family: var(--font);
  background: var(--navy);
  color: var(--text);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

/* ── Layout ───────────────────────────────────────────────────────── */

#app { min-height: 100vh; display: flex; flex-direction: column; }

header {
  position: sticky; top: 0; z-index: 100;
  background: var(--navy-mid);
  border-bottom: 1px solid var(--border);
  padding: 0 24px;
  height: 56px;
  display: flex; align-items: center; justify-content: space-between;
}

.header-logo {
  display: flex; align-items: center; gap: 10px;
  font-weight: 700; font-size: 16px; letter-spacing: -0.02em;
  color: var(--text);
  text-decoration: none;
}
.header-logo svg { flex-shrink: 0; }

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

#header-project-name {
  font-size: 13px; color: var(--text-muted);
  max-width: 200px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

.btn-ghost {
  background: none; border: none; cursor: pointer;
  color: var(--text-muted); font-size: 13px; padding: 6px 10px;
  border-radius: 6px; transition: color 0.15s, background 0.15s;
}
.btn-ghost:hover { color: var(--text); background: rgba(255,255,255,0.06); }

main { flex: 1; }

/* ── Screens ──────────────────────────────────────────────────────── */

.screen { display: none; }
.screen.active { display: block; }

/* ── Auth screens ─────────────────────────────────────────────────── */

.auth-wrap {
  min-height: calc(100vh - 56px);
  display: flex; align-items: center; justify-content: center;
  padding: 32px 16px;
}

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

.auth-icon {
  width: 48px; height: 48px;
  background: rgba(47,128,237,0.12);
  border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
  margin-bottom: 20px;
}

.auth-card h1 { font-size: 22px; font-weight: 700; margin-bottom: 4px; }
.auth-card .subtitle { color: var(--text-muted); font-size: 14px; margin-bottom: 28px; }

.form-group { margin-bottom: 16px; }
.form-label { display: block; font-size: 13px; font-weight: 500; color: var(--text-muted); margin-bottom: 6px; }

.form-input {
  width: 100%; padding: 10px 14px;
  background: var(--navy);
  border: 1px solid var(--border-md);
  border-radius: 8px;
  color: var(--text); font-size: 15px; font-family: var(--font);
  transition: border-color 0.15s, box-shadow 0.15s;
  outline: none;
}
.form-input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(47,128,237,0.18); }
.form-input::placeholder { color: var(--text-muted); }
.form-input.pin-input {
  font-size: 28px; font-weight: 700; font-family: var(--mono);
  letter-spacing: 0.12em; text-align: center; text-transform: uppercase;
}

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 10px 20px; border-radius: 8px;
  font-size: 14px; font-weight: 600; font-family: var(--font);
  cursor: pointer; border: none; transition: background 0.15s, opacity 0.15s;
  text-decoration: none;
}
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--accent-hov); }
.btn-secondary {
  background: rgba(255,255,255,0.07); color: var(--text);
  border: 1px solid var(--border-md);
}
.btn-secondary:hover:not(:disabled) { background: rgba(255,255,255,0.11); }
.btn-full { width: 100%; }
.btn-sm { padding: 6px 12px; font-size: 13px; }
.btn-danger { background: rgba(231,76,60,0.15); color: #ff6b6b; border: 1px solid rgba(231,76,60,0.3); }
.btn-danger:hover:not(:disabled) { background: rgba(231,76,60,0.25); }

.auth-divider {
  text-align: center; font-size: 12px; color: var(--text-muted);
  margin: 20px 0; position: relative;
}
.auth-divider::before, .auth-divider::after {
  content: ''; position: absolute; top: 50%; width: 40%; height: 1px;
  background: var(--border);
}
.auth-divider::before { left: 0; }
.auth-divider::after { right: 0; }

/* ── Alert ────────────────────────────────────────────────────────── */

.alert {
  padding: 10px 14px; border-radius: 8px; font-size: 13px;
  margin-bottom: 16px; display: none;
}
.alert.show { display: block; }
.alert-error { background: rgba(231,76,60,0.12); color: #ff7f7f; border: 1px solid rgba(231,76,60,0.3); }
.alert-success { background: rgba(39,174,96,0.12); color: #6ed49a; border: 1px solid rgba(39,174,96,0.3); }

/* ── Demo list screen ─────────────────────────────────────────────── */

.list-wrap { max-width: 960px; margin: 0 auto; padding: 32px 24px; }

.page-title { font-size: 22px; font-weight: 700; margin-bottom: 4px; }
.page-sub { color: var(--text-muted); font-size: 14px; margin-bottom: 28px; }

/* Tabs */
.tabs {
  display: flex; gap: 0; border-bottom: 1px solid var(--border);
  margin-bottom: 28px;
}
.tab-btn {
  padding: 10px 20px; background: none; border: none; cursor: pointer;
  font-size: 14px; font-weight: 500; color: var(--text-muted);
  border-bottom: 2px solid transparent; margin-bottom: -1px;
  transition: color 0.15s, border-color 0.15s;
}
.tab-btn:hover { color: var(--text); }
.tab-btn.active { color: var(--accent); border-bottom-color: var(--accent); }
.tab-panel { display: none; }
.tab-panel.active { display: block; }

/* Demo cards */
.demo-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 16px;
}

.demo-card {
  background: var(--card); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 20px;
  cursor: pointer; transition: border-color 0.15s, transform 0.15s, box-shadow 0.15s;
  display: flex; flex-direction: column; gap: 12px;
}
.demo-card:hover {
  border-color: var(--accent);
  box-shadow: 0 4px 20px rgba(47,128,237,0.12);
  transform: translateY(-1px);
}

.demo-type-badge {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 3px 8px; border-radius: 5px; font-size: 11px; font-weight: 600;
  text-transform: uppercase; letter-spacing: 0.05em;
}
.type-html  { background: rgba(47,128,237,0.15); color: #6ab0ff; }
.type-video { background: rgba(231,76,60,0.15);  color: #ff8f8f; }
.type-figma { background: rgba(243,78,234,0.15); color: #f07ef9; }
.type-doc   { background: rgba(243,156,18,0.15); color: #ffc760; }

.demo-card-title { font-weight: 600; font-size: 15px; }
.demo-card-url { font-size: 12px; color: var(--text-muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.empty-state {
  text-align: center; padding: 64px 16px; color: var(--text-muted);
}
.empty-state svg { opacity: 0.3; margin-bottom: 12px; }
.empty-state p { font-size: 15px; }
.empty-state small { font-size: 13px; }

/* ── Upload tab ───────────────────────────────────────────────────── */

.upload-zone {
  border: 2px dashed var(--border-md);
  border-radius: var(--radius);
  padding: 48px 24px;
  text-align: center;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}
.upload-zone:hover, .upload-zone.drag-over {
  border-color: var(--accent);
  background: rgba(47,128,237,0.04);
}
.upload-zone p { color: var(--text-muted); font-size: 14px; margin-top: 8px; }
.upload-zone small { font-size: 12px; color: var(--text-muted); opacity: 0.7; }

#file-input { display: none; }

.upload-list { margin-top: 24px; display: flex; flex-direction: column; gap: 10px; }

.upload-item {
  display: flex; align-items: center; gap: 12px;
  background: var(--card); border: 1px solid var(--border);
  border-radius: 8px; padding: 12px 16px;
}
.upload-item-icon { flex-shrink: 0; width: 32px; height: 32px; display: flex; align-items: center; justify-content: center; border-radius: 6px; }
.upload-item-icon.pdf { background: rgba(243,156,18,0.12); color: #ffc760; }
.upload-item-icon.img { background: rgba(39,174,96,0.12); color: #6ed49a; }
.upload-item-name { flex: 1; font-size: 13px; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.upload-item-size { font-size: 12px; color: var(--text-muted); white-space: nowrap; }
.upload-item a { color: var(--accent); font-size: 12px; text-decoration: none; white-space: nowrap; }
.upload-item a:hover { text-decoration: underline; }

/* ── Demo viewer screen ───────────────────────────────────────────── */

.viewer-wrap { display: flex; flex-direction: column; height: calc(100vh - 56px); }

.viewer-toolbar {
  background: var(--navy-mid); border-bottom: 1px solid var(--border);
  padding: 10px 20px;
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
}
.viewer-toolbar .demo-title { font-weight: 600; font-size: 15px; flex: 1; }
.viewer-toolbar .demo-badge { flex-shrink: 0; }

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

/* Left: viewer pane */
.viewer-pane { flex: 1; position: relative; overflow: hidden; }

/* Right: comment panel */
.comment-panel {
  width: 320px; flex-shrink: 0;
  border-left: 1px solid var(--border);
  background: var(--card);
  display: flex; flex-direction: column;
  overflow: hidden;
}

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

.comment-form { padding: 14px 16px; border-bottom: 1px solid var(--border); }
.comment-form textarea {
  width: 100%; padding: 10px 12px;
  background: var(--navy); border: 1px solid var(--border-md);
  border-radius: 8px; color: var(--text); font-family: var(--font);
  font-size: 13px; line-height: 1.5; resize: vertical; min-height: 72px;
  outline: none; transition: border-color 0.15s;
}
.comment-form textarea:focus { border-color: var(--accent); }
.comment-meta { font-size: 12px; color: var(--text-muted); margin-bottom: 8px; }

.comment-list { flex: 1; overflow-y: auto; padding: 8px; }

.comment-item {
  padding: 10px 12px; border-radius: 8px;
  margin-bottom: 8px; background: var(--navy);
  border: 1px solid var(--border);
  cursor: pointer; transition: border-color 0.15s;
}
.comment-item:hover { border-color: var(--border-md); }
.comment-item.highlight { border-color: var(--accent); background: rgba(47,128,237,0.08); }
.comment-item-header {
  display: flex; align-items: center; gap: 8px; margin-bottom: 4px;
}
.comment-pin {
  width: 20px; height: 20px; border-radius: 50%;
  background: var(--accent); color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-size: 10px; font-weight: 700; flex-shrink: 0;
}
.comment-user { font-size: 12px; font-weight: 600; }
.comment-time { font-size: 11px; color: var(--text-muted); }
.comment-body-text { font-size: 13px; line-height: 1.4; }
.comment-ts-badge {
  display: inline-block; font-size: 11px; font-weight: 600;
  background: rgba(231,76,60,0.15); color: #ff8f8f;
  padding: 1px 6px; border-radius: 4px; margin-bottom: 4px;
}
.comment-page-badge {
  display: inline-block; font-size: 11px; font-weight: 600;
  background: rgba(243,156,18,0.15); color: #ffc760;
  padding: 1px 6px; border-radius: 4px; margin-bottom: 4px;
}

/* HTML viewer */
.html-viewer-container {
  position: relative; width: 100%; height: 100%;
  overflow: hidden;
}
#html-iframe {
  width: 100%; height: 100%; border: none; display: block;
}
#html-overlay {
  position: absolute; inset: 0; z-index: 10;
  pointer-events: none;
}
#html-overlay.comment-mode { background: rgba(47,128,237,0.04); pointer-events: auto; cursor: crosshair; }
.pin-marker {
  position: absolute; transform: translate(-50%, -50%);
  width: 26px; height: 26px; border-radius: 50%;
  background: var(--accent); color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-size: 11px; font-weight: 700;
  box-shadow: 0 2px 8px rgba(0,0,0,0.4);
  cursor: pointer; transition: transform 0.15s;
  pointer-events: none;
}
#html-overlay.comment-mode .pin-marker { pointer-events: auto; }
.pin-marker:hover, .pin-marker.highlight { transform: translate(-50%, -50%) scale(1.2); }
.comment-mode-toggle {
  padding: 6px 12px; border-radius: 6px; font-size: 13px; font-weight: 500;
  border: 1px solid var(--border-md); cursor: pointer;
  background: rgba(255,255,255,0.06); color: var(--text);
  transition: background 0.15s, border-color 0.15s;
  display: flex; align-items: center; gap: 6px;
}
.comment-mode-toggle.active { background: rgba(47,128,237,0.15); border-color: var(--accent); color: var(--accent); }

/* Video viewer */
.video-viewer-container { width: 100%; height: 100%; display: flex; flex-direction: column; overflow: hidden; }
#demo-video { width: 100%; flex: 1; background: #000; object-fit: contain; display: block; }

/* Figma viewer */
.figma-viewer-container { width: 100%; height: 100%; }
#figma-iframe { width: 100%; height: 100%; border: none; }

/* Doc viewer */
.doc-viewer-container {
  width: 100%; height: 100%; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 20px; padding: 40px;
}
.doc-open-btn {
  display: inline-flex; align-items: center; gap: 10px;
  padding: 14px 28px; background: var(--accent); color: #fff;
  border-radius: 10px; font-size: 15px; font-weight: 600;
  text-decoration: none; transition: background 0.15s;
}
.doc-open-btn:hover { background: var(--accent-hov); }
.doc-viewer-note { color: var(--text-muted); font-size: 14px; text-align: center; }

/* Spinner */
.spinner {
  display: inline-block; width: 18px; height: 18px;
  border: 2px solid rgba(255,255,255,0.2);
  border-top-color: rgba(255,255,255,0.8);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Scrollbar */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.12); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,0.22); }

/* Responsive */
@media (max-width: 640px) {
  .viewer-body { flex-direction: column; }
  .comment-panel { width: 100%; height: 300px; border-left: none; border-top: 1px solid var(--border); }
  .auth-card { padding: 28px 20px; }
  .list-wrap { padding: 20px 16px; }
}
