/* ═══════════════════════════════════════════════════════
   ManTrail – Stylesheet
   ═══════════════════════════════════════════════════════ */

/* ── Design Tokens ──────────────────────────────────── */
:root {
  --primary: #10b981;
  --primary-dark: #059669;
  --primary-light: #6ee7b7;
  --danger: #ef4444;
  --danger-dark: #dc2626;
  --bg: #0f172a;
  --bg-card: rgba(30, 41, 59, 0.85);
  --bg-surface: rgba(15, 23, 42, 0.92);
  --text: #e2e8f0;
  --text-muted: #94a3b8;
  --border: rgba(148, 163, 184, 0.15);
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
  --font: "Outfit", sans-serif;
}

/* ── Reset ──────────────────────────────────────────── */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  overflow-x: hidden;
}

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ── Views ──────────────────────────────────────────── */
.view {
  display: none;
  min-height: 100vh;
  width: 100%;
  animation: fadeIn 0.3s ease;
}
.view.active { display: flex; }

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ── Hero (Home) ────────────────────────────────────── */
.hero-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  width: 100%;
  min-height: 100vh;
  text-align: center;
  background: linear-gradient(135deg, #0f172a 0%, #1e3a5f 50%, #0f172a 100%);
  padding: 2rem;
}

.hero-container h1 {
  font-size: 3.5rem;
  font-weight: 700;
  color: var(--primary);
  margin-bottom: 0.5rem;
}

.hero-container .subtitle {
  font-size: 1.2rem;
  color: var(--text-muted);
  margin-bottom: 2rem;
}

.hero-buttons {
  display: flex;
  gap: 1rem;
  flex-wrap: wrap;
  justify-content: center;
}

/* ── Auth Card ──────────────────────────────────────── */
.auth-card {
  background: var(--bg-card);
  backdrop-filter: blur(20px);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 2.5rem;
  max-width: 400px;
  width: 90%;
  margin: auto;
  box-shadow: var(--shadow);
}

.auth-card h2 {
  text-align: center;
  margin-bottom: 1.5rem;
  color: var(--primary);
}

.link-text {
  text-align: center;
  margin-top: 1rem;
  font-size: 0.9rem;
  color: var(--text-muted);
}

/* ── Input Groups ───────────────────────────────────── */
.input-group {
  margin-bottom: 1rem;
}

.input-group label {
  display: block;
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-bottom: 0.3rem;
  font-weight: 500;
}

.input-group input,
.input-group select,
.input-group textarea {
  width: 100%;
  padding: 0.6rem 0.8rem;
  background: rgba(15, 23, 42, 0.6);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-family: var(--font);
  font-size: 0.95rem;
  transition: border-color 0.2s;
}

.input-group input:focus,
.input-group select:focus,
.input-group textarea:focus {
  outline: none;
  border-color: var(--primary);
}

/* ── Buttons ────────────────────────────────────────── */
.btn {
  padding: 0.55rem 1.2rem;
  border: none;
  border-radius: var(--radius-sm);
  font-family: var(--font);
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
}

.btn:hover { transform: translateY(-1px); filter: brightness(1.1); }
.btn:active { transform: translateY(0); }

.btn-primary {
  background: var(--primary);
  color: #fff;
}
.btn-primary:hover { background: var(--primary-dark); }

.btn-secondary {
  background: rgba(148, 163, 184, 0.2);
  color: var(--text);
}
.btn-secondary:hover { background: rgba(148, 163, 184, 0.3); }

.btn-active {
  background: rgba(16, 185, 129, 0.25);
  color: var(--primary-light);
  border: 1px solid rgba(16, 185, 129, 0.4);
}
.btn-active:hover { background: rgba(16, 185, 129, 0.35); }

.btn-danger {
  background: var(--danger);
  color: #fff;
}
.btn-danger:hover { background: var(--danger-dark); }

.btn-block { width: 100%; justify-content: center; }

.btn-sm { padding: 0.3rem 0.7rem; font-size: 0.8rem; }
.btn-xs { padding: 0.2rem 0.5rem; font-size: 0.75rem; }

/* ── Dashboard Layout ───────────────────────────────── */
.dashboard-layout {
  display: flex;
  width: 100%;
  height: 100vh;
}

