:root {
  --bg: #f4f5f7;
  --surface: #ffffff;
  --surface-2: #f8f9fb;
  --border: #e3e6ea;
  --text: #1f2430;
  --muted: #7a8290;
  --primary: #2f6bff;
  --primary-dark: #1f52d6;
  --accent-owner: #0f9d58;
  --accent-arch: #7c4dff;
  --danger: #e5484d;
  --radius: 12px;
  --shadow: 0 1px 3px rgba(20, 30, 50, .06), 0 6px 24px rgba(20, 30, 50, .06);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
}

.hidden { display: none !important; }
.muted { color: var(--muted); font-size: 13px; }

button, input, select { font-family: inherit; font-size: 14px; }

.btn {
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  padding: 9px 16px;
  border-radius: 9px;
  cursor: pointer;
  font-weight: 600;
  transition: .15s;
}
.btn:hover { background: var(--surface-2); }
.btn-primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-sm { padding: 6px 12px; font-size: 13px; }
.icon-btn {
  border: none; background: transparent; cursor: pointer;
  font-size: 16px; color: var(--muted); padding: 4px 8px; border-radius: 6px;
}
.icon-btn:hover { background: var(--surface-2); color: var(--text); }

/* ---------- Login ---------- */
.login-screen {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, #eef2ff, #f4f5f7);
}
.login-card {
  background: var(--surface); padding: 40px 36px; border-radius: 16px;
  box-shadow: var(--shadow); width: 340px; text-align: center;
  display: flex; flex-direction: column; gap: 12px;
}
.login-logo { font-size: 40px; }
.login-card h1 { margin: 0; font-size: 20px; }
.login-card input {
  padding: 11px 14px; border: 1px solid var(--border); border-radius: 9px; outline: none;
}
.login-card input:focus { border-color: var(--primary); }
.login-error { color: var(--danger); font-size: 13px; min-height: 18px; }

/* ---------- Topbar ---------- */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 24px; background: var(--surface); border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 20;
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 17px; }
.brand-logo { font-size: 22px; }
.role-picker { display: flex; align-items: center; gap: 8px; }
.role-picker select {
  padding: 7px 10px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface);
}

/* ---------- Tabs ---------- */
.tabs {
  display: flex; gap: 4px; padding: 10px 24px 0; background: var(--surface);
  border-bottom: 1px solid var(--border); overflow-x: auto; position: sticky; top: 57px; z-index: 15;
}
.tab {
  border: none; background: transparent; padding: 11px 18px; cursor: pointer;
  font-weight: 600; color: var(--muted); border-bottom: 3px solid transparent;
  white-space: nowrap; display: flex; align-items: center; gap: 8px;
}
.tab:hover { color: var(--text); }
.tab.active { color: var(--primary); border-bottom-color: var(--primary); }
.tab .count { font-size: 12px; background: var(--surface-2); color: var(--muted);
  padding: 1px 7px; border-radius: 10px; }
.tab.active .count { background: #e7efff; color: var(--primary); }
.tab-add { border: none; background: transparent; cursor: pointer; color: var(--muted);
  padding: 11px 14px; font-weight: 700; }
.tab-add:hover { color: var(--primary); }

/* ---------- Content ---------- */
.content { padding: 20px 24px 60px; max-width: 1400px; margin: 0 auto; }

.room-toolbar {
  display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; gap: 12px;
}
.room-toolbar h2 { margin: 0; font-size: 18px; }
.room-title { display: flex; align-items: baseline; gap: 10px; }
.toolbar-actions { display: flex; gap: 8px; }

/* ---------- Khối một góc ---------- */
.shot-block {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow); margin-bottom: 22px; overflow: hidden;
}
.shot-head {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 12px 16px; border-bottom: 1px solid var(--border);
  background: linear-gradient(var(--surface-2), var(--surface));
}
.shot-head-left { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; min-width: 0; }
.shot-index {
  font-size: 11px; font-weight: 700; color: var(--primary);
  background: #e7efff; padding: 2px 9px; border-radius: 20px; white-space: nowrap;
}
.shot-name { margin: 0; font-size: 16px; font-weight: 700; }
.shot-count { font-size: 12px; color: var(--muted); }
.shot-actions { display: flex; align-items: center; gap: 6px; flex-shrink: 0; }
.shot-body { padding: 14px 16px 16px; }
.shot-note {
  background: #fff8e6; border: 1px solid #f3e3b3; color: #8a6d1f;
  border-radius: 9px; padding: 8px 12px; margin-bottom: 12px; font-size: 13px;
}
.single-wrap { display: grid; grid-template-columns: minmax(0, 620px); }

