/* Catppuccin Mocha theme */
:root {
  --bg: #1e1e2e;
  --bg2: #181825;
  --bg3: #313244;
  --bg4: #45475a;
  --text: #cdd6f4;
  --subtext: #a6adc8;
  --muted: #6c7086;
  --accent: #89b4fa;
  --accent2: #f5c2e7;
  --green: #a6e3a1;
  --yellow: #f9e2af;
  --red: #f38ba8;
  --orange: #fab387;
  --teal: #94e2d5;
  --border: #45475a;
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; height: 100%; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg); color: var(--text);
  overflow: hidden;
}
.hidden { display: none !important; }

/* Login */
.login-view {
  position: fixed; inset: 0;
  display: flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, var(--bg) 0%, var(--bg2) 100%);
}
.login-card {
  background: var(--bg2);
  padding: 40px;
  border-radius: 12px;
  border: 1px solid var(--border);
  width: 100%; max-width: 380px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.4);
}
.login-card h1 {
  margin: 0 0 4px;
  color: var(--accent); font-size: 32px;
}
.login-card .muted { color: var(--muted); font-size: 13px; margin: 0 0 24px; }
.login-card label {
  display: block; margin-bottom: 14px; font-size: 13px; color: var(--subtext);
}
.login-card input {
  display: block; width: 100%;
  padding: 10px 12px; margin-top: 4px;
  background: var(--bg3); color: var(--text);
  border: 1px solid var(--border); border-radius: 6px;
  font-size: 14px;
}
.login-card input:focus { outline: none; border-color: var(--accent); }
.login-card button {
  width: 100%; padding: 10px;
  background: var(--accent); color: var(--bg);
  border: none; border-radius: 6px;
  font-weight: 600; cursor: pointer;
  margin-top: 8px;
}
.login-card button:hover { background: #74c7ec; }
.login-error {
  background: rgba(243, 139, 168, 0.15);
  color: var(--red);
  padding: 8px 12px; border-radius: 6px;
  margin-top: 12px; font-size: 13px;
}

/* Header */
.main-view { display: flex; flex-direction: column; height: 100vh; }
header {
  background: var(--bg2);
  border-bottom: 1px solid var(--border);
  padding: 10px 18px;
  display: flex; align-items: center; gap: 14px;
  flex-shrink: 0;
}
header h1 {
  margin: 0; font-size: 18px; color: var(--accent);
  cursor: pointer; user-select: none;
}
#search {
  background: var(--bg3); color: var(--text);
  border: 1px solid var(--border); border-radius: 6px;
  padding: 7px 12px; font-size: 14px; flex: 1; max-width: 360px;
}
#search:focus { outline: none; border-color: var(--accent); }
.header-stats { color: var(--muted); font-size: 12px; flex: 1; }
.header-user { display: flex; align-items: center; gap: 8px; }
.header-user span { color: var(--subtext); font-size: 13px; }
.header-user button {
  background: var(--bg3); color: var(--text);
  border: 1px solid var(--border); border-radius: 6px;
  padding: 6px 10px; font-size: 12px; cursor: pointer;
}
.header-user button:hover { background: var(--bg4); }
#new-project-btn { background: var(--accent); color: var(--bg); border-color: var(--accent); font-weight: 600; }
#new-project-btn:hover { background: #74c7ec; }

/* Layout */
.layout { display: flex; flex: 1; overflow: hidden; }
#sidebar {
  width: 320px;
  background: var(--bg2);
  border-right: 1px solid var(--border);
  overflow-y: auto;
  flex-shrink: 0;
}
#content {
  flex: 1; overflow-y: auto;
  padding: 24px 32px 80px;
}
#content.empty {
  display: flex; align-items: center; justify-content: center;
  color: var(--muted); font-size: 18px;
}

/* Project cards */
.project-card {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  transition: background 0.1s;
}
.project-card:hover { background: var(--bg3); }
.project-card.active {
  background: var(--bg3);
  border-left: 3px solid var(--accent);
}
.project-card .name { font-weight: 600; font-size: 14px; margin-bottom: 4px; }
.project-card .meta { color: var(--muted); font-size: 12px; }
.project-card .meta .badge {
  display: inline-block; background: var(--bg3);
  padding: 2px 6px; border-radius: 4px; margin-right: 4px;
  color: var(--subtext); font-size: 11px;
}
.project-card .meta .badge.photos { color: var(--accent); }
.project-card .meta .badge.tasks { color: var(--yellow); }
.project-card .meta .badge.comments { color: var(--accent2); }