.sidebar {
  width: 360px;
  min-width: 360px;
  background: var(--bg-surface);
  border-right: 1px solid var(--border);
  overflow-y: auto;
  overflow-x: hidden;
  display: flex;
  flex-direction: column;
  position: relative;
  transition: width 0.25s ease, min-width 0.25s ease;
  flex-shrink: 0;

  /* Firefox */
  scrollbar-width: thin;
  scrollbar-color: rgba(148, 163, 184, 0.2) transparent;
}

/* WebKit: Chrome, Edge, Safari */
.sidebar::-webkit-scrollbar {
  width: 5px;
}

.sidebar::-webkit-scrollbar-track {
  background: transparent;
}

.sidebar::-webkit-scrollbar-thumb {
  background: rgba(148, 163, 184, 0.18);
  border-radius: 10px;
  transition: background 0.2s;
}

.sidebar::-webkit-scrollbar-thumb:hover {
  background: rgba(16, 185, 129, 0.45);
}

.sidebar::-webkit-scrollbar-thumb:active {
  background: var(--primary);
}

.sidebar.is-resizing {
  transition: none;
}

.sidebar.collapsed {
  width: 0 !important;
  min-width: 0 !important;
  overflow: hidden;
}

/* ── Sidebar Header ─────────────────────────────────── */
.sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1.2rem;
  border-bottom: 1px solid var(--border);
  background: rgba(16, 185, 129, 0.08);
  white-space: nowrap;
}

.sidebar-header h2 {
  font-size: 1.1rem;
  color: var(--primary);
  overflow: hidden;
  text-overflow: ellipsis;
}

.sidebar-header-actions {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  flex-shrink: 0;
}

.sidebar-toggle-btn {
  background: rgba(148, 163, 184, 0.12);
  color: var(--text-muted);
  border: 1px solid var(--border);
  width: 30px;
  height: 30px;
  padding: 0;
  justify-content: center;
}

.sidebar-toggle-btn:hover {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}

/* ── Sidebar Resize Handle ──────────────────────────── */
.sidebar-resize-handle {
  width: 5px;
  flex-shrink: 0;
  cursor: col-resize;
  background: transparent;
  transition: background 0.2s;
  z-index: 20;
  position: relative;
}

.sidebar-resize-handle:hover,
.sidebar-resize-handle.is-resizing {
  background: rgba(16, 185, 129, 0.35);
}

/* ── Sidebar Open Button (on map when collapsed) ────── */
.sidebar-open-btn {
  position: absolute;
  top: 12px;
  left: 12px;
  z-index: 20;
  width: 40px;
  height: 40px;
  border: none;
  border-radius: 8px;
  background: var(--bg-card);
  color: var(--text);
  font-size: 1.1rem;
  cursor: pointer;
  display: none;
  align-items: center;
  justify-content: center;
  box-shadow: var(--shadow);
  backdrop-filter: blur(10px);
  transition: all 0.2s;
}

/* Hide the text label on desktop — icon only */
.sidebar-open-btn span {
  display: none;
}

.sidebar-open-btn:hover {
  background: var(--primary);
  color: #fff;
}

.sidebar-section {
  padding: 1rem 1.2rem;
  border-bottom: 1px solid var(--border);
}

.sidebar-section h3 {
  font-size: 0.95rem;
  font-weight: 600;
  margin-bottom: 0.8rem;
  color: var(--primary-light);
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.map-container {
  flex: 1;
  position: relative;
  min-width: 0;
}

.map {
  width: 100%;
  height: 100%;
}

/* ── Map Controls (customer / shared) ──────────────── */
.map-controls {
  position: absolute;
  top: 12px;
  left: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 10;
}

.map-ctrl-btn {
  width: 40px;
  height: 40px;
  border: none;
  border-radius: 8px;
  background: var(--bg-card);
  color: var(--text);
  font-size: 1.1rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: var(--shadow);
  transition: all 0.2s;
  backdrop-filter: blur(10px);
}

.map-ctrl-btn:hover {
  background: var(--primary);
  color: #fff;
}

/* ── Floating Draw Panel (trainer, top-center) ──────── */
.map-draw-panel {
  position: absolute;
  top: 12px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 10;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  backdrop-filter: blur(14px);
  box-shadow: var(--shadow);
  min-width: 380px;
  max-width: calc(100% - 200px);
}

.draw-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.45rem 0.9rem;
  cursor: pointer;
  user-select: none;
  border-bottom: 1px solid var(--border);
}

