/* Gman Realty — website upgrade (PRD v1.0): area units, image manager, gallery + lightbox,
   projects with sizes, My Properties and the multi-section Admin Panel. */

html.gm-lb-open { overflow: hidden; }
.mono { font-family: ui-monospace, SFMono-Regular, Consolas, monospace; font-size: 12px; word-break: break-all; }
.mt-24 { margin-top: 24px; }

/* ------------------------------------------------------------ form additions */

.area-input-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(92px, 118px);
  gap: 8px;
}

.field-help { color: var(--muted); font-size: 12.5px; }

/* --------------------------------------------------------------- image manager */

.im-root { display: grid; gap: 6px; }

.im-dropzone {
  position: relative;
  display: grid;
  justify-items: center;
  gap: 4px;
  padding: 26px 16px;
  border: 2px dashed #b9c6d6;
  border-radius: 14px;
  background: #f7fafd;
  text-align: center;
  cursor: pointer;
  transition: border-color .15s ease, background .15s ease;
}
.im-dropzone strong { color: var(--ink); }
.im-dropzone small { color: var(--muted); }
.im-drop-icon { font-size: 26px; line-height: 1; color: var(--saffron-dark); }
.im-dropzone.is-dragging { border-color: var(--saffron); background: var(--saffron-soft); }
.im-dropzone:focus-within { outline: 3px solid rgba(245, 124, 0, .35); outline-offset: 2px; }
.im-dropzone input[type="file"] {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  min-height: 0;
  padding: 0;
  border: 0;
  opacity: 0;
  cursor: pointer;
}

.im-status {
  min-height: 20px;
  padding: 6px 10px;
  border-radius: 8px;
  color: var(--muted);
  background: #f5f7fa;
  font-size: 13px;
  font-weight: 700;
}
.im-status.has-photos { color: #175c36; background: #eaf8f0; }
.im-error:empty { display: none; }

.im-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 12px;
  margin-top: 4px;
}

.im-item {
  position: relative;
  display: grid;
  margin: 0;
  overflow: hidden;
  border: 2px solid var(--line);
  border-radius: 12px;
  background: #fff;
  box-shadow: 0 6px 16px rgba(7, 26, 51, .07);
}
.im-item.is-thumbnail { border-color: var(--saffron); }
.im-item img { width: 100%; aspect-ratio: 4 / 3; object-fit: cover; background: var(--blue-soft); }

.im-order {
  position: absolute;
  top: 8px;
  left: 8px;
  display: grid;
  place-items: center;
  min-width: 26px;
  height: 26px;
  border-radius: 999px;
  color: #fff;
  background: rgba(7, 26, 51, .85);
  font-size: 12px;
  font-weight: 900;
}