/* Project view */
.project-header {
  margin-bottom: 24px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--border);
}
.project-header h2 {
  margin: 0 0 8px;
  color: var(--accent); font-size: 24px;
  display: flex; align-items: center; gap: 8px;
}
.project-header h2 .edit-icon {
  font-size: 14px; cursor: pointer; color: var(--muted);
  background: var(--bg3); padding: 2px 8px; border-radius: 4px;
}
.project-header h2 .edit-icon:hover { color: var(--accent); background: var(--bg4); }
.project-header .addr { color: var(--subtext); font-size: 14px; margin-bottom: 8px; }
.project-header .info-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 8px; margin-top: 12px; font-size: 13px;
}
.info-grid .label { color: var(--muted); }
.info-grid .value { color: var(--text); }

/* Sections */
.section { margin-top: 28px; }
.section h3 {
  color: var(--accent2); margin: 0 0 12px; font-size: 16px;
  border-bottom: 1px solid var(--border); padding-bottom: 6px;
  display: flex; align-items: center; gap: 8px;
}
.section h3 .add-btn {
  background: var(--bg3); color: var(--text);
  border: 1px solid var(--border); border-radius: 4px;
  padding: 2px 8px; font-size: 11px; cursor: pointer;
}
.section h3 .add-btn:hover { background: var(--bg4); }

/* Notes */
.notes {
  background: var(--bg2); padding: 16px; border-radius: 6px;
  line-height: 1.6; font-size: 14px;
  position: relative;
  white-space: pre-wrap;
}
.notes-edit {
  background: var(--bg2); padding: 0; border-radius: 6px;
}
.notes-edit textarea {
  width: 100%;
  background: var(--bg2); color: var(--text);
  border: 1px solid var(--accent); border-radius: 6px;
  padding: 12px; font: inherit;
  min-height: 200px; resize: vertical;
}
.notes-edit-actions { margin-top: 8px; display: flex; gap: 8px; }
.notes:hover .edit-link { opacity: 1; }
.edit-link {
  position: absolute; top: 8px; right: 8px;
  font-size: 11px; color: var(--muted); cursor: pointer;
  opacity: 0.4;
  background: var(--bg3); padding: 3px 8px; border-radius: 3px;
}
.edit-link:hover { color: var(--accent); }

/* Comments */
.comment {
  background: var(--bg2); border-left: 3px solid var(--accent2);
  padding: 8px 14px; margin-bottom: 8px; border-radius: 0 6px 6px 0;
  font-size: 13px;
  position: relative;
}
.comment .who { font-weight: 600; color: var(--accent2); }
.comment .when { color: var(--muted); font-size: 11px; margin-left: 6px; }
.comment .text { margin-top: 4px; white-space: pre-wrap; }
.comment .delete {
  position: absolute; top: 6px; right: 8px;
  background: none; border: none; color: var(--muted);
  font-size: 14px; cursor: pointer; opacity: 0;
}
.comment:hover .delete { opacity: 0.5; }
.comment .delete:hover { color: var(--red); opacity: 1; }
.comment-form {
  display: flex; gap: 8px; margin-top: 8px;
}
.comment-form textarea {
  flex: 1;
  background: var(--bg3); color: var(--text);
  border: 1px solid var(--border); border-radius: 6px;
  padding: 8px 12px; font-family: inherit; font-size: 13px;
  min-height: 36px; resize: vertical;
}

/* Checklists */
.checklist {
  background: var(--bg2); border-radius: 6px; padding: 12px 16px; margin-bottom: 12px;
}
.checklist .cl-header {
  display: flex; align-items: center; justify-content: space-between;
  font-weight: 600; color: var(--yellow); margin-bottom: 8px; font-size: 14px;
}
.checklist .cl-header .name { flex: 1; cursor: text; }
.checklist .cl-header .actions { display: flex; gap: 4px; }
.checklist .cl-header .actions button {
  background: none; border: none; color: var(--muted); cursor: pointer; font-size: 12px;
}
.checklist .cl-header .actions button:hover { color: var(--text); }
.checklist .task {
  padding: 6px 0; font-size: 13px;
  display: flex; align-items: flex-start; gap: 8px;
}
.checklist .task input[type=checkbox] { margin-top: 3px; cursor: pointer; }
.checklist .task .title-text {
  flex: 1; cursor: text;
}
.checklist .task.done .title-text { color: var(--muted); text-decoration: line-through; }
.checklist .task .delete {
  background: none; border: none; color: var(--muted);
  cursor: pointer; opacity: 0;
}
.checklist .task:hover .delete { opacity: 0.5; }
.checklist .task .delete:hover { color: var(--red); opacity: 1; }
.checklist .add-task {
  display: flex; gap: 8px; margin-top: 8px;
  padding-top: 8px; border-top: 1px dashed var(--border);
}
.checklist .add-task input {
  flex: 1; background: var(--bg3); border: 1px solid var(--border);
  color: var(--text); border-radius: 4px; padding: 6px 10px; font-size: 13px;
}

