/* Magicplan clone — shared design tokens & base styles.
   Intentionally independent of the portfolio site's own branding. */

:root {
  --mp-blue: #0a84ff;
  --mp-blue-dark: #0060df;
  --mp-blue-tint: #e8f2ff;
  --mp-red: #ff3b30;
  --mp-red-tint: #ffe9e8;
  --mp-ink: #1c1c1e;
  --mp-wall: #1c1c1e;
  --mp-gray-25: #fbfbfc;
  --mp-gray-50: #f5f5f7;
  --mp-gray-100: #eceef0;
  --mp-gray-200: #e0e1e4;
  --mp-gray-300: #c7c8cc;
  --mp-gray-400: #aeb0b6;
  --mp-gray-500: #8e8e93;
  --mp-gray-600: #6b6c70;
  --mp-gray-700: #48484a;
  --mp-white: #ffffff;
  --mp-canvas-bg: #fafafa;
  --mp-grid-dot: #dcdde1;
  --mp-shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.08);
  --mp-shadow-md: 0 4px 16px rgba(0, 0, 0, 0.12);
  --mp-shadow-lg: 0 12px 40px rgba(0, 0, 0, 0.18);
  --mp-radius-sm: 8px;
  --mp-radius-md: 12px;
  --mp-radius-lg: 16px;
  --mp-font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto,
    Helvetica, Arial, sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  height: 100%;
}

body {
  font-family: var(--mp-font);
  color: var(--mp-ink);
  background: var(--mp-gray-50);
  -webkit-font-smoothing: antialiased;
}

button {
  font-family: inherit;
  cursor: pointer;
}

a {
  color: inherit;
  text-decoration: none;
}

input,
textarea {
  font-family: inherit;
}

/* ─── Top bar (shared across pages) ───────────────────────────── */

.mp-topbar {
  display: flex;
  align-items: center;
  gap: 14px;
  height: 60px;
  padding: 0 20px;
  background: var(--mp-white);
  border-bottom: 1px solid var(--mp-gray-200);
  flex-shrink: 0;
}

.mp-icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border: none;
  background: transparent;
  border-radius: var(--mp-radius-sm);
  color: var(--mp-ink);
}

/* This rule's own `display` otherwise beats the native [hidden] UA rule
   at equal specificity — same fix as .mp-tool-btn/.mp-existence-banner
   elsewhere in this app. */
.mp-icon-btn[hidden] {
  display: none;
}

/* Figma-style hover tooltip, matching the bottom tool dock's
   [data-tooltip] treatment (see .mp-tool-btn[data-tooltip] in editor.css)
   — same dark pill, same delayed fade-in, just anchored below the button
   instead of above, since the top bar sits at the top of the screen. */
.mp-icon-btn[data-tooltip] {
  position: relative;
}

.mp-icon-btn[data-tooltip]::after {
  content: attr(data-tooltip);
  position: absolute;
  top: 40px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--mp-ink);
  color: var(--mp-white);
  font-size: 11px;
  font-weight: 500;
  padding: 4px 8px;
  border-radius: 5px;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.1s ease 0.4s;
  z-index: 80;
}

.mp-icon-btn[data-tooltip]:hover::after {
  opacity: 1;
}

.mp-icon-btn:hover {
  background: var(--mp-gray-100);
}

.mp-icon-btn:disabled {
  opacity: 0.35;
  cursor: default;
}

.mp-icon-btn:disabled:hover {
  background: transparent;
}

.mp-icon-btn svg {
  width: 20px;
  height: 20px;
}

/* A passive connectivity badge (#offline-badge), not a button — no
   pointer cursor, no hover fill, just the shared icon-btn sizing/spacing.
   Filled black (the ink color, not the blue accent) while actually shown
   as offline — this is a status indicator, not an action to take. */
.mp-icon-btn.mp-status-icon {
  cursor: default;
  color: var(--mp-gray-400);
}

.mp-icon-btn.mp-status-icon:hover {
  background: transparent;
}

.mp-icon-btn.mp-status-icon.mp-status-active {
  color: var(--mp-ink);
}

.mp-breadcrumb {
  display: flex;
  flex-direction: column;
  line-height: 1.2;
}

.mp-breadcrumb .mp-title {
  font-size: 15px;
  font-weight: 600;
}