.map-draw-panel.collapsed .draw-panel-header {
  border-bottom: none;
}

.draw-panel-title {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--primary-light);
  display: flex;
  align-items: center;
  gap: 0.45rem;
}

.draw-panel-toggle {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 0.15rem 0.4rem;
  border-radius: 4px;
  font-size: 0.8rem;
  transition: color 0.2s, background 0.2s;
  line-height: 1;
}

.draw-panel-toggle:hover {
  color: var(--primary);
  background: rgba(16, 185, 129, 0.12);
}

.draw-panel-body {
  padding: 0.6rem 0.9rem;
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
  overflow: visible;
  transition: opacity 0.22s ease, padding 0.22s ease;
  opacity: 1;
}

.map-draw-panel.collapsed .draw-panel-body {
  display: none;
  opacity: 0;
}

.draw-panel-tools {
  display: flex;
  align-items: center;
  gap: 0.35rem;
}

.draw-panel-sep {
  width: 1px;
  height: 28px;
  background: var(--border);
  margin: 0 0.2rem;
  flex-shrink: 0;
}

/* Tool buttons inside draw panel are smaller */
.draw-panel-tools .map-ctrl-btn {
  width: 36px;
  height: 36px;
  font-size: 1rem;
  flex-shrink: 0;
}

.draw-panel-save {
  display: flex;
  gap: 0.5rem;
  align-items: center;
}

.draw-panel-save input {
  flex: 1;
  padding: 0.45rem 0.7rem;
  background: rgba(15, 23, 42, 0.6);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-family: var(--font);
  font-size: 0.88rem;
  min-width: 0;
}

.draw-panel-save input:focus {
  outline: none;
  border-color: var(--primary);
}

.draw-panel-save .btn {
  white-space: nowrap;
  flex-shrink: 0;
}

/* ── Tool Buttons ───────────────────────────────────── */
.tool-btn {
  width: 36px;
  height: 36px;
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  background: rgba(15, 23, 42, 0.6);
  color: var(--text-muted);
  font-size: 0.95rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
  flex-shrink: 0;
}

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

.tool-btn.active {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
}

/* ── Draw tool color picker ─────────────────────────── */
.draw-tool-wrap {
  position: relative;
}

.draw-color-dot {
  position: absolute;
  bottom: 3px;
  right: 3px;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #e63946;
  border: 1px solid rgba(255,255,255,0.6);
  pointer-events: none;
}

.draw-color-dropdown {
  display: none;
  position: absolute;
  top: calc(100% + 6px);
  left: 50%;
  transform: translateX(-50%);
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 6px;
  gap: 6px;
  flex-direction: row;
  box-shadow: var(--shadow);
  z-index: 100;
}

.draw-color-dropdown.open {
  display: flex;
}

.color-swatch {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  border: 2px solid transparent;
  cursor: pointer;
  transition: transform 0.15s, border-color 0.15s;
  flex-shrink: 0;
}

.color-swatch:hover {
  transform: scale(1.2);
}

.color-swatch.selected {
  border-color: #fff;
  box-shadow: 0 0 0 2px var(--primary);
}

/* ── Trail List ─────────────────────────────────────── */
.trail-list, .customer-list, .user-list, .notes-list {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.trail-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.6rem 0.8rem;
  background: rgba(15, 23, 42, 0.5);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  transition: border-color 0.2s;
  cursor: pointer;
}

.trail-item:hover {
  border-color: var(--primary);
}

.trail-item.trail-dragging {
  opacity: 0.25;
  border-style: dashed;
}

/* ── Drag handle ────────────────────────────────────── */
.trail-drag-handle {
  touch-action: none;   /* prevents scroll from stealing the pointer on mobile */
  cursor: grab;
  color: var(--text-muted);
  padding: 0.2rem 0.35rem 0.2rem 0;
  flex-shrink: 0;
  font-size: 0.8rem;
  opacity: 0.45;
  transition: opacity 0.15s;
}

