/* =========================================================
   The Loft Maps — Login & Dashboard Styles
   ========================================================= */

:root {
  --bg: #0f1218;
  --bg-grad: radial-gradient(circle at top center, #1d2330 0%, #0d1016 70%);
  --surface: #171b24;
  --surface-elevated: #202634;
  --border: rgba(255, 255, 255, 0.11);
  --border-strong: rgba(255, 255, 255, 0.22);
  --text: #f3f5f8;
  --text-muted: #9aa4b6;
  --accent: #38bdf8;
  --accent-hover: #0ea5e9;
  --danger: #f43f5e;
  --success: #22c55e;
  --radius-sm: 7px;
  --radius-md: 12px;
  --radius-lg: 18px;
  --font: "Segoe UI", system-ui, -apple-system, BlinkMacSystemFont, Roboto, sans-serif;
}

*, *::before, *::after {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  padding: 0;
  min-height: 100%;
  background: var(--bg);
  background-image: var(--bg-grad);
  background-attachment: fixed;
  color: var(--text);
  font-family: var(--font);
  -webkit-font-smoothing: antialiased;
}

.hidden {
  display: none !important;
}

.brand-dot {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 14px var(--accent);
  flex-shrink: 0;
}

/* =========================================================
   Buttons & Inputs
   ========================================================= */

.btn-primary, .btn-secondary, .btn-danger-ghost {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 38px;
  padding: 0 16px;
  border-radius: var(--radius-sm);
  font-size: 13.5px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  text-decoration: none;
  transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

.btn-sm {
  height: 32px;
  padding: 0 12px;
  font-size: 12.5px;
}

.btn-full {
  width: 100%;
}

.btn-primary {
  border: 1px solid var(--accent);
  background: var(--accent);
  color: #07131d;
}

.btn-primary:hover {
  background: var(--accent-hover);
  border-color: var(--accent-hover);
}

.btn-secondary {
  border: 1px solid var(--border-strong);
  background: transparent;
  color: var(--text);
}

.btn-secondary:hover {
  background: rgba(255, 255, 255, 0.08);
}

.btn-danger-ghost {
  border: 1px solid transparent;
  background: transparent;
  color: var(--text-muted);
  padding: 0 9px;
}

.btn-danger-ghost:hover {
  background: rgba(244, 63, 94, 0.16);
  color: #fda4af;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.field label {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
}

input[type="text"],
input[type="email"],
input[type="password"],
select {
  height: 40px;
  padding: 0 12px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--surface-elevated);
  color: var(--text);
  font-size: 14px;
  font-family: inherit;
}

input:focus, select:focus {
  outline: none;
  border-color: var(--accent);
}

.hp-field {
  position: absolute;
  left: -9999px;
  opacity: 0;
  pointer-events: none;
}

/* =========================================================
   Auth View
   ========================================================= */

.auth-shell {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.auth-card {
  width: 100%;
  max-width: 410px;
  padding: 32px 28px;
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-lg);
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.5);
}

.auth-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 8px;
}

.auth-brand h1 {
  margin: 0;
  font-size: 22px;
  font-weight: 700;
}

.auth-subtitle {
  margin: 0 0 22px;
  font-size: 14px;
  line-height: 1.5;
  color: var(--text-muted);
}

.auth-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  padding: 4px;
  margin-bottom: 20px;
  border-radius: var(--radius-sm);
  background: var(--surface-elevated);
}

.auth-tab {
  height: 34px;
  border: none;
  border-radius: 5px;
  background: transparent;
  color: var(--text-muted);
  font-size: 13.5px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
}