.mp-breadcrumb .mp-subtitle {
  font-size: 12px;
  color: var(--mp-gray-500);
}

.mp-spacer {
  flex: 1;
}

/* ─── User menu (top bar, every signed-in page) ──────────────────── */

.mp-user-menu-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 5px 10px 5px 5px;
  border: none;
  border-radius: 999px;
  background: transparent;
  cursor: pointer;
  flex-shrink: 0;
}

.mp-user-menu-btn:hover {
  background: var(--mp-gray-100);
}

.mp-user-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--mp-blue);
  color: var(--mp-white);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11.5px;
  font-weight: 700;
  flex-shrink: 0;
  overflow: hidden;
}

.mp-user-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* Each demo account keeps one fixed brand color everywhere its avatar
   shows up — the signed-in user menu, the login screen's account picker,
   comment/reply avatars (css/editor.css), the project page's
   Created/Modified By avatars (css/project.css, .mp-avatar), and the
   History modal's per-entry avatar (css/editor.css, .mp-history-avatar) —
   so a person stays visually identifiable across the whole app. */
.mp-user-avatar[data-account="ines"],
.mp-comment-avatar[data-account="ines"],
.mp-comment-reply-avatar[data-account="ines"],
.mp-avatar[data-account="ines"],
.mp-history-avatar[data-account="ines"] {
  background: #f60000;
  color: #ffffff;
}

.mp-user-avatar[data-account="marek"],
.mp-comment-avatar[data-account="marek"],
.mp-comment-reply-avatar[data-account="marek"],
.mp-avatar[data-account="marek"],
.mp-history-avatar[data-account="marek"] {
  background: #006aff;
  color: #ffffff;
}

.mp-user-avatar[data-account="kai"],
.mp-comment-avatar[data-account="kai"],
.mp-comment-reply-avatar[data-account="kai"],
.mp-avatar[data-account="kai"],
.mp-history-avatar[data-account="kai"] {
  background: #ffe100;
  color: #000000;
}

.mp-user-name {
  font-size: 13px;
  font-weight: 600;
  color: var(--mp-ink);
}

@media (max-width: 560px) {
  .mp-user-name {
    display: none;
  }
}

/* ─── Buttons ──────────────────────────────────────────────────── */

.mp-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 10px 14px;
  background: var(--mp-white);
  border: 1px solid var(--mp-gray-200);
  border-radius: var(--mp-radius-md);
  box-shadow: var(--mp-shadow-sm);
  font-size: 14px;
  font-weight: 500;
  color: var(--mp-ink);
  text-align: left;
}

.mp-btn:hover {
  background: var(--mp-gray-50);
}

/* This rule's own `display` otherwise beats the native [hidden] UA rule
   at equal specificity — same fix as .mp-icon-btn/.mp-tool-btn elsewhere
   in this app. */
.mp-btn[hidden] {
  display: none;
}

.mp-btn.mp-btn-danger {
  color: var(--mp-red);
}

.mp-btn.mp-btn-danger:hover {
  background: var(--mp-red-tint);
}

.mp-btn.mp-btn-primary {
  background: var(--mp-blue);
  border-color: var(--mp-blue);
  color: var(--mp-white);
  justify-content: center;
}

.mp-btn.mp-btn-primary:hover {
  background: var(--mp-blue-dark);
}

.mp-btn:disabled {
  opacity: 0.4;
  pointer-events: none;
}

.mp-btn svg {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
}

.mp-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: 999px;
  border: 1px solid var(--mp-gray-200);
  background: var(--mp-white);
  font-size: 13px;
  font-weight: 600;
}

.mp-pill.mp-pill-active {
  background: var(--mp-ink);
  border-color: var(--mp-ink);
  color: var(--mp-white);
}

/* ─── Right detail panel (shared by editor + project pages) ──── */

.mp-panel {
  display: flex;
  flex-direction: column;
  background: var(--mp-white);
  border-left: 1px solid var(--mp-gray-200);
  height: 100%;
  overflow-y: auto;
}

.mp-panel[hidden] {
  display: none;
}

.mp-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 18px;
  border-bottom: 1px solid var(--mp-gray-100);
}

.mp-panel-header h2 {
  font-size: 16px;
  font-weight: 600;
  margin: 0;
}

