/* ═══════════════════════════════════════
   FIELD SQUARE — layout.css
   App screens, grid, canvas/panel split
═══════════════════════════════════════ */

/* ── SCREENS ── */
.screen {
  display: none;
  min-height: 100vh;
}
.screen.active {
  display: flex;
  flex-direction: column;
}

/* ── AUTH SCREEN ── */
#screen-auth {
  align-items: center;
  justify-content: center;
  background: var(--surface2);
  padding: 24px;
}

.auth-card {
  width: 100%;
  max-width: 400px;
  background: var(--surface);
  border: 1px solid var(--border2);
  border-radius: var(--radius-xl);
  overflow: hidden;
  box-shadow: var(--shadow-lg);
}

.auth-header {
  background: var(--ink);
  padding: 32px 32px 28px;
  text-align: center;
  position: relative;
}

.auth-header::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 24px;
  right: 24px;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--gold), transparent);
}

.auth-mark {
  width: 56px;
  height: 56px;
  border-radius: 14px;
  background: var(--gold-p);
  border: 1px solid var(--gold-b);
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 16px;
}

.auth-mark span {
  font-family: var(--mono);
  font-size: 18px;
  font-weight: 500;
  color: var(--gold);
}

.auth-app-name {
  font-size: 22px;
  font-weight: 600;
  color: white;
  margin-bottom: 4px;
}

.auth-tagline {
  font-size: 12px;
  color: rgba(255, 255, 255, 0.4);
  letter-spacing: 0.3px;
}

.auth-body {
  padding: 28px 32px 32px;
}

/* ── PROJECTS SCREEN ── */
#screen-projects {
  background: var(--surface2);
  flex-direction: column;
}

.projects-topbar {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 0 24px;
  height: 60px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  position: sticky;
  top: 0;
  z-index: 10;
}

.brand-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.brand-mark {
  width: 34px;
  height: 34px;
  border-radius: 9px;
  background: var(--ink);
  border: 1px solid var(--gold-b);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.brand-mark span {
  font-family: var(--mono);
  font-size: 12px;
  font-weight: 500;
  color: var(--gold);
}

.brand-name {
  font-size: 16px;
  font-weight: 600;
  color: var(--ink);
}

.brand-sub {
  font-size: 11px;
  color: var(--muted);
}

.projects-content {
  flex: 1;
  padding: 28px 24px;
  max-width: 1200px;
  margin: 0 auto;
  width: 100%;
}

.projects-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 24px;
  flex-wrap: wrap;
}

.projects-search {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--surface);
  border: 1px solid var(--border2);
  border-radius: var(--radius);
  padding: 7px 12px;
  width: 260px;
}

.projects-search input {
  border: none;
  background: none;
  font-size: 13px;
  color: var(--text);
  flex: 1;
  min-width: 0;
}

.projects-search input::placeholder {
  color: var(--muted2);
}

.projects-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 16px;
}

.project-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  cursor: pointer;
  transition: box-shadow var(--t-fast), transform var(--t-fast), border-color var(--t-fast);
}

.project-card:hover {
  box-shadow: var(--shadow);
  transform: translateY(-1px);
  border-color: var(--border2);
}

.project-thumb {
  height: 140px;
  background: var(--surface2);
  border-bottom: 1px solid var(--border);
  position: relative;
  overflow: hidden;
}

.project-thumb canvas {
  width: 100%;
  height: 100%;
}

.project-thumb-empty {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--muted3);
  flex-direction: column;
  gap: 8px;
}

.project-card-body {
  padding: 14px 16px;
}

.project-name {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 4px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.project-meta {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 11px;
  color: var(--muted);
  margin-bottom: 10px;
}

.project-total {
  font-family: var(--mono);
  font-size: 13px;
  font-weight: 500;
  color: var(--ink);
}

.project-card-actions {
  display: flex;
  gap: 6px;
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid var(--border);
}

.projects-empty {
  grid-column: 1 / -1;
  text-align: center;
  padding: 60px 20px;
  color: var(--muted);
}

.projects-empty svg {
  margin: 0 auto 16px;
  color: var(--muted3);
}

/* ── APP SCREEN ── */
#screen-app {
  flex-direction: column;
  background: var(--surface2);
}

.app-shell {
  flex: 1;
  display: grid;
  grid-template-columns: 1fr 360px;
  min-height: calc(100vh - 52px);
}

/* ── TOP BAR ── */
.topbar {
  height: 52px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 14px;
  gap: 8px;
  position: sticky;
  top: 0;
  z-index: 20;
}

.topbar-left {
  display: flex;
  align-items: center;
  gap: 8px;
}

.topbar-center {
  display: flex;
  align-items: center;
  gap: 4px;
  flex: 1;
  justify-content: center;
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 6px;
}