.trail-item:hover .trail-drag-handle,
.trail-drag-handle:active {
  opacity: 1;
  cursor: grabbing;
}

/* ── Drag-over drop targets ─────────────────────────── */
.container-group.drag-over {
  outline: 2px solid var(--primary);
  outline-offset: -2px;
}

.container-group.drag-over > .container-header,
.container-group.drag-over > .container-header-plain {
  background: rgba(16, 185, 129, 0.22);
  color: var(--primary-light);
}

.container-group.drag-over > .container-trails {
  background: rgba(16, 185, 129, 0.05);
  min-height: 2.5rem;
}

.trail-item-info {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}

.trail-item-info strong {
  font-size: 0.9rem;
}

.trail-length {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.trail-item-actions {
  display: flex;
  gap: 0.3rem;
}

/* ── Trail-List toolbar ─────────────────────────────── */
.trail-list-toolbar {
  display: flex;
  gap: 0.4rem;
  margin-bottom: 0.5rem;
  flex-wrap: wrap;
}

/* ── Container groups ───────────────────────────────── */
.container-group {
  margin-bottom: 0.4rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  overflow: hidden;
}

.container-group.is-active {
  border-color: var(--primary);
}

.container-header {
  display: flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.5rem 0.7rem;
  background: rgba(16, 185, 129, 0.08);
  user-select: none;
  transition: background 0.15s;
}

.container-header:hover {
  background: rgba(16, 185, 129, 0.15);
}

.is-active .container-header {
  background: rgba(16, 185, 129, 0.18);
}

.container-eye-btn {
  background: none;
  border: none;
  padding: 0.2rem 0.35rem;
  border-radius: 4px;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 0.9rem;
  flex-shrink: 0;
  transition: color 0.15s, background 0.15s;
}

.container-eye-btn:hover {
  color: var(--primary-light);
  background: rgba(16, 185, 129, 0.15);
}

.is-active .container-eye-btn {
  color: var(--primary-light);
}

.container-header-plain {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.5rem 0.7rem;
  background: rgba(15, 23, 42, 0.4);
  color: var(--text-muted);
  font-size: 0.82rem;
}

.container-title {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--primary-light);
  min-width: 0;
  flex: 1;
  cursor: pointer;
  padding: 0.1rem 0.2rem;
  border-radius: 4px;
}

.container-title span:first-of-type {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.container-count {
  background: rgba(16, 185, 129, 0.2);
  color: var(--primary-light);
  font-size: 0.72rem;
  font-weight: 700;
  border-radius: 20px;
  padding: 0 0.4rem;
  flex-shrink: 0;
}

.container-actions {
  display: flex;
  gap: 0.25rem;
  flex-shrink: 0;
  margin-left: 0.4rem;
}

.container-trails {
  padding: 0.35rem;
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}

.container-trails .trail-item {
  border-radius: calc(var(--radius-sm) - 2px);
}

/* Container collapse */
.container-trails {
  transition: max-height 0.2s ease, padding 0.2s ease, opacity 0.2s ease;
  opacity: 1;
}

.container-trails.is-collapsed {
  max-height: 0 !important;
  padding: 0 !important;
  opacity: 0;
  overflow: hidden;
}

.container-collapse-btn {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text-muted);
  padding: 0.1rem 0.3rem;
  border-radius: 4px;
  font-size: 0.75rem;
  transition: color 0.15s, transform 0.2s;
  flex-shrink: 0;
  line-height: 1;
}

.container-collapse-btn:hover { color: var(--primary-light); }

.container-collapse-btn.is-collapsed i {
  transform: rotate(-90deg);
}

.empty-state-sm {
  font-size: 0.78rem;
  color: var(--text-muted);
  padding: 0.4rem 0.3rem;
  text-align: center;
  font-style: italic;
}

/* ── Customer List ──────────────────────────────────── */
.customer-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.6rem 0.8rem;
  background: rgba(15, 23, 42, 0.5);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}

.customer-info {
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

.customer-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid var(--border);
}