.im-remove {
  position: absolute;
  top: 6px;
  right: 6px;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  min-height: 34px;
  padding: 5px 10px;
  border: 0;
  border-radius: 999px;
  color: #fff;
  background: rgba(180, 35, 24, .94);
  box-shadow: 0 6px 14px rgba(0, 0, 0, .2);
  font-size: 11.5px;
  font-weight: 800;
}
.im-remove:hover, .im-remove:focus-visible { background: #912018; }
.im-remove span:first-child { font-size: 18px; line-height: .8; }

.im-thumb-btn {
  min-height: 40px;
  padding: 8px 10px;
  border: 0;
  border-top: 1px solid var(--line);
  color: var(--ink);
  background: #f7fafd;
  font-size: 12.5px;
  font-weight: 800;
}
.im-thumb-btn:hover { background: var(--saffron-soft); color: var(--saffron-dark); }
.im-item.is-thumbnail .im-thumb-btn { color: #fff; background: var(--saffron); }

/* --------------------------------------------------------------------- gallery */

.gm-gallery { display: grid; gap: 8px; padding: 8px; background: #e8edf3; }

.gm-main {
  position: relative;
  aspect-ratio: 16 / 10;
  overflow: hidden;
  border-radius: 12px;
  background: #cfd8e3;
}
.gm-main-btn { display: block; width: 100%; height: 100%; padding: 0; border: 0; background: none; cursor: zoom-in; }
.gm-main-media { display: block; width: 100%; height: 100%; }
.gm-main img { width: 100%; height: 100%; object-fit: cover; }

.gm-main-nav {
  position: absolute;
  top: 50%;
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  margin-top: -22px;
  border: 0;
  border-radius: 999px;
  color: #fff;
  background: rgba(7, 26, 51, .6);
  font-size: 28px;
  line-height: 1;
  transition: background .15s ease;
}
.gm-main-nav:hover, .gm-main-nav:focus-visible { background: rgba(7, 26, 51, .88); }
.gm-main-nav.prev { left: 10px; }
.gm-main-nav.next { right: 10px; }

.gm-counter {
  position: absolute;
  left: 12px;
  bottom: 12px;
  padding: 4px 10px;
  border-radius: 999px;
  color: #fff;
  background: rgba(7, 26, 51, .75);
  font-size: 12.5px;
  font-weight: 800;
}
.gm-viewall {
  position: absolute;
  right: 12px;
  bottom: 12px;
  min-height: 38px;
  padding: 7px 14px;
  border: 0;
  border-radius: 999px;
  color: var(--ink);
  background: rgba(255, 255, 255, .94);
  box-shadow: 0 6px 16px rgba(0, 0, 0, .2);
  font-size: 13px;
  font-weight: 800;
}
.gm-viewall:hover { background: #fff; color: var(--saffron-dark); }
.gm-gallery.is-single .gm-main-nav,
.gm-gallery.is-single .gm-counter,
.gm-gallery.is-single .gm-thumbs { display: none; }

.gm-thumbs {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 4px;
  scroll-snap-type: x proximity;
  -webkit-overflow-scrolling: touch;
}
.gm-thumb {
  flex: 0 0 104px;
  height: 76px;
  padding: 0;
  overflow: hidden;
  border: 2px solid transparent;
  border-radius: 10px;
  background: #cfd8e3;
  opacity: .8;
  scroll-snap-align: start;
  transition: opacity .15s ease, border-color .15s ease;
}
.gm-thumb img { width: 100%; height: 100%; object-fit: cover; }
.gm-thumb:hover { opacity: 1; }
.gm-thumb.is-active { border-color: var(--saffron); opacity: 1; }

.gm-image-missing, .image-placeholder.gm-missing {
  display: grid;
  place-items: center;
  width: 100%;
  height: 100%;
  min-height: 160px;
  color: var(--muted);
  background: var(--blue-soft);
  font-weight: 700;
}

/* -------------------------------------------------------------------- lightbox */

.gm-lightbox {
  position: fixed;
  inset: 0;
  z-index: 2000;
  display: flex;
  flex-direction: column;
  color: #fff;
  background: #050c18;
}
.gm-lightbox[hidden] { display: none; }

.gm-lb-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 14px;
  padding-top: max(10px, env(safe-area-inset-top));
}
.gm-lb-count { font-size: 14px; font-weight: 800; letter-spacing: .04em; }
.gm-lb-tools { display: flex; gap: 8px; }
.gm-lb-tools button, .gm-lb-nav {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  padding: 0;
  border: 0;
  border-radius: 999px;
  color: #fff;
  background: rgba(255, 255, 255, .14);
  font-size: 22px;
  line-height: 1;
}
.gm-lb-tools button:hover, .gm-lb-nav:hover, .gm-lb-tools button:focus-visible, .gm-lb-nav:focus-visible { background: rgba(255, 255, 255, .28); }

.gm-lb-stage {
  display: flex;
  flex: 1;
  align-items: center;
  justify-content: center;
  min-height: 0;
  overflow: hidden;
  touch-action: none;
  cursor: zoom-in;
}
.gm-lb-stage.is-zoomed { cursor: grab; }
.gm-lb-img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  transform-origin: center center;
  transition: transform .14s ease;
  user-select: none;
  -webkit-user-drag: none;
}
.gm-lb-stage.is-zoomed .gm-lb-img { transition: none; }
/* The site-wide `img { display: block }` would otherwise beat the [hidden] attribute. */
.gm-lb-img[hidden], .gm-lb-error[hidden] { display: none !important; }
.gm-lb-error { padding: 24px; color: rgba(255, 255, 255, .8); font-size: 15px; font-weight: 700; text-align: center; }

.gm-lb-nav { position: absolute; top: 50%; z-index: 3; margin-top: -22px; font-size: 32px; }
.gm-lb-nav.prev { left: 12px; }
.gm-lb-nav.next { right: 12px; }
.gm-lightbox.is-single .gm-lb-nav, .gm-lightbox.is-single .gm-lb-strip { display: none; }

.gm-lb-caption { padding: 6px 16px; color: rgba(255, 255, 255, .75); font-size: 13.5px; text-align: center; }
.gm-lb-strip {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  padding: 8px 12px;
  padding-bottom: max(8px, env(safe-area-inset-bottom));
  background: rgba(0, 0, 0, .35);
}
.gm-lb-strip button {
  flex: 0 0 72px;
  height: 52px;
  padding: 0;
  overflow: hidden;
  border: 2px solid transparent;
  border-radius: 8px;
  background: #1c2a3d;
  opacity: .6;
}
.gm-lb-strip button.is-active { border-color: var(--saffron); opacity: 1; }
.gm-lb-strip img { width: 100%; height: 100%; object-fit: cover; }

/* ------------------------------------------------------------- details pages */

.detail-rows { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 28px; margin: 0; }
.detail-row { display: flex; align-items: baseline; justify-content: space-between; gap: 14px; padding: 11px 0; border-bottom: 1px solid var(--line); }
.detail-row dt { color: var(--muted); font-size: 13.5px; font-weight: 700; }
.detail-row dd { margin: 0; color: var(--ink); font-weight: 800; text-align: right; overflow-wrap: anywhere; }

.badge.project { color: #fff; background: #174b84; }
.badge.brochure-badge { color: var(--ink); background: #fff; }

.size-tabs { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 18px; }
.size-tab {
  display: grid;
  gap: 2px;
  min-width: 132px;
  padding: 12px 16px;
  border: 2px solid var(--line);
  border-radius: 12px;
  background: #fff;
  color: var(--ink);
  text-align: left;
  transition: border-color .15s ease, background .15s ease;
}
.size-tab strong { font-size: 1.02rem; }
.size-tab span { color: var(--muted); font-size: 13px; font-weight: 700; }
.size-tab em { color: var(--saffron-dark); font-size: 13px; font-style: normal; font-weight: 800; }
.size-tab:hover { border-color: var(--saffron); }
.size-tab[aria-selected="true"] { border-color: var(--saffron); background: var(--saffron-soft); }
.size-panel { display: grid; gap: 14px; }
.size-note { margin: 0; color: var(--muted); }
.size-gallery-title { margin: 6px 0 0; font-size: 1.05rem; }
.size-empty { margin: 0; padding: 18px; border: 1px dashed var(--line); border-radius: 10px; text-align: center; }
.size-panel .gm-gallery { border-radius: 14px; }
.brochure-missing { padding: 10px 12px; border-radius: 10px; color: var(--muted); background: var(--surface-2); font-size: 14px; text-align: center; }

/* ------------------------------------------------------------- My Properties */

.mp-list { display: grid; gap: 16px; }
.mp-card {
  display: grid;
  grid-template-columns: 170px minmax(0, 1fr) auto;
  gap: 18px;
  align-items: center;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
  box-shadow: var(--shadow-sm);
}
.mp-thumb { height: 120px; overflow: hidden; border-radius: 10px; background: var(--surface-2); }
.mp-thumb img { width: 100%; height: 100%; object-fit: cover; }
.mp-body h3 { margin: 8px 0 4px; font-size: 1.08rem; }
.mp-note { margin: 6px 0 0; color: var(--muted); font-size: 13.5px; }
.mp-actions { display: flex; flex-direction: column; gap: 8px; min-width: 150px; }
.mp-editor { display: grid; gap: 14px; }
.mp-editor h2 { margin: 6px 0 0; }

/* --------------------------------------------------------------- form layout */

.pf-form { display: grid; gap: 20px; }
.pf-section { min-width: 0; margin: 0; padding: 20px 22px; border: 1px solid var(--line); border-radius: var(--radius); background: #fff; box-shadow: var(--shadow-sm); }
.pf-section legend { padding: 0 8px; color: var(--ink); font-size: 1.02rem; font-weight: 800; }
.pf-sizes-head h2 { margin: 6px 0 4px; font-size: 1.3rem; }
.pf-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 10px; }
.pf-actions-start { justify-content: flex-start; }
.pf-status:empty { display: none; }
.size-block-head { display: flex; justify-content: flex-end; margin-bottom: 8px; }
.size-block + .size-block { margin-top: 4px; }
.brochure-current { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 12px; padding: 10px 14px; border-radius: 10px; background: var(--blue-soft); }
.brochure-current a { color: var(--ink-2); font-weight: 800; overflow-wrap: anywhere; }

/* --------------------------------------------------------------- admin layout */

.admin-layout { display: grid; grid-template-columns: 230px minmax(0, 1fr); gap: 28px; align-items: start; }
.admin-content { min-width: 0; }
.admin-sidebar {
  position: sticky;
  top: 96px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
  box-shadow: var(--shadow-sm);
}
.admin-nav { display: grid; gap: 4px; }
.admin-nav-group { display: grid; gap: 2px; margin-top: 10px; padding-top: 10px; border-top: 1px solid var(--line); }
.admin-nav-heading { padding: 4px 12px; color: var(--muted); font-size: 11px; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; }
.admin-nav-link { display: block; padding: 9px 12px; border-radius: 9px; color: var(--ink-2); font-size: 14px; font-weight: 700; }
.admin-nav-link:hover { background: var(--blue-soft); }
.admin-nav-link.active { color: #fff; background: var(--ink); }

.admin-stats { grid-template-columns: repeat(3, minmax(0, 1fr)); }
a.admin-stat-card { display: block; color: inherit; transition: transform .15s ease, box-shadow .15s ease; }
a.admin-stat-card:hover { transform: translateY(-2px); box-shadow: var(--shadow); }
.admin-quick h2 { margin: 0 0 12px; font-size: 1.15rem; }
.admin-quick-grid { display: flex; flex-wrap: wrap; gap: 10px; }

.admin-table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: 12px; background: #fff; box-shadow: var(--shadow-sm); }
.admin-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.admin-table th { padding: 12px 14px; color: var(--muted); background: var(--surface-2); font-size: 12px; font-weight: 800; letter-spacing: .05em; text-align: left; text-transform: uppercase; }
.admin-table td { padding: 12px 14px; border-top: 1px solid var(--line); vertical-align: middle; overflow-wrap: anywhere; }
.admin-table-actions { display: flex; flex-wrap: wrap; gap: 6px; }
.admin-users-toolbar { grid-template-columns: minmax(240px, 1fr); }
.admin-user-listings { display: grid; gap: 8px; margin: 0; padding: 0; list-style: none; }
.admin-user-listings a { color: var(--ink-2); font-weight: 700; text-decoration: underline; }

.admin-modal { position: fixed; inset: 0; z-index: 1500; display: grid; place-items: start center; padding: 24px 16px; overflow-y: auto; background: rgba(7, 26, 51, .55); }
.admin-modal-card { width: min(100%, 640px); margin: auto; border-radius: var(--radius); background: #fff; box-shadow: var(--shadow); }
.admin-modal-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 16px 20px; border-bottom: 1px solid var(--line); }
.admin-modal-head h2 { margin: 0; font-size: 1.15rem; overflow-wrap: anywhere; }
.admin-modal-close { width: 38px; height: 38px; border: 0; border-radius: 999px; color: var(--ink); background: var(--surface-2); font-size: 16px; }
.admin-modal-body { display: grid; gap: 16px; padding: 20px; }

/* ------------------------------------------------------------------ responsive */

@media (max-width: 900px) {
  .admin-layout { grid-template-columns: minmax(0, 1fr); gap: 18px; }
  .admin-sidebar { position: static; padding: 8px; }
  .admin-nav { display: flex; gap: 6px; overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .admin-nav-group { display: flex; align-items: center; gap: 6px; margin-top: 0; padding-top: 0; border-top: 0; }
  .admin-nav-heading { display: none; }
  .admin-nav-link { flex: 0 0 auto; padding: 9px 14px; border: 1px solid var(--line); border-radius: 999px; white-space: nowrap; }
  .admin-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 760px) {
  .detail-rows { grid-template-columns: minmax(0, 1fr); }
  .mp-card { grid-template-columns: minmax(0, 1fr); }
  .mp-thumb { height: 180px; }
  .mp-actions { flex-direction: row; flex-wrap: wrap; }
  .mp-actions .btn { flex: 1 1 auto; }
  .pf-section { padding: 16px; }
  .pf-actions { flex-direction: column-reverse; }
  .pf-actions .btn { width: 100%; }
  .im-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .im-remove-text { display: none; }
  .im-remove { width: 36px; height: 36px; justify-content: center; padding: 0; }

  .admin-table thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
  .admin-table, .admin-table tbody, .admin-table tr, .admin-table td { display: block; width: 100%; }
  .admin-table tr { border-top: 1px solid var(--line); padding: 8px 0; }
  .admin-table td { display: flex; justify-content: space-between; gap: 14px; border-top: 0; padding: 6px 14px; text-align: right; }
  .admin-table td::before { content: attr(data-label); color: var(--muted); font-size: 12px; font-weight: 800; text-align: left; text-transform: uppercase; }
  .admin-table td.admin-table-actions { justify-content: flex-start; }
  .admin-table td.admin-table-actions::before { display: none; }
}

@media (max-width: 600px) {
  .gm-main { aspect-ratio: 4 / 3; }
  .gm-main-nav { width: 40px; height: 40px; margin-top: -20px; font-size: 24px; }
  .gm-thumb { flex-basis: 84px; height: 62px; }
  .gm-viewall { padding: 6px 12px; font-size: 12px; }
  .gm-lb-nav { width: 40px; height: 40px; margin-top: -20px; }
  .gm-lb-strip button { flex-basis: 56px; height: 42px; }
  .size-tab { flex: 1 1 calc(50% - 10px); min-width: 0; }
  .admin-modal { padding: 12px 8px; }
  .admin-modal-body { padding: 16px; }
}

@media (prefers-reduced-motion: reduce) {
  .gm-lb-img, .size-tab, .gm-thumb, a.admin-stat-card { transition: none; }
}

/* ------------------------------------------------- form alignment + mobile fixes */

/* Rows no longer stretch short fields to match tall neighbours, so inputs line up on one baseline. */
.form-grid { align-items: start; }
.form-grid > *, .form-group { min-width: 0; }
.form-group { align-content: start; }
.form-group > label, .form-group > .field-label { line-height: 1.35; }
.form-group .price-in-words { min-height: 40px; }
.check-option { min-width: 0; overflow-wrap: anywhere; }
.pf-form, .pf-section, fieldset.pf-section { min-width: 0; max-width: 100%; }
.pf-section .price-in-words { margin-top: 2px; }

@media (max-width: 767px) {
  .form-grid, .pf-form, .checkbox-grid, .summary-list { grid-template-columns: minmax(0, 1fr); }
  .form-grid .span-2, .form-grid > .form-group { grid-column: auto; min-width: 0; }
  .form-group input, .form-group select, .form-group textarea { max-width: 100%; box-sizing: border-box; }
  .area-input-row { grid-template-columns: minmax(0, 1fr) minmax(84px, 108px); }
  .form-card, .pf-section, .size-block { overflow: visible; }
  .size-block-head { justify-content: flex-start; }
}

/* ---------------------------------------------------------- misc additions */

.details-section p + p { margin-top: 12px; }
.size-tab-thumb { width: 100%; height: 64px; margin-bottom: 6px; border-radius: 8px; object-fit: cover; }
.detail-rows dd { overflow-wrap: anywhere; }

/* My Profile: keep each label next to its value instead of at opposite edges. */
.profile-details { grid-template-columns: minmax(0, 1fr); gap: 0; margin: 12px 0 18px; max-width: 560px; }
.profile-details .detail-row { display: grid; grid-template-columns: 110px minmax(0, 1fr); justify-content: start; gap: 16px; }
.profile-details .detail-row dd { text-align: left; margin: 0; }