.mp-tabs {
  display: flex;
  border-bottom: 1px solid var(--mp-gray-100);
  padding: 0 12px;
}

.mp-tab {
  flex: 1;
  padding: 12px 8px;
  text-align: center;
  font-size: 13px;
  font-weight: 500;
  color: var(--mp-gray-500);
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
}

.mp-tab.mp-tab-active {
  color: var(--mp-ink);
  border-bottom-color: var(--mp-blue);
}

.mp-panel-section {
  padding: 16px 18px;
  border-bottom: 1px solid var(--mp-gray-100);
}

.mp-panel-section h3 {
  margin: 0 0 10px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--mp-gray-500);
}

.mp-field {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 0;
}

.mp-field label {
  font-size: 14px;
  color: var(--mp-ink);
}

.mp-field input[type="text"],
.mp-field input[type="number"] {
  width: 130px;
  padding: 6px 10px;
  border: 1px solid var(--mp-gray-200);
  border-radius: var(--mp-radius-sm);
  font-size: 14px;
  text-align: right;
}

.mp-field select {
  width: 150px;
  padding: 6px 10px;
  border: 1px solid var(--mp-gray-200);
  border-radius: var(--mp-radius-sm);
  font-size: 14px;
  background: var(--mp-white);
  color: var(--mp-ink);
}

.mp-field .mp-value {
  font-size: 14px;
  color: var(--mp-gray-700);
}

.mp-swatch {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  border: 2px solid var(--mp-white);
  box-shadow: 0 0 0 1px var(--mp-gray-300);
  cursor: pointer;
}

.mp-color-grid {
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  gap: 6px;
  margin-top: 12px;
}

.mp-color-grid button {
  width: 100%;
  aspect-ratio: 1;
  border-radius: 6px;
  border: none;
  position: relative;
}

.mp-color-grid button.mp-color-selected::after {
  content: "";
  position: absolute;
  inset: -3px;
  border: 2px solid var(--mp-ink);
  border-radius: 8px;
}

.mp-reset-link {
  display: inline-block;
  margin-top: 12px;
  font-size: 13px;
  color: var(--mp-blue);
  background: none;
  border: none;
  font-weight: 500;
}

.mp-toggle {
  position: relative;
  width: 44px;
  height: 26px;
  border-radius: 999px;
  background: var(--mp-gray-300);
  border: none;
  flex-shrink: 0;
  transition: background 0.15s;
}

.mp-toggle::after {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--mp-white);
  box-shadow: var(--mp-shadow-sm);
  transition: left 0.15s;
}

.mp-toggle.mp-toggle-on {
  background: var(--mp-blue);
}

.mp-toggle.mp-toggle-on::after {
  left: 20px;
}

.mp-textarea {
  width: 100%;
  min-height: 70px;
  padding: 10px;
  border: 1px solid var(--mp-gray-200);
  border-radius: var(--mp-radius-sm);
  font-size: 14px;
  resize: vertical;
}

.mp-photo-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

.mp-photo-tile {
  aspect-ratio: 1;
  border: 1.5px dashed var(--mp-gray-300);
  border-radius: var(--mp-radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--mp-gray-400);
  background: var(--mp-gray-25);
}

.mp-empty-note {
  font-size: 13px;
  color: var(--mp-gray-500);
  line-height: 1.5;
}

/* ─── Dropdown menus (shared: floor/view selectors, folder picker, insert popovers) ── */

.mp-dropdown-menu {
  position: fixed;
  background: var(--mp-ink);
  border-radius: var(--mp-radius-md);
  box-shadow: var(--mp-shadow-lg);
  padding: 6px;
  min-width: 180px;
  z-index: 500;
}

.mp-dropdown-menu button {
  display: flex;
  align-items: center;
  gap: 6px;
  width: 100%;
  text-align: left;
  padding: 9px 12px;
  border: none;
  background: none;
  border-radius: var(--mp-radius-sm);
  font-size: 14px;
  color: var(--mp-white);
}

/* Fixed-width leading slot so labels line up whether or not that row is
   the checked/active one — filled in via showDropdown() in app-common.js. */
.mp-dropdown-check {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 14px;
  flex-shrink: 0;
  color: var(--mp-blue);
}

.mp-dropdown-check svg {
  width: 12px;
  height: 12px;
}