/* Empty state */
.empty {
  text-align: center; padding: 60px 20px; color: var(--muted);
  background: var(--surface); border: 2px dashed var(--border); border-radius: var(--radius);
}
.empty .big { font-size: 40px; margin-bottom: 10px; }

/* Thanh phiên bản (timeline) */
.timeline {
  display: flex; gap: 10px; overflow-x: auto; padding: 4px 2px 12px; margin-bottom: 8px;
}
.thumb {
  flex: 0 0 auto; width: 120px; border: 2px solid var(--border); border-radius: 10px;
  overflow: hidden; cursor: pointer; background: var(--surface); position: relative;
}
.thumb.sel-left { border-color: var(--primary); }
.thumb.sel-right { border-color: var(--accent-arch); }
.thumb img { width: 100%; height: 84px; object-fit: cover; display: block; }
.thumb .thumb-meta { padding: 5px 7px; font-size: 11px; }
.thumb .thumb-label { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.thumb .thumb-badge {
  position: absolute; top: 5px; left: 5px; font-size: 10px; font-weight: 700;
  padding: 1px 6px; border-radius: 6px; color: #fff;
}
.thumb .pin { position: absolute; top: 4px; right: 4px; display: flex; gap: 3px; }
.pin-btn { font-size: 10px; font-weight: 700; border: none; border-radius: 5px; cursor: pointer;
  padding: 2px 6px; color: #fff; opacity: .92; }
.pin-l { background: var(--primary); }
.pin-r { background: var(--accent-arch); }

/* Chọn kiểu xem */
.view-toggle { display: inline-flex; gap: 4px; background: var(--surface-2); border: 1px solid var(--border); border-radius: 10px; padding: 3px; margin-bottom: 14px; }
.vt-btn { border: none; background: transparent; padding: 8px 14px; border-radius: 8px; cursor: pointer; font-weight: 600; color: var(--muted); font-size: 13px; }
.vt-btn:hover { color: var(--text); }
.vt-btn.active { background: var(--surface); color: var(--primary); box-shadow: var(--shadow); }

/* Kéo trượt Trước/Sau */
.ba-pickers { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 12px; }
.ba-picker { display: flex; align-items: center; gap: 8px; }
.ba-picker select { padding: 7px 10px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface); max-width: 260px; }
.ba-arrow { color: var(--muted); font-weight: 700; }
.ba-wrap { text-align: center; background: #0e1116; border: 1px solid var(--border); border-radius: 12px; padding: 12px; margin-bottom: 16px; box-shadow: var(--shadow); }
.ba-slider { position: relative; display: inline-block; line-height: 0; max-width: 100%; cursor: ew-resize; touch-action: none; user-select: none; }
.ba-slider img { -webkit-user-drag: none; user-select: none; pointer-events: none; }
.ba-after { display: block; max-width: 100%; max-height: 72vh; width: auto; height: auto; }
.ba-before { position: absolute; top: 0; left: 0; width: 100%; height: 100%; object-fit: fill; }
.ba-divider { position: absolute; top: 0; bottom: 0; width: 2px; background: #fff; box-shadow: 0 0 5px rgba(0,0,0,.7); transform: translateX(-1px); pointer-events: none; }
.ba-handle {
  position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%);
  width: 38px; height: 38px; border-radius: 50%; background: #fff; color: #1f2430;
  display: flex; align-items: center; justify-content: center; font-size: 17px; font-weight: 700;
  box-shadow: 0 1px 8px rgba(0,0,0,.55);
}
.ba-label {
  position: absolute; top: 10px; font-size: 11px; font-weight: 700; color: #fff;
  background: rgba(15,20,30,.62); padding: 3px 10px; border-radius: 6px; letter-spacing: .05em; pointer-events: none;
}
.ba-label-l { left: 10px; }
.ba-label-r { right: 10px; }
.ba-hint { margin-top: 8px; font-size: 12px; }
.ba-cmt-title { font-weight: 700; font-size: 14px; }

/* Bảng so sánh 2 cột */
.compare { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.pane {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow); overflow: hidden; display: flex; flex-direction: column;
}
.pane-head {
  display: flex; align-items: center; gap: 8px; padding: 10px 12px; border-bottom: 1px solid var(--border);
  background: var(--surface-2);
}
.pane-head .side-tag { font-size: 11px; font-weight: 700; padding: 2px 8px; border-radius: 6px; color: #fff; }
.side-left { background: var(--primary); }
.side-right { background: var(--accent-arch); }
.pane-head select { flex: 1; padding: 7px 10px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface); }
.pane-img-wrap { background: #0e1116; display: flex; align-items: center; justify-content: center; min-height: 240px; overflow: auto; }
.pane-img-wrap img { max-width: 100%; max-height: 460px; object-fit: contain; cursor: zoom-in; display: block; }
.pane-img-empty { color: #8a93a3; padding: 60px 20px; text-align: center; }

/* Thanh công cụ ghim */
.pane-tools { display: flex; align-items: center; gap: 8px; padding: 8px 12px; border-bottom: 1px solid var(--border); background: var(--surface); }
.pin-toggle.active { background: var(--danger); border-color: var(--danger); color: #fff; }

/* Sân khấu ảnh + pin */
.pin-stage { position: relative; display: inline-block; line-height: 0; }
.pin-stage.adding, .pin-stage.adding img { cursor: crosshair; }
.imgpin {
  position: absolute; transform: translate(-50%, -50%);
  width: 26px; height: 26px; border-radius: 50%;
  background: var(--danger); color: #fff; font-size: 13px; font-weight: 700;
  display: flex; align-items: center; justify-content: center; line-height: 1;
  border: 2px solid #fff; box-shadow: 0 1px 5px rgba(0,0,0,.45); cursor: pointer; z-index: 3;
}
.imgpin:hover { transform: translate(-50%, -50%) scale(1.18); z-index: 4; }
.imgpin.flash { animation: pinflash .7s ease 2; }
@keyframes pinflash {
  0%, 100% { box-shadow: 0 1px 5px rgba(0,0,0,.45); }
  50% { box-shadow: 0 0 0 7px rgba(229,72,77,.45); }
}
.pin-num {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 20px; height: 20px; padding: 0 5px; border-radius: 10px;
  background: var(--danger); color: #fff; font-size: 12px; font-weight: 700;
}
.comment.has-pin { cursor: pointer; }
.comment.flash { box-shadow: 0 0 0 2px var(--primary); border-color: var(--primary); }

/* Popover nhập góp ý khi ghim */
.pin-popover {
  position: fixed; z-index: 80; width: 260px; background: var(--surface);
  border: 1px solid var(--border); border-radius: 11px; box-shadow: var(--shadow); padding: 12px;
}
.pin-pop-title { font-size: 13px; font-weight: 700; margin-bottom: 8px; }
.pin-popover textarea {
  width: 100%; min-height: 72px; border: 1px solid var(--border); border-radius: 8px;
  padding: 8px 10px; resize: vertical; outline: none; font-size: 14px; font-family: inherit;
}
.pin-popover textarea:focus { border-color: var(--primary); }
.pin-pop-actions { display: flex; justify-content: flex-end; gap: 6px; margin-top: 8px; }

.pane-info { padding: 10px 14px; border-bottom: 1px solid var(--border); }
.pane-info .v-label { font-weight: 700; }
.pane-info .v-sub { font-size: 12px; color: var(--muted); margin-top: 2px; display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }

.badge { font-size: 11px; font-weight: 700; padding: 1px 8px; border-radius: 6px; color: #fff; }
.badge-owner { background: var(--accent-owner); }
.badge-arch { background: var(--accent-arch); }
.badge-neutral { background: var(--muted); }

/* Góp ý */
.comments { padding: 12px 14px; flex: 1; }
.comments h4 { margin: 0 0 8px; font-size: 13px; color: var(--muted); text-transform: uppercase; letter-spacing: .03em; }
.comment {
  background: var(--surface-2); border: 1px solid var(--border); border-radius: 9px;
  padding: 8px 11px; margin-bottom: 8px; position: relative;
}
.comment .c-head { display: flex; align-items: center; gap: 6px; margin-bottom: 3px; }
.comment .c-text { white-space: pre-wrap; word-break: break-word; font-size: 14px; }
.comment .c-time { font-size: 11px; color: var(--muted); }
.comment .c-del { position: absolute; top: 6px; right: 6px; }
.no-comments { color: var(--muted); font-size: 13px; font-style: italic; padding: 4px 0 8px; }

.add-comment { display: flex; flex-direction: column; gap: 8px; margin-top: 6px; }
.add-comment textarea {
  width: 100%; border: 1px solid var(--border); border-radius: 9px; padding: 9px 11px;
  resize: vertical; min-height: 60px; outline: none; font-size: 14px;
}
.add-comment textarea:focus { border-color: var(--primary); }
.add-comment .row { display: flex; justify-content: flex-end; }

/* Modal */
.modal { position: fixed; inset: 0; background: rgba(15,20,30,.5); display: flex; align-items: center;
  justify-content: center; z-index: 50; padding: 20px; }
.modal-box { background: var(--surface); border-radius: 14px; width: 440px; max-width: 100%; box-shadow: var(--shadow); overflow: hidden; }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 16px 18px; border-bottom: 1px solid var(--border); }
.modal-head h3 { margin: 0; font-size: 16px; }
.modal-body { padding: 18px; display: flex; flex-direction: column; gap: 14px; }
.field { display: flex; flex-direction: column; gap: 6px; font-size: 13px; font-weight: 600; }
.field input[type=text], .field input[type=file] { padding: 9px 11px; border: 1px solid var(--border); border-radius: 9px; outline: none; font-weight: 400; }
.field input:focus { border-color: var(--primary); }
.upload-preview { min-height: 0; }
.preview-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(90px, 1fr)); gap: 8px; max-height: 260px; overflow-y: auto; }
.preview-cell { position: relative; border: 1px solid var(--border); border-radius: 8px; overflow: hidden; aspect-ratio: 1; }
.preview-cell img { width: 100%; height: 100%; object-fit: cover; display: block; }
.preview-rm {
  position: absolute; top: 3px; right: 3px; width: 20px; height: 20px; line-height: 1;
  border: none; border-radius: 50%; background: rgba(15,20,30,.72); color: #fff;
  cursor: pointer; font-size: 12px; display: flex; align-items: center; justify-content: center;
}
.preview-rm:hover { background: var(--danger); }
.modal-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 14px 18px; border-top: 1px solid var(--border); background: var(--surface-2); }

/* Lightbox */
.lightbox { position: fixed; inset: 0; background: rgba(8,10,14,.92); display: flex; align-items: center; justify-content: center; z-index: 60; padding: 30px; }
.lightbox img { max-width: 100%; max-height: 100%; object-fit: contain; }
.lightbox-close { position: absolute; top: 18px; right: 24px; font-size: 22px; color: #fff; background: transparent; border: none; cursor: pointer; }

/* Toast */
.toast { position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%);
  background: #1f2430; color: #fff; padding: 11px 18px; border-radius: 9px; z-index: 70; font-size: 14px; box-shadow: var(--shadow); }

/* Responsive */
@media (max-width: 820px) {
  .compare { grid-template-columns: 1fr; }
  .content { padding: 16px 14px 60px; }
  .topbar, .tabs { padding-left: 14px; padding-right: 14px; }
  .tabs { top: 57px; }
}