.customer-dog {
  display: block;
  font-size: 0.78rem;
  color: var(--text-muted);
}

.customer-actions {
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

/* ── User List (Admin) ──────────────────────────────── */
.admin-main {
  flex: 1;
  padding: 1.5rem;
  overflow-y: auto;
}

.admin-main h3 {
  margin-bottom: 1rem;
  color: var(--primary-light);
}

.user-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.7rem 1rem;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  margin-bottom: 0.5rem;
}

.user-info {
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

.user-actions {
  display: flex;
  gap: 0.3rem;
}

/* ── Badges ─────────────────────────────────────────── */
.badge {
  padding: 0.15rem 0.5rem;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 600;
  color: #fff;
  background: var(--primary-dark);
}

.badge-trainer { background: #3b82f6; }
.badge-customer { background: #a855f7; }
.badge-admin { background: #ef4444; }
.badge-green { background: var(--primary-dark); }
.badge-red { background: var(--danger); }

/* ── Invite Section ─────────────────────────────────── */
.invite-section {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.invite-label {
  font-size: 0.85rem;
  color: var(--text-muted);
}

.invite-code-display {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.invite-code-display code {
  background: rgba(16, 185, 129, 0.15);
  padding: 0.4rem 0.8rem;
  border-radius: var(--radius-sm);
  font-size: 1.1rem;
  font-weight: 600;
  letter-spacing: 2px;
  color: var(--primary);
  flex: 1;
  text-align: center;
}

/* ── Profile Photo (Customer) ───────────────────────── */
.profile-photo-container {
  position: relative;
  width: 100px;
  height: 100px;
  margin: 0 auto 0.8rem;
  cursor: pointer;
}

.profile-photo-container.profile-photo-lg {
  width: 140px;
  height: 140px;
}

.profile-photo {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  object-fit: cover;
  border: 3px solid var(--primary);
}

.photo-overlay {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 1.5rem;
  opacity: 0;
  transition: opacity 0.2s;
}

.profile-photo-container:hover .photo-overlay {
  opacity: 1;
}

.profile-username {
  text-align: center;
  font-size: 1.1rem;
  margin-bottom: 1rem;
  color: var(--text);
}

/* ── Dog Manager (Customer) ─────────────────────────── */
.dog-manager {
  margin-top: 0.5rem;
}

.cust-profile-right {
  flex: 1;
  min-width: 0;
}

.dog-manager-label {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-bottom: 0.4rem;
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.dog-chip-list {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-bottom: 0.6rem;
  min-height: 1.5rem;
}

.dog-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  background: rgba(16, 185, 129, 0.12);
  border: 1px solid rgba(16, 185, 129, 0.3);
  border-radius: 999px;
  padding: 0.2rem 0.55rem 0.2rem 0.45rem;
  font-size: 0.82rem;
  color: var(--text);
}

.dog-chip i {
  color: var(--primary);
  font-size: 0.78rem;
}

.dog-chip-remove {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text-muted);
  padding: 0 0 0 0.15rem;
  line-height: 1;
  font-size: 0.78rem;
  transition: color 0.15s;
}
.dog-chip-remove:hover { color: var(--danger); }

.dog-empty {
  font-size: 0.82rem;
  color: var(--text-muted);
  font-style: italic;
}

.dog-add-row {
  display: flex;
  gap: 0.4rem;
  align-items: center;
}

.dog-add-row input {
  flex: 1;
  background: rgba(15, 23, 42, 0.6);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  padding: 0.3rem 0.6rem;
  font-size: 0.85rem;
  outline: none;
}
.dog-add-row input:focus {
  border-color: var(--primary);
}

/* ── Stats Grid ─────────────────────────────────────── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(80px, 1fr));
  gap: 0.5rem;
}

.stat-card {
  background: rgba(15, 23, 42, 0.5);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.6rem;
  text-align: center;
}

.stat-value {
  display: block;
  font-size: 1.3rem;
  font-weight: 700;
  color: var(--primary);
}

.stat-label {
  display: block;
  font-size: 0.7rem;
  color: var(--text-muted);
  margin-top: 0.2rem;
}

/* ── Modal ──────────────────────────────────────────── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  backdrop-filter: blur(4px);
}

.modal-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 2rem;
  max-width: 480px;
  width: 90%;
  box-shadow: var(--shadow);
  animation: fadeIn 0.2s ease;
}

.modal-card h3 {
  color: var(--primary);
  margin-bottom: 1rem;
}

.modal-buttons {
  display: flex;
  gap: 0.5rem;
  margin-top: 1rem;
  justify-content: flex-end;
}

/* ── Notes ──────────────────────────────────────────── */
.note-item {
  padding: 0.6rem 0.8rem;
  background: rgba(15, 23, 42, 0.5);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}

.note-item p {
  font-size: 0.9rem;
  margin-bottom: 0.3rem;
}

.note-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.note-meta small {
  color: var(--text-muted);
  font-size: 0.75rem;
}

/* ── Empty State ────────────────────────────────────── */
.empty-state {
  text-align: center;
  color: var(--text-muted);
  padding: 1rem;
  font-size: 0.85rem;
  font-style: italic;
}

/* ── GPS Marker ─────────────────────────────────────── */
.gps-marker {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: rgba(59, 130, 246, 0.3);
  border: 3px solid #3b82f6;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #3b82f6;
  font-size: 1rem;
  animation: gpsPulse 2s ease-in-out infinite;
}

@keyframes gpsPulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(59, 130, 246, 0.4); }
  50% { box-shadow: 0 0 0 12px rgba(59, 130, 246, 0); }
}

/* ── Loading Overlay ──────────────────────────────────── */
.loading-overlay {
  position: absolute;
  inset: 0;
  background: rgba(15, 23, 42, 0.7);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  z-index: 500;
  color: var(--text-muted);
  font-size: 0.9rem;
  backdrop-filter: blur(2px);
}

.loading-spinner {
  width: 36px;
  height: 36px;
  border: 3px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* ── Clickable Items ────────────────────────────────── */
.clickable {
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}
.clickable:hover {
  background: rgba(139, 92, 246, 0.1);
  border-color: var(--primary);
}

/* ── Customer Detail Modal ──────────────────────────── */
.modal-card-lg {
  max-width: 560px;
}

.cd-header {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-bottom: 1.2rem;
}

.customer-avatar-lg {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid var(--primary);
}

.cd-header h3 {
  margin: 0;
}

.cd-dog {
  color: var(--text-muted);
  font-size: 0.85rem;
  margin: 0.15rem 0 0;
}

.cd-assignments {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  max-height: 250px;
  overflow-y: auto;
  margin-bottom: 0.5rem;
}

.cd-assignment-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.6rem 0.8rem;
  background: rgba(15, 23, 42, 0.5);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}

.cd-assignment-info {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}

.cd-assignment-info strong {
  font-size: 0.9rem;
}

.cd-assignment-info .trail-length {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.cd-note-preview {
  font-size: 0.75rem;
  color: var(--text-muted);
  font-style: italic;
  margin-top: 0.1rem;
}

.cd-note-preview i {
  color: var(--primary);
  margin-right: 0.25rem;
}

.cd-assignment-actions {
  display: flex;
  gap: 0.3rem;
  flex-shrink: 0;
  margin-left: 0.5rem;
}

.btn-note-active {
  background: rgba(16, 185, 129, 0.2);
  color: var(--primary-light);
  border-color: rgba(16, 185, 129, 0.4);
}

/* Payment buttons */
.btn-success {
  background: #10b981;
  color: #fff;
  border: none;
}
.btn-success:hover {
  background: #059669;
}

.btn-warning {
  background: #f59e0b;
  color: #000;
  border: none;
}
.btn-warning:hover {
  background: #d97706;
}

/* ── Hint Text ──────────────────────────────────────── */
.hint-text {
  color: var(--text-muted);
  font-size: 0.85rem;
  margin-bottom: 0.75rem;
}


/* ── Responsive ─────────────────────────────────────── */
@media (max-width: 768px) {
  /* Dashboard: map top, sidebar bottom */
  .dashboard-layout {
    flex-direction: column-reverse;
    height: 100dvh;
    overflow: hidden;
  }

  .map-container {
    flex: 1;
    min-height: 0;
  }

  .sidebar {
    width: 100% !important;
    min-width: 100% !important;
    height: 45vh;
    max-height: 80vh;
    min-height: 0;
    border-right: none;
    border-top: 1px solid var(--border);
    transition: height 0.32s cubic-bezier(0.4, 0, 0.2, 1),
                opacity 0.28s ease;
    opacity: 1;
    overflow-x: hidden;
    overflow-y: auto;
    flex-direction: column;
    flex-shrink: 0;
  }

  .sidebar.collapsed {
    height: 0 !important;
    min-height: 0 !important;
    overflow: hidden;
    opacity: 0;
  }

  .sidebar-resize-handle {
    display: none !important;
  }

  /* Hide desktop toggle chevron on mobile */
  .sidebar-toggle-btn {
    display: none;
  }

  /* ── Mobile sidebar toggle pill ── */
  .sidebar-open-btn {
    display: flex !important;   /* always visible on mobile */
    position: absolute;
    bottom: 14px;
    left: 50%;
    top: auto;
    transform: translateX(-50%);
    width: auto;
    min-width: 110px;
    padding: 0 1.4rem;
    border-radius: 999px;
    height: 44px;
    white-space: nowrap;
    gap: 0.5rem;
    /* Override desktop appearance */
    background: var(--primary);
    color: #fff;
    border: none;
    font-size: 0.9rem;
    font-weight: 600;
    box-shadow: 0 4px 18px rgba(16, 185, 129, 0.45),
                0 1px 4px rgba(0,0,0,0.18);
    backdrop-filter: none;
  }

  .sidebar-open-btn:hover {
    background: #059669;
    color: #fff;
    box-shadow: 0 6px 24px rgba(16, 185, 129, 0.55);
    transform: translateX(-50%) translateY(-1px);
  }

  .sidebar-open-btn:active {
    transform: translateX(-50%) translateY(0);
    box-shadow: 0 2px 10px rgba(16, 185, 129, 0.35);
  }

  .sidebar-open-btn span {
    display: inline;
  }

  .sidebar-open-btn i {
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  }

  /* Rotate chevron when sidebar is open (set by JS) */
  .sidebar-open-btn.is-open i {
    transform: rotate(180deg);
  }

  /* Profile section: horizontal compact layout */
  .cust-profile-section {
    display: flex;
    flex-direction: row;
    align-items: flex-start;
    gap: 1rem;
    padding: 0.75rem 1rem;
  }

  .profile-photo-container.profile-photo-lg {
    width: 72px !important;
    height: 72px !important;
    flex-shrink: 0;
    margin: 0;
  }

  .profile-username {
    font-size: 0.95rem;
    margin-bottom: 0.4rem;
    text-align: left;
  }

  .cust-profile-right {
    flex: 1;
    min-width: 0;
  }

  .dog-manager-label {
    font-size: 0.8rem;
  }

  .dog-chip-list {
    gap: 0.3rem;
  }

  .dog-chip {
    font-size: 0.78rem;
    padding: 0.15rem 0.45rem 0.15rem 0.35rem;
  }

  /* Draw panel: full width, compact tools with wrapping */
  .map-draw-panel {
    min-width: calc(100vw - 16px);
    max-width: calc(100vw - 16px);
    left: 8px;
    transform: none;
  }

  .draw-panel-tools {
    flex-wrap: wrap;
    gap: 0.3rem;
  }

  .draw-panel-save {
    flex-direction: column;
  }

  .draw-panel-save input,
  .draw-panel-save .btn {
    width: 100%;
  }

  /* Modals: full screen on mobile */
  .modal-card {
    width: 100%;
    max-width: 100%;
    max-height: 90dvh;
    overflow-y: auto;
    border-radius: var(--radius) var(--radius) 0 0;
    margin: auto 0 0;
  }

  .modal-overlay {
    align-items: flex-end;
  }

  .modal-card-lg {
    max-height: 90dvh;
  }

  /* Map controls: don't overlap draw panel */
  .map-controls {
    top: auto;
    bottom: 12px;
    left: 12px;
  }

  .hero-container h1 {
    font-size: 2.2rem;
  }

  .auth-card {
    padding: 1.5rem;
  }
}