.mp-dropdown-menu button:hover {
  background: rgba(255, 255, 255, 0.1);
}

.mp-dropdown-menu button.mp-dropdown-active {
  font-weight: 600;
}

.mp-dropdown-menu button.mp-dropdown-danger {
  color: var(--mp-red);
}

.mp-dropdown-menu hr {
  border: none;
  border-top: 1px solid rgba(255, 255, 255, 0.14);
  margin: 6px 2px;
}

/* ─── Form fields (create/move modals) ──────────────────────────── */

.mp-form-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 14px;
}

.mp-form-field label {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--mp-gray-700);
}

.mp-form-field input[type="text"],
.mp-form-field input[type="email"],
.mp-form-field input[type="password"],
.mp-form-field select {
  padding: 9px 10px;
  border: 1px solid var(--mp-gray-200);
  border-radius: var(--mp-radius-sm);
  font-size: 14px;
  background: var(--mp-white);
  color: var(--mp-ink);
}

.mp-modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 6px;
}

.mp-modal-footer .mp-btn {
  width: auto;
}

/* ─── Toast ────────────────────────────────────────────────────── */

.mp-toast {
  position: fixed;
  left: 50%;
  bottom: 28px;
  transform: translateX(-50%) translateY(20px);
  background: var(--mp-ink);
  color: var(--mp-white);
  padding: 12px 20px;
  border-radius: var(--mp-radius-md);
  font-size: 13px;
  font-weight: 500;
  box-shadow: var(--mp-shadow-lg);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s, transform 0.2s;
  z-index: 500;
}

.mp-toast.mp-toast-show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* ─── Modal ────────────────────────────────────────────────────── */

.mp-modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(20, 20, 22, 0.4);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 400;
}

.mp-modal-backdrop[hidden] {
  display: none;
}

.mp-modal {
  background: var(--mp-white);
  border-radius: var(--mp-radius-lg);
  box-shadow: var(--mp-shadow-lg);
  width: min(440px, 92vw);
  max-height: 84vh;
  overflow-y: auto;
}

.mp-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 20px;
  border-bottom: 1px solid var(--mp-gray-100);
  position: sticky;
  top: 0;
  background: var(--mp-white);
}

.mp-modal-header h2 {
  margin: 0;
  font-size: 16px;
  font-weight: 700;
}

.mp-modal-body {
  padding: 18px 20px;
}

/* Groups one share option's own icon/heading/description/link — the
   editor's Share modal stacks these (Full Plan always, Flags & Comments
   only once there's something worth sending — see updateShareSections in
   editor.js). */
.mp-share-section + .mp-share-section {
  margin-top: 20px;
  padding-top: 20px;
  border-top: 1px solid var(--mp-gray-100);
}

.mp-share-section-heading {
  display: flex;
  align-items: center;
  gap: 8px;
}

.mp-share-section-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  color: var(--mp-gray-500);
  flex-shrink: 0;
}

.mp-share-section-icon svg {
  width: 100%;
  height: 100%;
}

.mp-share-section h3 {
  margin: 0;
  font-size: 13px;
  font-weight: 700;
  color: var(--mp-ink);
}

.mp-share-section .mp-empty-note {
  margin-top: 6px;
}

.mp-share-row {
  display: flex;
  gap: 8px;
  margin-top: 14px;
}

.mp-share-row input {
  flex: 1;
  min-width: 0;
  padding: 9px 10px;
  border: 1px solid var(--mp-gray-200);
  border-radius: var(--mp-radius-sm);
  font-size: 12px;
  color: var(--mp-gray-700);
}

@media (max-width: 640px) {
  .mp-topbar {
    padding: 0 12px;
  }
}

/* ─── Click-to-edit text fields (project title/address, breadcrumb) ─── */

.mp-editable {
  cursor: pointer;
  border-radius: var(--mp-radius-sm);
  transition: background 0.12s;
}

.mp-editable:hover {
  background: var(--mp-gray-100);
}

.mp-editable.mp-editing {
  background: none;
}

.mp-editable input {
  font: inherit;
  color: inherit;
  border: 1px solid var(--mp-blue);
  border-radius: var(--mp-radius-sm);
  padding: 1px 4px;
  width: 100%;
  box-sizing: border-box;
  background: var(--mp-white);
}