.auth-tab.active {
  background: var(--surface);
  color: var(--text);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

.auth-form {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.auth-error {
  margin: 0;
  padding: 9px 12px;
  border-radius: var(--radius-sm);
  background: rgba(244, 63, 94, 0.14);
  border: 1px solid rgba(244, 63, 94, 0.4);
  color: #fda4af;
  font-size: 13px;
}

/* =========================================================
   Dashboard Shell & Header
   ========================================================= */

.dash-shell {
  max-width: 1320px;
  margin: 0 auto;
  padding: 22px 24px 40px;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  gap: 22px;
}

.dash-header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 16px 22px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
}

.user-identity {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.username-display {
  display: inline-flex;
  align-items: center;
  gap: 10px;
}

.username-text {
  margin: 0;
  font-size: 24px;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.big-pencil-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border: 1px solid var(--border-strong);
  border-radius: 10px;
  background: var(--surface-elevated);
  color: var(--accent);
  cursor: pointer;
  transition: transform 0.14s ease, background 0.15s ease, border-color 0.15s ease;
}

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

.big-pencil-btn:hover {
  background: rgba(56, 189, 248, 0.18);
  border-color: var(--accent);
  transform: scale(1.05);
}

.username-edit-form {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.username-edit-form input {
  height: 36px;
  font-size: 16px;
  font-weight: 600;
  width: 220px;
}

.header-right {
  display: flex;
  align-items: center;
  gap: 12px;
}

.email-badge {
  font-size: 13px;
  color: var(--text-muted);
}

/* =========================================================
   Dashboard 2-Column Layout
   ========================================================= */

.dash-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr);
  gap: 20px;
  flex: 1;
  align-items: start;
}

.dash-right-col {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.dash-panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.panel-header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.panel-header h2 {
  margin: 0;
  font-size: 18px;
  font-weight: 700;
}

.panel-sub {
  margin: 2px 0 0;
  font-size: 12.5px;
  color: var(--text-muted);
}

.panel-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.maps-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.empty-state {
  padding: 26px 16px;
  text-align: center;
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius-md);
  color: var(--text-muted);
  font-size: 13.5px;
}

/* Map Card */
.map-card {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 12px;
  border-radius: var(--radius-md);
  background: var(--surface-elevated);
  border: 1px solid var(--border);
  transition: border-color 0.15s ease, transform 0.14s ease;
}

.map-card:hover {
  border-color: var(--border-strong);
}

.map-thumb {
  width: 84px;
  height: 54px;
  border-radius: 7px;
  background: #10141c;
  border: 1px solid var(--border);
  overflow: hidden;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  font-size: 11px;
}

.map-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.map-info {
  flex: 1;
  min-width: 0;
}

.map-title-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 4px;
}

.map-title {
  margin: 0;
  font-size: 15px;
  font-weight: 700;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.map-meta {
  font-size: 12px;
  color: var(--text-muted);
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 7px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  flex-shrink: 0;
}

.badge-public {
  background: rgba(34, 197, 94, 0.16);
  color: #86efac;
}

.badge-edit {
  background: rgba(56, 189, 248, 0.16);
  color: #7dd3fc;
}

.badge-view {
  background: rgba(255, 255, 255, 0.1);
  color: var(--text-muted);
}

.map-card-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

/* =========================================================
   Modals (New Map & Share)
   ========================================================= */

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: rgba(6, 8, 12, 0.72);
  backdrop-filter: blur(6px);
}

.modal-box {
  width: 100%;
  max-width: 480px;
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-lg);
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.55);
  overflow: hidden;
}

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

.modal-head h3 {
  margin: 0;
  font-size: 17px;
}

.icon-close {
  border: none;
  background: transparent;
  color: var(--text-muted);
  font-size: 24px;
  line-height: 1;
  cursor: pointer;
}

.icon-close:hover {
  color: var(--text);
}

.modal-form, .modal-content {
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.modal-hint, .small-muted {
  margin: 0;
  font-size: 12.5px;
  color: var(--text-muted);
  line-height: 1.45;
}

.modal-foot {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 4px;
}

.share-public-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.share-link-row {
  display: flex;
  gap: 8px;
}

.share-link-row input {
  flex: 1;
  height: 32px;
  font-size: 12px;
  color: var(--text-muted);
}

.modal-sep {
  border: none;
  border-top: 1px solid var(--border);
  margin: 4px 0;
}

.add-share-form {
  display: flex;
  gap: 6px;
}

.add-share-form input {
  flex: 1;
  min-width: 0;
  height: 34px;
  font-size: 13px;
}

.add-share-form select {
  height: 34px;
  font-size: 12.5px;
  padding: 0 8px;
}

.share-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-height: 200px;
  overflow-y: auto;
}

.share-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  background: var(--surface-elevated);
  font-size: 13px;
}

/* Toggle Switch */
.switch {
  position: relative;
  display: inline-block;
  width: 42px;
  height: 24px;
  flex-shrink: 0;
}

.switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.slider {
  position: absolute;
  inset: 0;
  border-radius: 999px;
  background: #334155;
  cursor: pointer;
  transition: background 0.18s ease;
}

.slider::before {
  content: "";
  position: absolute;
  width: 18px;
  height: 18px;
  left: 3px;
  top: 3px;
  border-radius: 50%;
  background: #fff;
  transition: transform 0.18s ease;
}

.switch input:checked + .slider {
  background: var(--success);
}

.switch input:checked + .slider::before {
  transform: translateX(18px);
}

/* Toast */
.toast {
  position: fixed;
  bottom: 20px;
  right: 20px;
  z-index: 200;
  padding: 10px 16px;
  border-radius: var(--radius-md);
  background: var(--surface-elevated);
  border: 1px solid var(--border-strong);
  color: var(--text);
  font-size: 13px;
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.5);
}

@media (max-width: 900px) {
  .dash-grid {
    grid-template-columns: 1fr;
  }
}
