/* ===== Reset & Base ===== */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: #1a1a2e;
  color: #e0e0e0;
}

/* ===== Login Page ===== */
.login-page {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  background: linear-gradient(135deg, #1a1a2e 0%, #16213e 50%, #0f3460 100%);
}

.login-card {
  background: rgba(255, 255, 255, 0.06);
  backdrop-filter: blur(12px);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 20px;
  padding: 48px 40px;
  width: 100%;
  max-width: 400px;
  text-align: center;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.4);
}

.login-logo {
  width: 100%;
  max-width: 320px;
  border-radius: 16px;
  margin-bottom: 20px;
  display: block;
  margin-left: auto;
  margin-right: auto;
}

.login-title {
  font-size: 26px;
  font-weight: 700;
  color: #ffffff;
  margin-bottom: 8px;
}

.login-subtitle {
  font-size: 14px;
  color: #9ca3af;
  margin-bottom: 32px;
}

.login-error {
  background: rgba(231, 76, 60, 0.2);
  border: 1px solid rgba(231, 76, 60, 0.5);
  color: #e74c3c;
  border-radius: 10px;
  padding: 10px 16px;
  margin-bottom: 20px;
  font-size: 14px;
}

.form-group {
  margin-bottom: 16px;
}

.form-input {
  width: 100%;
  padding: 14px 18px;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 12px;
  color: #ffffff;
  font-size: 16px;
  outline: none;
  transition: border-color 0.2s, background 0.2s;
}

.form-input::placeholder {
  color: #6b7280;
}

.form-input:focus {
  border-color: #3b82f6;
  background: rgba(59, 130, 246, 0.08);
}

.btn-primary {
  width: 100%;
  padding: 14px;
  background: #3b82f6;
  color: #ffffff;
  border: none;
  border-radius: 12px;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s, transform 0.1s;
}

.btn-primary:hover {
  background: #2563eb;
}

.btn-primary:active {
  transform: scale(0.98);
}

/* ===== Map Page ===== */
.map-page {
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow: hidden;
}

.map-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 20px;
  background: #16213e;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  flex-shrink: 0;
  gap: 12px;
  z-index: 1000;
}

.map-header-title {
  font-size: 18px;
  font-weight: 700;
  color: #ffffff;
  white-space: nowrap;
}

.map-header-right {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.status-badge {
  font-size: 12px;
  font-weight: 600;
  padding: 4px 12px;
  border-radius: 20px;
  white-space: nowrap;
}

.status-connecting {
  background: rgba(245, 158, 11, 0.2);
  color: #f59e0b;
  border: 1px solid rgba(245, 158, 11, 0.4);
}

.status-online {
  background: rgba(52, 211, 153, 0.2);
  color: #34d399;
  border: 1px solid rgba(52, 211, 153, 0.4);
}

.status-error {
  background: rgba(239, 68, 68, 0.2);
  color: #ef4444;
  border: 1px solid rgba(239, 68, 68, 0.4);
}

.last-update {
  font-size: 12px;
  color: #6b7280;
  white-space: nowrap;
}

.btn-logout {
  padding: 6px 16px;
  background: rgba(239, 68, 68, 0.15);
  border: 1px solid rgba(239, 68, 68, 0.35);
  color: #ef4444;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
  text-decoration: none;
  transition: background 0.2s;
  white-space: nowrap;
}

.btn-logout:hover {
  background: rgba(239, 68, 68, 0.3);
}

#map {
  flex: 1;
  z-index: 1;
}

/* ===== Sidebar ===== */
#sidebar {
  position: absolute;
  top: 60px;
  right: 12px;
  width: 240px;
  max-height: calc(100vh - 80px);
  overflow-y: auto;
  background: rgba(22, 33, 62, 0.92);
  backdrop-filter: blur(10px);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 14px;
  padding: 16px;
  z-index: 500;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
}

.sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  cursor: pointer;
  user-select: none;
  margin-bottom: 14px;
}

.sidebar-header:hover #sidebar-toggle-icon {
  color: #ffffff;
}

#sidebar-toggle-icon {
  font-size: 12px;
  color: #6b7280;
  transition: color 0.2s;
}

.sidebar-title {
  font-size: 14px;
  font-weight: 700;
  color: #9ca3af;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: 0;
}

@media (max-width: 600px) {
  #sidebar {
    max-height: 50vh;
    overflow-y: auto;
  }
}

.child-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.04);
  margin-bottom: 8px;
  transition: background 0.15s;
}

.child-item:hover {
  background: rgba(255, 255, 255, 0.08);
}

.child-item.child-offline {
  opacity: 0.55;
}

.child-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  flex-shrink: 0;
}

.child-info {
  flex: 1;
  min-width: 0;
}

.child-name {
  font-size: 14px;
  font-weight: 600;
  color: #ffffff;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.child-time {
  font-size: 11px;
  color: #6b7280;
  margin-top: 2px;
}

.child-coords {
  font-size: 11px;
  color: #4b5563;
  font-family: monospace;
}

.child-center {
  background: none;
  border: 1px solid rgba(255, 255, 255, 0.15);
  color: #9ca3af;
  border-radius: 6px;
  width: 28px;
  height: 28px;
  cursor: pointer;
  font-size: 16px;
  flex-shrink: 0;
  transition: border-color 0.15s, color 0.15s;
}

.child-center:hover {
  border-color: #3b82f6;
  color: #3b82f6;
}

.no-children {
  font-size: 13px;
  color: #6b7280;
  text-align: center;
  line-height: 1.6;
  padding: 12px 0;
}

/* ===== Marker Label ===== */
.marker-label {
  display: inline-block;
  color: #fff;
  font-size: 12px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 10px;
  margin-bottom: 2px;
  white-space: nowrap;
  box-shadow: 0 2px 6px rgba(0,0,0,0.4);
  max-width: 120px;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ===== Scrollbar ===== */
#sidebar::-webkit-scrollbar {
  width: 4px;
}
#sidebar::-webkit-scrollbar-track {
  background: transparent;
}
#sidebar::-webkit-scrollbar-thumb {
  background: rgba(255,255,255,0.15);
  border-radius: 4px;
}

/* ===== Responsive ===== */
@media (max-width: 600px) {
  #sidebar {
    width: calc(100vw - 24px);
    right: 12px;
    left: 12px;
    top: auto;
    bottom: 12px;
    max-height: 220px;
  }

  .login-card {
    margin: 16px;
    padding: 36px 24px;
  }
}