/* Photos */
.date-group { margin-top: 16px; }
.date-group .date-header {
  color: var(--orange); font-weight: 600; font-size: 14px;
  margin-bottom: 10px; padding-bottom: 4px;
  border-bottom: 1px dashed var(--border);
}
.photo-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 12px;
}
.photo {
  background: var(--bg2); border-radius: 6px; overflow: hidden;
  cursor: pointer; transition: transform 0.1s;
}
.photo:hover { transform: scale(1.02); }
.photo img {
  width: 100%; height: 200px; object-fit: cover;
  display: block; background: #000;
}
.photo .meta { padding: 8px 10px; font-size: 11px; }
.photo .meta .by { color: var(--accent); }
.photo .meta .when { color: var(--muted); }
.photo .meta .caption { color: var(--text); margin-top: 4px; font-size: 12px; }
.photo .meta .comments { color: var(--accent2); margin-top: 4px; }

.photo-upload {
  border: 2px dashed var(--border);
  border-radius: 6px;
  padding: 30px; text-align: center;
  margin-bottom: 16px; cursor: pointer;
  color: var(--muted); transition: all 0.15s;
}
.photo-upload:hover, .photo-upload.dragover {
  border-color: var(--accent); color: var(--accent); background: var(--bg2);
}
.photo-upload input { display: none; }

/* Lightbox */
#lightbox {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.94); z-index: 100;
  display: flex; align-items: center; justify-content: center;
  flex-direction: column;
  padding: 60px 80px 40px;
}
#lightbox.hidden { display: none !important; }
#lb-img { max-width: 100%; max-height: 60vh; object-fit: contain; }
.lb-meta {
  color: var(--text); margin-top: 12px;
  text-align: center; max-width: 80vw;
  background: rgba(0,0,0,0.5); padding: 8px 16px; border-radius: 6px;
  font-size: 13px;
}
.lb-actions {
  display: flex; gap: 8px; margin-top: 8px;
}
.lb-actions button {
  background: var(--bg3); color: var(--text);
  border: 1px solid var(--border); border-radius: 4px;
  padding: 5px 10px; font-size: 12px; cursor: pointer;
}
.lb-actions button:hover { background: var(--bg4); }
.lb-actions button.danger { color: var(--red); }
.lb-actions button.danger:hover { background: var(--red); color: var(--bg); }
.lb-comments {
  margin-top: 12px; max-width: 600px; width: 100%;
  max-height: 30vh; overflow-y: auto;
}
.lb-comments .c {
  color: var(--text); font-size: 13px; padding: 4px 8px;
  background: rgba(255,255,255,0.04); margin-bottom: 4px; border-radius: 4px;
}
.lb-comments .c .who { color: var(--accent2); font-weight: 600; }

#lightbox .lb-close, #lightbox .lb-nav {
  position: absolute; color: var(--text); cursor: pointer;
  background: rgba(0,0,0,0.5); border: 1px solid rgba(255,255,255,0.15);
}
.lb-close {
  top: 20px; right: 20px;
  font-size: 28px; width: 44px; height: 44px;
  border-radius: 50%; line-height: 1;
}
.lb-nav {
  top: 50%; transform: translateY(-50%);
  font-size: 36px; width: 56px; height: 56px;
  border-radius: 50%;
}
.lb-prev { left: 20px; }
.lb-next { right: 20px; }
.lb-close:hover, .lb-nav:hover { background: rgba(0,0,0,0.8); }

