@import url('https://fonts.googleapis.com/css2?family=Outfit:wght@300;400;500;600&display=swap');

:root {
  --color-bg: #eef2f5;
  --color-surface: rgba(255, 255, 255, 0.85);
  --color-surface-solid: #ffffff;
  --color-primary: #3b82f6;
  --color-primary-hover: #2563eb;
  --color-border: rgba(0, 0, 0, 0.08);
  --color-text: #1e293b;
  --color-text-muted: #64748b;
  --color-error: #ef4444;
  --color-success: #22c55e;
  --radius: 12px;
  --shadow: 0 8px 32px rgba(0, 0, 0, 0.05);
  --glass-border: 1px solid rgba(255, 255, 255, 0.4);
  --font-sans: 'Outfit', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  
  --speed-low: #ef4444; /* Red: 1-10 */
  --speed-mid: #eab308; /* Yellow: 10-50 */
  --speed-high: #22c55e; /* Green: 50-80 */
  --speed-max: #3b82f6; /* Blue: 80+ */
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: var(--font-sans);
  font-size: 1rem;
  line-height: 1.5;
  color: var(--color-text);
  background: var(--color-bg);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

main {
  flex: 1;
  display: flex;
  flex-direction: column;
}

/* Glassmorphism Navigation */
.app-nav {
  padding: 1rem 1.5rem;
  background: var(--color-surface);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: var(--glass-border);
  display: flex;
  align-items: center;
  gap: 1.5rem;
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05);
  position: sticky;
  top: 0;
  z-index: 1000;
}

.app-nav a {
  color: var(--color-text);
  text-decoration: none;
  font-weight: 500;
  transition: color 0.2s ease;
}

.app-nav a:hover {
  color: var(--color-primary);
}

/* Base Card / Container */
.premium-card {
  background: var(--color-surface);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: var(--glass-border);
  padding: 2rem;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

/* Inputs & Buttons */
input[type="text"],
input[type="password"],
input[type="number"],
input[type="datetime-local"],
select {
  width: 100%;
  padding: 0.6rem 1rem;
  font-size: 1rem;
  font-family: var(--font-sans);
  background: rgba(255,255,255,0.7);
  border: 1px solid var(--color-border);
  border-radius: 8px;
  transition: all 0.2s ease;
}

input:focus, select:focus {
  outline: none;
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.2);
  background: #fff;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.6rem 1.2rem;
  font-size: 0.95rem;
  font-weight: 500;
  font-family: var(--font-sans);
  color: #fff;
  background: var(--color-primary);
  border: none;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.2s ease;
  box-shadow: 0 2px 4px rgba(59, 130, 246, 0.3);
}

.btn:hover {
  background: var(--color-primary-hover);
  transform: translateY(-1px);
  box-shadow: 0 4px 6px rgba(59, 130, 246, 0.4);
}

.alert-error {
  padding: 0.75rem 1rem;
  margin-bottom: 1rem;
  border-radius: 8px;
  background: rgba(239, 68, 68, 0.1);
  color: var(--color-error);
  border: 1px solid rgba(239, 68, 68, 0.2);
  font-weight: 500;
}

/* Floating Sidebar for Map */
.map-layout {
  display: block;
  flex: 1;
  position: relative;
  overflow: hidden;
  height: calc(100vh - 65px);
}

#map {
  position: absolute;
  top: 0; left: 0; right: 0; bottom: 0;
  width: 100%;
  height: 100%;
  z-index: 1;
}

.floating-sidebar {
  position: absolute;
  top: 1rem;
  right: 1rem; /* Move to right side */
  width: 340px;
  max-height: calc(100% - 2rem);
  overflow-y: auto;
  z-index: 1000;
  background: var(--color-surface);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: var(--glass-border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1), opacity 0.3s ease, visibility 0.3s;
  transform-origin: top right;
}

.floating-sidebar.collapsed {
  transform: scale(0.1); /* Shrink into the toggle button */
  opacity: 0;
  visibility: hidden;
}

.sidebar-toggle {
  position: absolute;
  top: 1rem;
  left: 1rem;
  z-index: 999;
  background: var(--color-surface-solid);
  border: var(--glass-border);
  border-radius: 8px;
  padding: 0.5rem;
  cursor: pointer;
  box-shadow: var(--shadow);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: opacity 0.3s ease, transform 0.3s ease, visibility 0.3s;
}