/* ── CANVAS SIDE ── */
.canvas-side {
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border-right: 1px solid var(--border);
  overflow: hidden;
}

.canvas-wrap {
  flex: 1;
  position: relative;
  overflow: hidden;
  background: var(--surface3);
  min-height: 300px;
}

#mainCanvas {
  display: block;
  touch-action: none;
}

.canvas-overlay {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.snap-dot {
  position: absolute;
  width: 10px;
  height: 10px;
  border: 2px solid var(--gold);
  border-radius: 50%;
  transform: translate(-50%, -50%);
  display: none;
  pointer-events: none;
  transition: opacity 0.1s;
}

.canvas-hint {
  position: absolute;
  bottom: 10px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 11px;
  font-weight: 500;
  color: var(--muted);
  background: var(--surface);
  padding: 5px 12px;
  border-radius: 20px;
  border: 1px solid var(--border);
  white-space: nowrap;
  pointer-events: none;
}

.scale-badge {
  position: absolute;
  bottom: 10px;
  left: 12px;
  font-family: var(--mono);
  font-size: 10px;
  color: var(--muted2);
  background: var(--surface);
  padding: 4px 8px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  pointer-events: none;
}

/* ── ROOM TABS ── */
.room-tabs-bar {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 7px 10px;
  border-top: 1px solid var(--border);
  overflow-x: auto;
  scrollbar-width: none;
  background: var(--surface);
  min-height: 44px;
}

.room-tabs-bar::-webkit-scrollbar { display: none; }

/* ── PANEL SIDE ── */
.panel-side {
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  background: var(--surface);
}

/* ── PANEL SECTIONS ── */
.psec {
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
}

.psec:last-child {
  border-bottom: none;
}

/* ── DIRECTION PANEL (per room) ── */
.direction-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
  margin-bottom: 8px;
}

.dir-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: 8px 4px;
  border: 1px solid var(--border2);
  border-radius: var(--radius);
  background: var(--surface2);
  color: var(--muted);
  font-size: 10px;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--t-fast);
}

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

.dir-btn:hover { background: var(--surface3); color: var(--text); }

.dir-btn.active {
  background: var(--ink);
  color: var(--gold);
  border-color: var(--ink);
}

/* ── MOBILE TAB BAR ── */
.mob-tabbar {
  display: none;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  overflow-x: auto;
  scrollbar-width: none;
  position: sticky;
  top: 52px;
  z-index: 15;
}

.mob-tabbar::-webkit-scrollbar { display: none; }

.mob-tabs-inner {
  display: flex;
  padding: 0 12px;
}

.mob-tab {
  padding: 10px 14px;
  font-size: 12px;
  font-weight: 500;
  color: var(--muted);
  white-space: nowrap;
  border-bottom: 2px solid transparent;
  cursor: pointer;
  transition: all var(--t-fast);
}

.mob-tab.active {
  color: var(--ink);
  border-bottom-color: var(--gold);
}

/* ── PDF OVERLAY ── */
.overlay-bg {
  position: fixed;
  inset: 0;
  background: rgba(10, 20, 30, 0.65);
  z-index: 100;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 20px;
  backdrop-filter: blur(4px);
}

.overlay-bg.show {
  display: flex;
}

.overlay-box {
  background: var(--surface);
  border-radius: var(--radius-xl);
  width: 100%;
  max-width: 700px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: var(--shadow-xl);
}

.overlay-header {
  padding: 20px 24px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.overlay-body {
  padding: 24px;
}

.overlay-footer {
  padding: 16px 24px;
  border-top: 1px solid var(--border);
  display: flex;
  gap: 8px;
  background: var(--surface2);
  border-radius: 0 0 var(--radius-xl) var(--radius-xl);
}

/* ── ESTIMATE DOCUMENT ── */
.est-doc-header {
  background: var(--ink);
  padding: 24px 28px 20px;
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  position: relative;
}

.est-doc-header::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 20px;
  right: 20px;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--gold), transparent);
}

.est-doc-body {
  padding: 20px 28px;
  background: var(--surface);
  border-radius: 0 0 var(--radius-lg) var(--radius-lg);
  border: 1px solid var(--border2);
  border-top: none;
}

/* ── PROJECTS IMPORT AREA ── */
.import-zone {
  border: 2px dashed var(--border3);
  border-radius: var(--radius-lg);
  padding: 24px;
  text-align: center;
  cursor: pointer;
  transition: all var(--t-fast);
  background: var(--surface2);
}

.import-zone:hover {
  border-color: var(--gold);
  background: var(--gold-p);
}

.import-zone.drag-over {
  border-color: var(--gold);
  background: var(--gold-p);
}