/* Modal */
.modal {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.7); z-index: 200;
  display: flex; align-items: center; justify-content: center;
  padding: 20px;
}
.modal.hidden { display: none !important; }
.modal-card {
  background: var(--bg2);
  padding: 24px; border-radius: 8px;
  border: 1px solid var(--border);
  width: 100%; max-width: 500px;
  max-height: 80vh; overflow-y: auto;
}
.modal-card h2 { margin: 0 0 16px; color: var(--accent); }
.modal-card label { display: block; margin-bottom: 10px; font-size: 13px; color: var(--subtext); }
.modal-card input, .modal-card textarea, .modal-card select {
  width: 100%; padding: 8px 12px; margin-top: 4px;
  background: var(--bg3); color: var(--text);
  border: 1px solid var(--border); border-radius: 4px;
  font-size: 14px; font-family: inherit;
}
.modal-card input:focus, .modal-card textarea:focus { outline: none; border-color: var(--accent); }
.modal-card .actions {
  display: flex; gap: 8px; justify-content: flex-end;
  margin-top: 16px;
}
.modal-card button {
  background: var(--bg3); color: var(--text);
  border: 1px solid var(--border); border-radius: 4px;
  padding: 8px 14px; font-size: 13px; cursor: pointer;
}
.modal-card button.primary { background: var(--accent); color: var(--bg); border-color: var(--accent); font-weight: 600; }
.modal-card button.primary:hover { background: #74c7ec; }
.modal-card button.danger { color: var(--red); }

/* Toast */
.toast {
  position: fixed; bottom: 60px; left: 50%; transform: translateX(-50%);
  background: var(--bg3); color: var(--text);
  border: 1px solid var(--border); border-radius: 6px;
  padding: 8px 16px; font-size: 13px;
  z-index: 300;
  box-shadow: 0 4px 20px rgba(0,0,0,0.4);
}
.toast.error { border-color: var(--red); color: var(--red); }
.toast.success { border-color: var(--green); color: var(--green); }

/* Inline edit input */
.inline-edit {
  background: var(--bg3); color: var(--text);
  border: 1px solid var(--accent); border-radius: 4px;
  padding: 4px 8px; font: inherit;
}

button { font-family: inherit; }
button.primary { background: var(--accent); color: var(--bg); border-color: var(--accent); font-weight: 600; }

/* Review queue */
.review-modal-wrap { display: flex; flex-direction: column; max-height: 80vh; }
.review-list { overflow-y: auto; flex: 1; max-height: 60vh; padding-right: 4px; }
.review-bulkbar {
  display: flex; align-items: center; gap: 12px;
  background: var(--bg3); padding: 10px 14px;
  border-radius: 6px; margin-bottom: 12px;
  position: sticky; top: 0; z-index: 5;
  border: 1px solid var(--border);
  transition: border-color 0.15s;
}
.review-bulkbar.active { border-color: var(--accent); }
.review-bulkbar input[type=checkbox] { transform: scale(1.2); }
.review-item {
  display: flex; gap: 12px; align-items: flex-start;
  background: var(--bg3); border-radius: 6px;
  padding: 10px; margin-bottom: 10px;
  border: 2px solid transparent;
  transition: border-color 0.1s, background 0.1s;
}
.review-item.selected { border-color: var(--accent); background: var(--bg4); }
.review-item img {
  width: 100px; height: 100px; object-fit: cover;
  border-radius: 4px; cursor: pointer;
  background: #000; flex-shrink: 0;
}
.review-check {
  margin-top: 4px; transform: scale(1.3); cursor: pointer; flex-shrink: 0;
}
.review-meta { flex: 1; font-size: 13px; min-width: 0; }

#review-queue-btn { background: var(--orange); color: var(--bg); border-color: var(--orange); font-weight: 600; }
#review-queue-btn:hover { background: #f5a978; }

/* Make modal wider when it's the review queue */
.modal-card:has(.review-modal-wrap) {
  max-width: 900px;
}

/* User mgmt table */
.user-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.user-table th, .user-table td { padding: 8px; text-align: left; border-bottom: 1px solid var(--border); }
.user-table th { color: var(--muted); font-weight: normal; font-size: 11px; text-transform: uppercase; }
.user-table .role-admin { color: var(--accent); font-weight: 600; }

/* Scroll bars */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: var(--bg2); }
::-webkit-scrollbar-thumb { background: var(--bg3); border-radius: 5px; }
::-webkit-scrollbar-thumb:hover { background: var(--border); }

.empty-section { color: var(--muted); font-style: italic; font-size: 13px; padding: 8px 0; }