.sidebar-toggle.hidden {
  opacity: 0;
  visibility: hidden;
  transform: scale(0.5);
  pointer-events: none;
}

/* User Selection Chips inside Sidebar */
.user-list {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.user-cb-label {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  cursor: pointer;
  padding: 0.5rem;
  border-radius: 6px;
  transition: background 0.2s;
}

.user-cb-label:hover {
  background: rgba(0,0,0,0.03);
}

/* ===================================================================
   Member row — app-style (v2)
   =================================================================== */
.member-row {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 8px 6px;
  border-radius: 10px;
  cursor: pointer;
  transition: background 0.15s;
}
.member-row:hover {
  background: rgba(59, 130, 246, 0.07);
}

/* Avatar circle */
.member-av {
  flex-shrink: 0;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 700;
  color: #fff;
  object-fit: cover;   /* for <img> variant */
}

/* Info block */
.member-info {
  flex: 1;
  min-width: 0;
}
.member-name {
  font-size: 0.87rem;
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 1.3;
}
.me-badge {
  font-weight: 500;
  opacity: 0.75;
}
.member-meta {
  font-size: 0.72rem;
  color: #555;
  margin-top: 1px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.member-device {
  color: #aaa;
  font-size: 0.68rem;
}
.member-still {
  margin-top: 2px;
  font-size: 0.7rem;
  color: #6366f1;
  font-weight: 600;
}

/* Action column (right side) */
.member-actions {
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 4px;
}
.member-actions-row {
  display: flex;
  align-items: center;
  gap: 4px;
}
.member-time-left {
  font-size: 0.68rem;
  color: #16a34a;
  font-weight: 600;
}

/* Compact action buttons */
.mbtn {
  padding: 3px 9px;
  border-radius: 7px;
  font-size: 0.72rem;
  font-weight: 600;
  cursor: pointer;
  border-width: 1.5px;
  border-style: solid;
  background: transparent;
  white-space: nowrap;
  transition: opacity 0.15s;
}
.mbtn:hover { opacity: 0.75; }
.mbtn-blue   { color: #3b82f6; border-color: #3b82f6; }
.mbtn-purple { color: #8b5cf6; border-color: #8b5cf6; }
.mbtn-orange { color: #f59e0b; border-color: #f59e0b; }
.mbtn-red    { color: #ef4444; border-color: #ef4444; }

/* Status badges */
.mbadge {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: 6px;
  font-size: 0.7rem;
  font-weight: 700;
  white-space: nowrap;
}
.mbadge-green { background: rgba(34,197,94,0.12);  color: #16a34a; }
.mbadge-gray  { background: rgba(156,163,175,0.15); color: #6b7280; }

/* Request button (legacy compat) */
.req-btn {
  transition: all 0.15s;
}
.req-btn:hover {
  background: #3b82f6 !important;
  color: #fff !important;
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.25rem 0.6rem;
  background: rgba(0,0,0,0.05);
  border-radius: 999px;
  font-size: 0.85rem;
  border: 1px solid var(--color-border);
}

.chip button {
  background: none;
  border: none;
  color: var(--color-text-muted);
  cursor: pointer;
  font-size: 0.8rem;
  padding: 0 0.2rem;
}

.chip button:hover {
  color: var(--color-error);
}

/* Settings Layout */
.settings-page { 
  padding: 2rem; 
  max-width: 600px;
  margin: 0 auto;
  width: 100%;
}

/* Login Layout */
.login-wrap {
  min-height: calc(100vh - 80px); /* subtract nav height if any, or full */
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  background: linear-gradient(135deg, #eef2f3 0%, #8e9eab 100%);
}

.login-card {
  width: 100%;
  max-width: 400px;
}

/* Leaflet Overrides */
.leaflet-control-zoom {
  border: none !important;
  box-shadow: var(--shadow) !important;
}
.leaflet-control-zoom-in, .leaflet-control-zoom-out {
  background: var(--color-surface-solid) !important;
  color: var(--color-text) !important;
  border-bottom: 1px solid var(--color-border) !important;
}
